[R] Mixed Effects Model with Different Group Sizes
Carsten Giessing
Carsten.Giessing at gmx.de
Tue Jan 27 16:19:55 CET 2009
Hi R user,
I can not find the answer for a simple problem. I want to test the main effects and interactions of a 2 by 2 factorial design (Experiment I) and 2 by 2 by 2 factorial design (Experiment II) with unequal group sizes and one or two within-subject factors.
2 by 2 Design (Experiment I):
Factor A is a fixed grouping factor with different group sizes for group A1 and A2 (reflecting the different appearance of the factor levels within the population).
Factor B is a fixed “within-subject” factor and has two levels: The means of conditions B1 and B2 for each subject. Thereby condition B1 has been measured more frequently than condition B2.
Each subject in group A1 and A2 was measured under the conditions B1 and B2.
Experiment II has an additional “within-subject” factor C. Thereby B1 and B2 were measured under conditions C1 and C2.
>From my current readings I suggest for Experiment I:
library(lme4)
model1 <- lmer (beta ~ B - 1+(1| subject), data=data.ex,REML=FALSE)
model2 <- lmer (beta ~ A - 1 +(1| subject), data=data.ex,REML=FALSE)
model3 <- lmer (beta ~ A + B - 1 +(1| subject),data=data.ex,REML=FALSE)
model4 <- lmer (beta ~ A * B - 1 +(1| subject), data=data.ex,REML=FALSE)
anova(model1,model3) #Main effect factor A
anova(model2,model3) #Main effect factor B
anova(model3,model4) #Interaction factor A x B
Is this correct (error strata for unequal group sizes)? Do you suggest different solutions? Does the solution for experiment II follow the same principle of error strata?
Many thanks,
Carsten
More information about the R-help
mailing list