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

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Jan 5 00:19:16 CET 2009


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.




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