Skip to content
Prev 79633 / 398502 Next

lme and lmer syntax

There is an issue with implicit nesting in lmer. In your lme() model you nest block/irrigation/density/fertilizer. In lmer you need to do something like (I dind't include all of your variables, but I think the makes the point)

lmer(yield~irrigation*density*fertilizer+(1|fertilizer:density)+(1|density), data)

Which notes that fertilizer is nested in density. 

Try this and then compare the results. 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Ronaldo Reis-Jr.
Sent: Tuesday, October 25, 2005 12:21 PM
To: R-Help
Subject: Re: [R] lme and lmer syntax

Em Seg 24 Out 2005 18:08, Doran, Harold escreveu:
Hi,

I try this with a splitsplitplot example.

I make the correct model with aov, lme do compare with lmer.

But I cant make a correct model in lmer. Look that the aov and lme results are similars, but very different from lmer. In aov and lme is used the correct DF for each variable, in lmer it use a same DF for all? Denom=54.

What is my mistake?

Thanks
Ronaldo

----- Begin of example ------
yield        block      irrigation   density   fertilizer
 Min.   : 60.00   A:18   control  :36   high  :24   N :24     
 1st Qu.: 86.00   B:18   irrigated:36   low   :24   NP:24     
 Median : 95.00   C:18                  medium:24   P :24     
 Mean   : 99.72   D:18                                        
 3rd Qu.:114.00                                               
 Max.   :136.00
aov(yield~irrigation*density*fertilizer+Error(block/irrigation/density/fertilizer))
Error: block
          Df  Sum Sq Mean Sq F value Pr(>F)
Residuals  3 194.444  64.815               

Error: block:irrigation
           Df Sum Sq Mean Sq F value  Pr(>F) irrigation  1 8277.6  8277.6  17.590 0.02473 *
Residuals   3 1411.8   470.6                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: block:irrigation:density
                   Df  Sum Sq Mean Sq F value  Pr(>F)  
density             2 1758.36  879.18  3.7842 0.05318 .
irrigation:density  2 2747.03 1373.51  5.9119 0.01633 *
Residuals          12 2787.94  232.33                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: block:irrigation:density:fertilizer
                              Df  Sum Sq Mean Sq F value    Pr(>F)    
fertilizer                     2 1977.44  988.72 11.4493 0.0001418 ***
irrigation:fertilizer          2  953.44  476.72  5.5204 0.0081078 ** 
density:fertilizer             4  304.89   76.22  0.8826 0.4840526    
irrigation:density:fertilizer  4  234.72   58.68  0.6795 0.6106672    
Residuals                     36 3108.83   86.36                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
block/irrigation/density/fertilizer)
numDF denDF   F-value p-value
(Intercept)                       1    36 2683.2245  <.0001
irrigation                        1     3   31.0269  0.0114
density                           2    12    3.7780  0.0534
fertilizer                        2    36   11.4490  0.0001
irrigation:density                2    12    5.9023  0.0164
irrigation:fertilizer             2    36    5.5203  0.0081
density:fertilizer                4    36    0.8826  0.4841
irrigation:density:fertilizer     4    36    0.6795  0.6107
Loading required package: Matrix
Loading required package: lattice
Analysis of Variance Table
                              Df Sum Sq Mean Sq  Denom F value    Pr(>F)    
irrigation                     1 827.41  827.41  54.00 30.9203 8.546e-07 ***
density                        2 202.53  101.26  54.00  3.7842  0.028971 *  
fertilizer                     2 612.76  306.38  54.00 11.4493 7.159e-05 ***
irrigation:density             2 316.40  158.20  54.00  5.9120  0.004767 ** 
irrigation:fertilizer          2 295.45  147.72  54.00  5.5204  0.006586 ** 
density:fertilizer             4  94.48   23.62  54.00  0.8826  0.480561    
irrigation:density:fertilizer  4  72.73   18.18  54.00  0.6795  0.609157    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

----- End of example ------