Re: [R] Standard errors of the predicted values from a lme (or lmer)

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Mon, 04 Jun 2007 09:09:01 -0400

Dieter Menne wrote:
> Fränzi Korner <fraenzi.korner <at> oikostat.ch> writes:
>

>> sorry for not being more specific. I would like to use R to get a prediction
>> (with standard error) of the response in a mixed model at selected values of
>> the fixed-effects factors. Hence, in a mixed model, say, for response body
>> size with, say, fixed factors sex and age, I would like to get a prediction
>> of size for each sex and at selected ages such as 5, 10, 15; and I want a SE
>> for that prediction as well. 

> ....
>
> In that case, estimable in gmodels (by Greg Warnes, as also suggested by Michael
> Kubovy) and glht in Thorsten Hothorn's multcomp are best. The first works for
> lme out of the box, the very powerful glht can handle lmer(lme4), with strong
> support for multiple testing. Too bad the latter does not immediately work with
> lme, but it can be tweaked.
>
> In both cases, you have to construct the contrast matrix, which can be
> error-prone for complex models. To my knowledge (??), there is no
> simple-to-handle package that generates this matrix with an intuitive interface.
>
> Dieter

  See contrast() in the contrast package.

library(nlme)
Orthodont2 <- Orthodont
Orthodont2$newAge <- Orthodont$age - 11

fm1Orth.lme2 <- lme(distance ~ Sex*newAge, data = Orthodont2, random = ~ newAge | Subject)

contrast(

    fm1Orth.lme2,
    a = list(Sex = levels(Orthodont2$Sex)[1], newAge = 8 - 11))

lme model parameter contrast

 Contrast      S.E.    Lower    Upper     t  df Pr(>|t|)
 22.61563 0.5265041 21.58370 23.64755 42.95 100        0


> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 04 Jun 2007 - 13:16:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Jun 2007 - 14:31:50 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.