[R-SIG-Mac] Make a 'between-and-within-factors' ANOVA with lmer function

David Winsemius dwinsemius at comcast.net
Sat Mar 23 19:55:46 CET 2013

On Mar 23, 2013, at 4:06 AM, Vanni Rovera wrote:

> Hi there
> I don't know if this is the right place to do such a question, but
> nonetheless I try.

It is very much not the correct place to post this. There is no Mac-spcific content and there is a mixed-models mailing list wher ethis would be completely appropriate. You should do the necessary subscription and reading of their FAQ before re-posting.




> 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 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, and forgive me in the case
> this topic is inappropriate with this mailing list.
> *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
> 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.
> 	[[alternative HTML version deleted]]
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

David Winsemius
Alameda, CA, USA

More information about the R-SIG-Mac mailing list