I tried finding an answer to this question on this and other sites but to no avail - if I am missing something please excuse my inability to locate the answer!

Basically I have several dependent variables (dv) for two land management treatments (treat) measured quarterly (season). I know that I need to run a RM-ANOVA with season as a random effect, and so I am using the lme test in R. What I cant work out is whether I should be including season as a random variable like so:

lme <- lme(dv ~ treat, random = ~1|season, data=data)

or whether I should be nesting season within treatment like so:

lme <- lme(dv ~ treat, random = ~1|treat/season, data=data)

Many thanks for your assistance!


2 Answers 2


Major update, based on your comment.

The code should be something like when using lme from nlme:

lme.model <- lme(dv ~ season * treat, random = ~1|rep, data=data)

where rep is a factor assigning unique codes to each of your 10 independent study sites (i.e., 5 per treatment), season is a factor indicating measurment quarter, and treatment is the treatment factor.

However, this will not give you a real ANOVA but a mixed model with one random effect (rep) and two fixed effects (season and between).

To fit a real ANOVA (namely one with one between- and one within-subjects factor, a so called split-plot design) you could use package afex:

anova <- ez.glm("rep", "dv", data = data, within = "season", between = "treat")

You could run this on each dv separately.

To analyze all dvs together you would need some multivariate analysis of which I am no expert.

Response prior to your comment:

If treat is your unit of observation (of which having two seems to be quite low), then the following code would be correct:

lme <- lme(dv ~ season, random = ~1|treat, data=data)

However, as said, having a repeated measures ANOVA with only two units of observation is pretty uncommon and seems a bad idea. If this is really your design (observed two treatments over several seasons), you are probably better off with other analyses, such as single-case analysis, e.g., here.

  • $\begingroup$ Thanks Henrik, yes we have two treatments as I am comparing the effects of wildfire versus no wildfire on soils, and collected repeat samples over time. Why are you suggesting that season should be the fixed variable? Perhaps I should have been clearer that I am only really interested in comparing between the treatments (ie. fire vs. no fire) $\endgroup$
    – Levi
    Mar 13, 2013 at 16:33
  • $\begingroup$ What exactly did you measure within each treatment? And at what times? $\endgroup$
    – Henrik
    Mar 13, 2013 at 16:53
  • $\begingroup$ I measured numerous dependent variables such as pH, EC, temperature, nutrient concentrations....the data were collected once per quarter (i.e. approx. every three months, but not exactly the same length of time between measurements). And there are 5 reps (independent study sites) for fire and no fire. $\endgroup$
    – Levi
    Mar 13, 2013 at 17:23
  • $\begingroup$ great - thanks for your assistance. I'll give the ez.glm a try as that sounds like what I need. $\endgroup$
    – Levi
    Mar 13, 2013 at 19:43
  • $\begingroup$ you can alo upvote my answer if you think it is useful (small normal distribution above the 0). $\endgroup$
    – Henrik
    Mar 13, 2013 at 19:45

I think you should use this R command

lme <- lme( fixed = dv ~ treat + season , random = ~1 | id   , data=data)

where id is the identification of your records


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.