Hi all,

I am trying to get predictions for individual level observations for an lme
object. Yet, since I am get different types of errors for different trials,
it seems to me I am missing something.  My model is the following:

model <- lme(log(child_mortality) ~ as.factor(cluster)*time +
             my.new.time.one.transition.low.and.middle + ttd +
             maternal_educ+ log(IHME_id_gdppc) + hiv_prev-1,
             merged0,na.action=na.omit,method="ML",weights=varPower(form =
~ time),
             random= ~ time| country.x,
             correlation=corAR1(form = ~ time),
             control=lmeControl(msMaxIter = 200, msVerbose = TRUE))


It runs fine and the results make sense. Now my attempts to get
predictions. For example:

> test.pred <-
 data.frame(time=c(10,10,10,10),country.x=c("Poland","Brazil","Argentina","France"),
+
my.new.time.one.transition.low.and.middle=c(1,1,1,0),ttd=c(0,0,0,0),
+
maternal_educ=c(10,10,10,10),IHME_id_gdppc=c(log(5000),log(8000),log(8000),log(15000)),
+                          hiv_prev=c(.005,.005,.005,.005),
+                          cluster=c("One Transition, Middle Income","One
Transition, Middle Income",
+                                                        "One Transition,
Middle Income","Democracy, High Income"))
>
> predict(model,test.pred,level=0)


Error in X %*% fixef(object) : non-conformable arguments

If I exclude, say, France, and only include countries in which cluster="One
Transition, Middle Income" in my toy example, then I get a different error


 predict(model,test.pred,level=0)
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
  contrasts can be applied only to factors with 2 or more levels



My object is to calculate counterfactual scenarios (predictions and
intervals for them) for different subsets of my data. Could you please
help?


Many thanks,


Antonio Pedro.

	[[alternative HTML version deleted]]

