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:
I won't say that lme *always* gets the df 'right', but I don't think I've ever seen a case where there was an unambiguous right answer (i.e. the situation matched a classical experimental design so that the problem could also be expressed as a standard method-of-moments ANOVA with a well defined denominator df) *and* lme got it wrong.
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:
library(nlme) summary(aov(logDens~sample*dilut+Error(Block/(sample*dilut)), data=Assay))
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:
as3 <- lme(logDens~sample*dilut, data=Assay,
+ random=list(Block=~1, + Block=pdIdent(~sample-1), + dilut=~1))
anova(as3)
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.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com