Skip to content
Prev 8657 / 20628 Next

Specifying 'correct' degrees of freedom for within-subject factor in *nlme/lme* repeated measures ANOVA?

On Jul 28, 2012, at 00:16 , Ben Bolker wrote:

            
Haven't played with lme for a while, but models with crossed random effects is a pretty sure way to get df wrong. E.g., this one which I dug out from some 2006 slides:
Error: Block
          Df   Sum Sq  Mean Sq F value Pr(>F)
Residuals  1 0.008311 0.008311               

Error: Block:sample
          Df  Sum Sq Mean Sq F value  Pr(>F)   
sample     5 0.27615 0.05523   11.21 0.00952 **
Residuals  5 0.02463 0.00493                   
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 

Error: Block:dilut
          Df Sum Sq Mean Sq F value   Pr(>F)    
dilut      4  3.749  0.9373   420.8 1.68e-05 ***
Residuals  4  0.009  0.0022                     
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 

Error: Block:sample:dilut
             Df  Sum Sq  Mean Sq F value Pr(>F)
sample:dilut 20 0.05552 0.002776   1.607  0.149
Residuals    20 0.03455 0.001728               

This is not "officially" supported by lme, but you can cheat it to fit the model:
+            random=list(Block=~1,
+                      Block=pdIdent(~sample-1),
+                      dilut=~1))
numDF denDF  F-value p-value
(Intercept)      1    25 538.0174  <.0001
sample           5    25  11.2133  <.0001
dilut            4     4 420.7911  <.0001
sample:dilut    20    25   1.6069  0.1301

but as you see, the F-values are right but the denDF are not.