repeated measure anova using regression models (LM

2019-04-08 08:03发布

问题:

I would like to run repeated measure anova in R using regression models instead an 'Analysis of Variance' (AOV) function.

Here is an example of my AOV code for 3 within-subject factors:

m.aov<-aov(measure~(task*region*actiontype) + Error(subject/(task*region*actiontype)),data)  

Can someone give me the exact syntax to run the same analysis using regression models? I want to make sure to respect the independence of residuals, i.e. use specific error terms as with AOV.

In a previous post I read an answer of the type:

lmer(DV ~ 1 + IV1*IV2*IV3 + (IV1*IV2*IV3|Subject), dataset))

I am really not sure about this solution since it still treats variables as between subjects, and I don't understand how adding random factors would change this.

Does someone know how to run repeated measure anova with lm/lmer taking into account residual independence?

Many thanks, Solene

回答1:

If your aov example is right (maybe you don't want to nest things) you want this:

lmer(measure~(task*region*actiontype) + 1(1|subject/(task:region:actiontype))

If residual independence means intercept and slope independently calculated you need to specify them separately:

+(1|yourfactors)+(0+variable|yourfactors)

or use the symbol:

+(1||yourfactors)

Anyway if you read the help files you can find that lme4 can't deal with the most general problems.



标签: r regression