[R] post hoc test after lme

Chuck Cleland ccleland at optonline.net
Fri Aug 14 16:30:18 CEST 2009


On 8/14/2009 10:06 AM, Casimir wrote:
> Hi!
> 
> I am quiet new with R and I have some problems to perform a posthoc test
> with an lme model.
> My model is the following:
> 
>> lme1<-lme(eexp~meal+time, random=~1|id,na.action=na.omit)
> 
> and then i try to get a post hoc test:
> 
>> summary(glht(lme1,linfct=mcp(meal="Tukey)))
> 
> but I get a warning message: Erreur dans as.vector(x, mode) : argument
> 'mode' incorrect
> 
> Thank you for your help
> 
> Guillaume

  Use the data argument in the call to lme().  For example, this works:

library(multcomp)

library(nlme)

Orthodont$AGECAT <- as.factor(Orthodont$age)

fm1 <- lme(distance ~ AGECAT + Sex, data = Orthodont, random = ~ 1 |
Subject)

summary(glht(fm1, linfct=mcp(AGECAT = "Tukey")))

         Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts

Fit: lme.formula(fixed = distance ~ AGECAT + Sex, data = Orthodont,
    random = ~1 | Subject)

Linear Hypotheses:
             Estimate Std. Error z value Pr(>|z|)
10 - 8 == 0    0.9815     0.3924   2.501  0.05984 .
12 - 8 == 0    2.4630     0.3924   6.277  < 0.001 ***
14 - 8 == 0    3.9074     0.3924   9.958  < 0.001 ***
12 - 10 == 0   1.4815     0.3924   3.776  < 0.001 ***
14 - 10 == 0   2.9259     0.3924   7.457  < 0.001 ***
14 - 12 == 0   1.4444     0.3924   3.681  0.00123 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)

  But this does not work and returns the error you got:

attach(Orthodont)

fm2 <- lme(distance ~ AGECAT + Sex, random = ~ 1 | Subject)

summary(glht(fm2, linfct=mcp(AGECAT = "Tukey")))

Error in as.vector(x, mode) : invalid 'mode' argument

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
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




More information about the R-help mailing list