[R] how specify lme() with multiple within-subject factors?
Ben Meijering
B.Meijering at student.rug.nl
Sat Jan 3 19:59:04 CET 2009
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
More information about the R-help
mailing list