Make a 'between-and-within-factors' ANOVA with lmer function
I reckon lmer can figure out for itself what is between and what is within subjects, so lmer(DV ~ IV1*IV2*IV3*IV4 + (1|Subject)) should fit the same model as your ANOVA.
On 24 Mar 2013, at 08:56, Vanni Rovera <vanni.rovera at gmail.com> wrote:
Hi there, I'm trying to understand how to use the function lmer in order to do a 'between-and-within-factors' ANOVA, but without any success. I know about the usage of the function aov, but this holds only for balanced designs; its documentation say to use lme function (package nlme) for unbalanced designs. Furthermore I found the lmer function (package lme4) is an evolution of lme, so I wish to use this last function in order to perform my ANOVA. But I'm not able to understand how to do this. More precisely, imagine you have a dependent variable DV and four independent variables IV1, IV2, IV3, IV4, where IV1, IV2 are between-factors and IV3, IV4 are within-factors. Moreover you have a variable called Subject in order to identify the subject on which measurements are done (like for example this dataset: http://personality-project.org/r/datasets/R.appendix5.data). If I use the aov function, my 'between-and-within-factors' ANOVA would stand as follows: aov(DV~(IV1*IV2*IV3*IV4)+Error(Subject/(IV3*IV4))). Now can you write me the precise syntax in order to obtain the same result with the lmer function? Thanks a lot in advance! Vanni Rovera *Additional details:* The problem is that no one seems to be interested in explain the relations of 'within-factor' and 'between-factor' concepts with those of 'fixed-effect' and 'random-effect'. Textbooks and papers about ANOVA talk about between and within factors, while documentations and papers about lmer function talk about mixed-effects models, i.e. they talk about fixed and random effects, without mentioning between and within factors. *Thus I am not able to understand the relations between the two, since I think they are completely uncorrelated each others, and hence I am not able to use the syntax in lmer in order to distinguish between factors from within factors.* [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.