[R-sig-ME] [R] how specify lme() with multiple within-subject factors?

Ben Meijering B.Meijering at student.rug.nl
Mon Jan 5 15:31:44 CET 2009


Thierry,

Thanks for your reply!
I've specified the random part as you suggested, but with lmer()  
instead of lme(). For a thorough walk-through of lmer(), I've read  
Baayen, Davidson and Bates' (2007) article.
However, I still have a question about the degrees of freedom.

My model:

lmer(acc ~ wtype * present + (wtype + present | subj), data=...)

Then, with aovlmer.fnc() I obtained the p-values of the factors. I  
don't understand why Df2 differs from the residual degrees of freedom  
of oav()[, which is aov(acc ~ wtype * present + Error(subj/ 
wtype*present), data=...)]

In lmer() all terms (wtype, present and wtype:present) have the same  
df2, i.e., levels wtype * levels present * (levels subject - 1).
In repeated-measures aov each within-subject term has it's own  
denominator degrees of freedom, i.e., for wtype it's (levels wtype  
-1), for present it's (levels present -1) and for wtype:present it's  
(levels wtype - 1)*(levels present - 1).

Why are the residual degrees of freedom different between aov and  
lmer()?

Best,

Ben Meijering



Op 5 jan 2009, om 00:19 heeft ONKELINX, Thierry het volgende geschreven:

> Dear Ben,
>
> I'm cc'ing R-sig-mixed-models because that's a more appropriate list  
> for
> questions on lme().
>
> Lme() is only able to work with nested random effects, not with  
> crossed
> random effects. Therefore you would need lmer() from the lme4 package.
> But I don't think you need crossed random effects. Random slopes  
> should
> do the trick since wtype and present have only two levels. Try  
> something
> like lme(.., .., random = ~wtype * present | subj)
>
> HTH,
>
> Thierry
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no  
> more
> than asking him to perform a post-mortem examination: he may be able  
> to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does  
> not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r- 
> project.org]
> Namens Ben Meijering
> Verzonden: zaterdag 3 januari 2009 19:59
> Aan: r-help at r-project.org
> Onderwerp: [R] how specify lme() with multiple within-subject factors?
>
> I have some questions about the use of lme().
> Below, I constructed a minimal dataset to explain what difficulties I
> experience:
>
> # two participants
> subj <- factor(c(1, 1, 1, 1, 2, 2, 2, 2))
> # within-subjects factor Word Type
> wtype <- factor(c("nw", "w", "nw", "w", "nw", "w", "nw", "w"))
> # within-subjects factor Target Present/Absent
> present <- factor(c(0, 0, 1, 1, 0, 0, 1, 1))
> # dependend variable Accuracy
> acc <- c(.74, .81, .84, .88, .75, .95, .88, .94)
>
> # repeated-measures analysis of variance
> acc.aov <- aov(acc ~ wtype * present + Error(subj/wtype*present))
> summary(acc.aov)
>
> # to use lme
> library(nlme)
> # mixed-effects model
> acc.lme <- lme(acc ~ wtype * present, random = ~ 1 | subj)
> anova(acc.lme)
>
> How do I have to specify the model to have 1 degree of freedom for the
> denominator or error-term, as in aov()?
> I know how to do this for the first factor:
>
> lme(.., .., random = ~1 | subj/wtype),
>
> or
>
> lme(.., .., random = list( ~ 1 | subj, ~1 | wtype))
>
> , but not how to get the same degrees of freedom as in the specified
> aov(), i.e., 1 degree of freedom of the denominator for both factors
> and the interaction term.
>
> How do I specify such a model?
>
> ~ Ben
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de  
> schrijver weer
> en binden het INBO onder geen enkel beding, zolang dit bericht niet  
> bevestigd is
> door een geldig ondertekend document. The views expressed in  this  
> message
> and any annex are purely those of the writer and may not be regarded  
> as stating
> an official position of INBO, as long as the message is not  
> confirmed by a duly
> signed document.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-sig-mixed-models mailing list