[R-sig-ME] removing random slope effect from fitted values

Austin Frank austin.frank at gmail.com
Thu Feb 26 22:05:50 CET 2009


Hello all!

I would like to look at the difference between predicted values using
the original models specification (using fitted()) and predicted values
based on all predictors except one.

Say I have a model like

  model <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

And I want to look at the predicted values of the model if all
information about Days is excluded (not very interesting in this model,
I know).

If the normal predictions are

  ## taken from lmer.R
  Xbeta = model at X %*% model at fixef
  Zb = crossprod(model at Zt, model at ranef)@x
  Y = Xbeta + Zb

Then I think the fixed effects excluding the predictor of interest
should be

  predictorIndex = which(names(model at fixef) == "Days")
  Xbeta.hat = model at X[, -predictorIndex] %*% model at fixef[-predictorIndex]

But I can't figure out how to exclude a particular random slope term.
Part of the difficulty is that there might be more than one random slope
term for the same predictor if there are non-nested random effects in
the model.  I want to exclude the random slope term for the predictor of
interest from any random effect it appeared in.

I think that the best way to approach this might be to zero out the
relevant cells in the @Zt slot of the model, but I can't come up with a
good way to programmatically determine which cells need to be changed.
I've looked at lme4:::whichterms(), lme4:::reinds(), and
lme4:::whichreinds(), but those tell you where different grouping
factors start in @Zt, not where different random effects terms start
within a grouping factor.

Does anyone have any suggestions about how to remove a specific random
slope term from the Zb calculation above?


Thanks for any help,
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc




More information about the R-sig-mixed-models mailing list