[R-sig-ME] prediction intervals from a mixed-effects models?

D Chaws cat.dev.urandom at gmail.com
Wed Feb 17 22:34:07 CET 2010


This is an old post from April, 2008.  Spencer, you indicated you were
off to find a solution.  Did you ever solve the problem
of getting prediction intervals from lme?  I think the community would
benefit greatly if you did and would like to share it.  I
know I have been trying to find this for quite some time.

-D Chaws

--------------------------------------------------------------------------------------
     How can I get prediction intervals from a mixed-effects model?
Consider the following example:

library(nlme)
fm3 <- lme(distance ~ age*Sex, data = Orthodont, random = ~ 1)
df3.1 <- with(Orthodont, data.frame(age=seq(5, 20, 5),
                    Subject=rep(Subject[1], 4),
                    Sex=rep(Sex[1], 4)))
predict(fm3, df3.1, interval='prediction')
#      M01      M01      M01      M01
# 22.69012 26.61199 30.53387 34.45574

# NOTE:  The 'interval' argument to the 'predict' function was ignored.
# It works works for an 'lm' object, but not an 'lme' object.

      One way to do this might be via mcmcsamp of the corresponding
'lmer' model:

library(lme4)
set.seed(3)
samp3r <- mcmcsamp(fm3r, n=10000)
samp3r[1:2,]

      Then use library(coda) to check convergence and write a function
to simulate a single observation from each set of simulated parameters
and compute quantile(..., c(.025, .975)) for each prediction level
desired.

      However, before I coded that, I thought I would ask if some easier
method might be available.

      Thanks,
      Spencer
p.s.  RSiteSearch("lme prediction intervals") produced 3 hits including
2 from James A Rogers over 3 years ago.  In one, he said, "I am not
aware of any published R function that gives you prediction intervals or
tolerance intervals for lme models."
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/42781.html)   In the
other, he provided sample code for prediction or tolerance intervals of
lme variance components.
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/44675.html)




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