1
$\begingroup$

This question already has an answer here:

I have a question concerning a mixed model ANOVA conducted using the lmer function of the lme4 package. Despite a lengthy research across tutorials and forum entries I do not have a clear response to how exactly my lmer formula should be written.

Experimental design

32 participants take place in the study, half of which constitute the test group, the other half the control group. Both groups do a pre and a posttest, and in both testing sessions they see 18 items of 3 conditions (= 54 items per testing session), and the stimuli of each condition are not repeated in the pre and the posttest.

My question is now if the following formula is correct/complete and if the fact that we deal here with repeated measures is automatically calculated: (dv: dependent variable)

Formula

fit1 <- lmer(dv ~ (condition * session * group) + (1|item_ID) + (1|subj_ID) + group, 
             myData, REML=FALSE)

Or is one of the following more accurate:

fit2 <- lmer(dv ~ (condition * session * group) + (1|item_ID) + (1+session|subj_ID) + group, 
             myData, REML=FALSE)

fit3 <- lmer(dv ~ (condition * session * group) + (1|item_ID) + 
             (1+session+condition|subj_ID) + group, myData, REML=FALSE)

I have also conducted the ANOVA comparing the three models (anova(fit1,fit2,fit3)) but given that these three models are not equally complex this comparison is actually not valid, is this assumption right?

Moreover, I have included the pbkrtest package to obtain degrees of freedom and p values; are the obtained dfs usable for reporting the inferential statistics or do I need to apply an additional transformation?

$\endgroup$

marked as duplicate by Tim, Xi'an, kjetil b halvorsen, Christoph Hanck, gung - Reinstate Monica r Feb 15 '16 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Feb 15 '16 at 7:50

This question came from our site for professional and enthusiast programmers.

  • 1
    $\begingroup$ Well if I'm not mistaken it's less a question of proper implementation and more a question of which effects do you want to estimate. Models 2 and 3 include random slopes for subj_ID in addition to a random intercept. Do you want there to be a random slope corresponding to the effect of session for each subject (models 2 & 3) and a random slope corresponding to the effect of condition for each subject (model 3)? Should the effect of session and condition be different for different subjects? That's a theoretical question as far as I see it, not a question of implementation. $\endgroup$ – psychometriko Feb 8 '16 at 13:24
  • 4
    $\begingroup$ Possible duplicate of R's lmer cheat-sheet or stats.stackexchange.com/questions/70556/… or stats.stackexchange.com/questions/18428/… $\endgroup$ – Tim Feb 15 '16 at 8:24