[R] Problems with glht function for lme object

Ben Bolker bbolker at gmail.com
Fri Jan 7 17:16:17 CET 2011


anord <andreas.nord <at> zooekol.lu.se> writes:

> 
> 
> Dear all, 
> 
> I'm trying to make multiple comparisons for an lme-object. The data is for
> an experiment on parental work load in birds, in which adults at different
> sites were induced to work at one of three levels ('treat'; H, M, L). The
> response is 'feedings', which is a quantitative measure of nest provisioning
> per parent per chick per hour. Site is included as a random effect (one
> male/female pair per site). 
> 

  (For more complicated mixed model questions you might want
to try the r-sig-mixed-models list instead.)

It works for me:

feed.df <- read.table(textConnection("
feedings     sex site  treat year  date
1.8877888   M  838     H 2009      81
1.9102787   M  247     H 2009      81
1.4647229   M  674     H 2010      121
1.4160590   M 7009     M 2009      144
1.3106749   M  863     M 2010      196
1.2718121   M   61     M 2009      225
1.2799263   M  729     L 2009      256
1.5829564   M  629     L 2009      256
1.4847251   M  299     L 2010      324
1.2463151   M  569     L 2010      324
2.1694169   F  838     H 2009      81
1.5966899   F  247     H 2009      81
2.4136983   F  674     H 2010      121
1.7784873   F 7009     M 2009      144
1.6681317   F  863     M 2010      196
2.3691275   F   61     M 2009      225
2.0672192   F  729     L 2009      256
1.6389902   F  629     L 2009      256
0.9307536   F  299     L 2010      324
1.6786767   F  569     L 2010      324"),
           header=TRUE)

library(nlme)
m4.feed <- lme(feedings ~ treat + year + date, random = ~1|site,data=feed.df)

library(multcomp)
gg <- glht(m4.feed,linfct=mcp(treat="Tukey"))
plot(gg)
summary(gg)

It works for me (although it doesn't look like there's anything
going on there ...)

=========

	 Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: lme.formula(fixed = feedings ~ treat + year + date, data = feed.df, 
    random = ~1 | site)

Linear Hypotheses:
           Estimate Std. Error z value Pr(>|z|)
L - H == 0  -0.6452     0.7667  -0.842    0.592
M - H == 0  -0.3996     0.4276  -0.934    0.529
M - L == 0   0.2456     0.4229   0.581    0.771
(Adjusted p values reported -- single-step method)

> 


sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=C              LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] multcomp_1.2-4  survival_2.36-3 mvtnorm_0.9-95  nlme_3.1-97    

loaded via a namespace (and not attached):
[1] grid_2.12.1     lattice_0.19-18
>



More information about the R-help mailing list