Hello all,
I have fit an lmer() model to binomial data collected on a number of
subjects and obtained the predicted values using fitted(). The model has
several fixed effects plus a random intercept and slope.
I would now like to predict for a "new" data set. This I have developed
by simply
subsampling across the range of fitted values, and then replicating for
all subjects the same set of covariates linked with each of the
subsampled observations.
I can obtain predictions for the new data set based on the fixed effects
only using model.matrix() together with fixef():
fit <- lmer( bin ~ formula + (1+x1 | Subject), data=dat.original,
family=binomial)
X <- model.matrix(~ formula, data=dat.new)
b <- fixef(fit)
pred.f <- X %*% b ; pred.f <- exp(pred.f)/(1+exp(pred.f))
However I am struggling to build predictions for the new data set
incorporating both the estimated fixed and random effects. I believe the
information necessary to do this is available from the slots in the
lmer-class object, but I can't work our exactly how.
Any help would be greatly appreciated! I am using Package lme4 version
0.99875-7.
Thanks,
Sophie
[[alternative HTML version deleted]]