Predict with new random effects

Viewed 1630

When fitting a mixed effects model (or any other model), it's often useful to predict "counterfactual" fitted values, using new data or new model parameters. In my situation, I would like to predict fitted values with new random effects.

The lme4 package allows one to insert new parameters to be used in place of the beta, theta and sigma slots of the merMod class. This would allow one to predict fitted values under counterfactual fixed effects coefficients. How can I do the same for the random effects estimates?

My first thought was to directly modify the u slot of the merMod object, but that doesn't seem to do anything. What can I do?

Example code:

library(lme4)

# use sleepstudy example
fm1 <- lmer(Reaction ~ Days + (1 | Subject), sleepstudy)

# estimate predictions
fm1Predictions <- predict(fm1)

# estimate predictions with new fixed effects (arbitrarily set to 10)
cfPredictions <- predict(fm1, newparams=list('theta'=10)) # different than fm1Predictions

# estimate predictions with new random effects
fm2 <- fm1
fm2@u <- rep(10,length(fm2@u))
fm2Predictions <- predict(fm2) # same as fm1Predictions
1 Answers
Related