You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following example, predict only works when all levels of a predictor are given, but it should work when all levels or any subset is given by applying the original contrasts rather than re-calculating the contrasts for the new object. The issue appears to be similar to one posted on Stack Exchange which has a suggested patch: http://stats.stackexchange.com/questions/29513/error-in-getting-predictions-from-a-lme-object
# Fails "contrasts can be applied only to factors with 2 or more levels"
predict(mymod, newdata=data.frame(disp=100, gear=factor("3")))
# Fails "Error in p %*% beta[pmap[[nm]]] : non-conformable arguments"
predict(mymod, newdata=data.frame(disp=100, gear=factor(c("3", "4"))))
# Succeeds
predict(mymod, newdata=data.frame(disp=100, gear=factor(c("3", "4", "5"))))
In the following example, predict only works when all levels of a predictor are given, but it should work when all levels or any subset is given by applying the original contrasts rather than re-calculating the contrasts for the new object. The issue appears to be similar to one posted on Stack Exchange which has a suggested patch: http://stats.stackexchange.com/questions/29513/error-in-getting-predictions-from-a-lme-object
library(nlme)
d.mod <- mtcars
d.mod$gear <- factor(d.mod$gear)
mymod <-
gnls(mp∼e.gear*disp,
data=d.mod,
params=e.gea∼gear-1,
start=rep(0.1, nlevels(d.mod$gear)))
summary(mymod)
# Fails "contrasts can be applied only to factors with 2 or more levels"
predict(mymod, newdata=data.frame(disp=100, gear=factor("3")))
# Fails "Error in p %*% beta[pmap[[nm]]] : non-conformable arguments"
predict(mymod, newdata=data.frame(disp=100, gear=factor(c("3", "4"))))
# Succeeds
predict(mymod, newdata=data.frame(disp=100, gear=factor(c("3", "4", "5"))))
METADATA
RELATED ISSUES
Blocks Bugzilla #17228
The text was updated successfully, but these errors were encountered: