Søren Højsgaard
2005-Apr-27 23:25 UTC
[R] How to specify the hierarchical structure of a split plot using lmer ??
I have a problem getting the lmer function of the lme4 package to use the appropriate degrees of freedom for testing. Consider the Semiconductor data from the SASmixed package: library(SASmixed) Semi.lme <- lme(resistance ~ ET * position, random=~1|Grp, data=Semiconductor) anova(Semi.lme) numDF denDF F-value p-value (Intercept) 1 24 3237.261 <.0001 ET 3 8 1.942 0.2015 position 3 24 3.385 0.0345 ET:position 9 24 0.809 0.6125 Here, the ET effect is (correctly) tested on 8 denominator degrees of freedom. In the example in the SASmixed package, the following code is presented: (fm1Semi <- lmer(resistance ~ ET * position + (1|Grp), Semiconductor)) anova(fm1Semi) Analysis of Variance Table Df Sum Sq Mean Sq Denom F value Pr(>F) ET 3 0.647 0.216 32.000 1.9415 0.14273 position 3 1.129 0.376 32.000 3.3855 0.02991 * ET:position 9 0.809 0.090 32.000 0.8092 0.61127 So here, all effects are tested with 32 denominator degrees of freedom. I have looked at the help page for lmer but have been unable to figure out how to specify the hierarchical structure of a split plot experiment. Also, I have Googled but without any luck. Any help will be appreciated. S??ren
Douglas Bates
2005-Apr-28 02:21 UTC
[R] How to specify the hierarchical structure of a split plot using lmer ??
S??ren H??jsgaard wrote:> I have a problem getting the lmer function of the lme4 package to use the > appropriate degrees of freedom for testing. Consider the Semiconductor data > from the SASmixed package: > > library(SASmixed) > Semi.lme <- lme(resistance ~ ET * position, random=~1|Grp, data=Semiconductor) > anova(Semi.lme) > numDF denDF F-value p-value > (Intercept) 1 24 3237.261 <.0001 > ET 3 8 1.942 0.2015 > position 3 24 3.385 0.0345 > ET:position 9 24 0.809 0.6125 > > Here, the ET effect is (correctly) tested on 8 denominator degrees of freedom. > In the example in the SASmixed package, the following code is presented: > > (fm1Semi <- lmer(resistance ~ ET * position + (1|Grp), Semiconductor)) > anova(fm1Semi) > Analysis of Variance Table > Df Sum Sq Mean Sq Denom F value Pr(>F) > ET 3 0.647 0.216 32.000 1.9415 0.14273 > position 3 1.129 0.376 32.000 3.3855 0.02991 * > ET:position 9 0.809 0.090 32.000 0.8092 0.61127 > > So here, all effects are tested with 32 denominator degrees of freedom. > I have looked at the help page for lmer but have been unable to figure out > how to specify the hierarchical structure of a split plot experiment. Also, > I have Googled but without any luck. Any help will be appreciated. > S??renUnfortunately the answer is quite simple. The current version of the lme4 package does not attempt to get the degrees of freedom "right" - it just gives an upper bound. The reason is more than simple laziness on my part. The lmer function can fit models with non-nested grouping factors and it is not easy to define sensible values for the degrees of freedom in such cases. Hence I have put that problem aside while dealing with other issues. (Also - as long time readers of this list may know - the topic of denominator degrees of freedom is one of my least favorite topics.)