# Step-by-step mixed model analysis in R using lme, ezANOVA, or aov

My data consist of 4 treatments (fixed), 8 locations (2 locations per treatment), 3 positions (per location, fixed), 3 samples (per location, random), with dependent variable Nmin observed at 2 sample times.

I want to do a nested repeated-measures ANOVA in R. I believe this falls under the name 'mixed effects model' (?)

As nested and repeated-measures have different assumptions I was wondering how to handle this?

Also, should I first carry out a normal nested ANOVA and normal repeated-measures, and then the mixed model effects? Does this give more information or is it a waste of time?

I want to use the mean of the 3 samples but I don't want to loose information; might a range be the handiest? I am unsure of how to code this into the R formula (either mean or range).

These are my formulae (I have not run them yet as I am a bit confused about the assumptions and don't think the formulae are correct yet):

lme(data=data, fixed=Nmin~sample/position*time, random=~1|(sample/position/location))

ezANOVA(data=data, dv=Nmin, wid=sample, within=time, between=location)

aov(Nmin~treatment*position*location*time + error(sample/position/location), data=data)


I want to see if (1) position, (2) location, (3) treatment, (4) time and (5) every combination of (1) - (4), have an affect on Nmin ie. p, l, tr, ti, p*tr, p*ti, tr*ti, p*tr*ti. I am unsure how to handle l as p is nested in l, but I am interested in the affect of location on Nmin also.

Could anyone explain to me how to handle the assumptions? How can I add 'means of sample' to my R formulae? How should I formulate my R formulae taking into account my numerous research questions?

-
 I'm not quite sure what 'means of sample' are, but that sounds like a job for the ave function. – conjugateprior Dec 25 '12 at 23:24