# Is repeated measures ANOVA a correct method for my data?

My experiment is a completely randomized block design. The objective is to find whether a variable is different between species $a$, $b$, $c$. The measurement was taken 2 times (June, July) in each year (2011, 2012). I was wondering whether repeated measures ANOVA is a correct method to use? If it is, would you please help me to write up the syntax for the ANOVA and post-hoc analysis?

My data are like the following:

dat <- read.table(text = "species block   year    time    variable
a   1   2011    June    1
a   2   2011    June    2
a   3   2011    June    3
b   1   2011    June    4
b   2   2011    June    5
b   3   2011    June    6
c   1   2011    June    7
c   2   2011    June    8
c   3   2011    June    9
a   1   2011    July    10
a   2   2011    July    11
a   3   2011    July    12
b   1   2011    July    13
b   2   2011    July    14
b   3   2011    July    15
c   1   2011    July    16
c   2   2011    July    17
c   3   2011    July    18
a   1   2012    June    19
a   2   2012    June    20
a   3   2012    June    21
b   1   2012    June    22
b   2   2012    June    23
b   3   2012    June    24
c   1   2012    June    25
c   2   2012    June    26
c   3   2012    June    27
a   1   2012    July    28
a   2   2012    July    29
a   3   2012    July    30
b   1   2012    July    31
b   2   2012    July    32
b   3   2012    July    33
c   1   2012    July    34
c   2   2012    July    35
c   3   2012    July    36", header=TRUE)

-
When you say "variable is different" among species, what exactly do you mean? Different at one time? Different at any time? Different on average? Has a different growth rate? Has a different starting point? Or what? –  Peter Flom Oct 21 '12 at 23:39

The short answer is yes, it is a repeated measures. There are many ways to do it in R. See this post for a list of some of the possibilities. I would use package nlme, assuming your data are normally distributed.

dat$block <- factor(dat$block)
dat$time = factor(paste(dat$time,dat$year,sep=".")) dat$variable = rnorm(36)
library(nlme)
summary(lme(variable~species,data=dat,random=~1|block/time))


I combined year and time into a single "time" factor. If you don't do this you only have 2 levels of year and two of time, and things get a little whacky - hard to get variance estimates with only 2 replicates.

-
That is very helpful. What if I want to treat "year" as a fixed variable, only "time" and "block" as random variables? Can I use summary(lme(variable~species*year,data=dat,random=~1|block/time))? –  didi Aug 23 '12 at 14:28
I also have trouble interpreting the results, especially the fixed effect of "speciesb" and "speciesc". I guess what I wanted to know is whether species a, b, c are different in terms of variable. –  didi Aug 23 '12 at 16:42
@didi yes, that should work. The coefficients for the fixed effect of species represent the difference between species a and b, and species a and c (treatment contrasts). If you want the expected value of each species you can use the predict function. If you want post-hoc tests see this link –  atiretoo Aug 23 '12 at 22:09