[R-sig-ME] lmer how to get predictions and confidence intervals

Ben Bolker bbolker at gmail.com
Thu Jul 11 18:38:43 CEST 2013


Ron Stone <ronstone1980 at ...> writes:

> 
> Dear all,
> 
> My question is how to get predictions and confidence intervals when using
> lmer?
> 
> I have spend the whole previous day working with this whithout any success.
> I have tried library(ggplot2), further I tried ezPredict in the "ez"
> package, but I find it difficult to adapt my model to the provided scripts.
> I assume that I'm on the right track, but needs help to write the right
> script to achive predictions and confidence interval for my model.
> 
> I have the following model:
> 
> Speed = fixed effect (continous)
> BodyMass = fixed effect (continous)
> ID = random effect
> Species = random effect.
> 
> lmerfit1<-(Speed~BodyMass+(1|ID)+(1|Species))
> 
> >From this I would like to make a regression curve with confidence
> intervals, showing the effect of BodyMass on Speed.

   Have you looked at the recipes on http://glmm.wikidot.com/faq ?

   Nit-picky point, I would call "Speed" a response (i.e. "fixed"
vs "random" refers to predictor/input variables).

  The development version of lme4 (available from github or
http://lme4.r-forge.r-project.org/repos/ ) has a predict method.

The tricky/hard part of generating predictions and confidence
intervals on mixed models is that you have to decide which predictors
you are going condition on and which you are going to marginalize over.
For example, are you trying to predict speeds for a _particular_
individual of a _particular_ species of a particular body mass?
Of an _average_ individual of a particular species?  The predict()
method gives you a fair amount of flexibility in deciding about
conditioning for predictions.  Computing confidence intervals is
harder because you need to decide which components of uncertainty
you're going to include.

  Ben Bolker



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