## Using Repeated Measures ANOVA

We have just finished an experiment, where we had samples distributed into 6 groups and each group receiving a different treatment. Each group had 5 samples, with 20 replicate measurements taken per sample (they do not represent timepont difference, but mainly replicates). The data looks something like this

I am stacking the data and making R chew on it, so that the final input looks something like this...

Now, We want to see if there is difference in TotalActivity (the values in the trial variable in the first table) Between the groups represented in FinalID (6 groups).

I factor the relevant fields after importing the CSV and perform the repeated measures ANOVA in R like so

Code:
`````` Data <- within(Data, {
FinalID <- factor(FinalID)
AnimalID <- factor(AnimalID)
Trial <- factor(Trial)
})

aov.out = aov(TotalActivity~FinalID*Trial + Error(AnimalID), data=Data)
PostHoc <- with(Data,pairwise.t.test(TotalActivity,FinalID,p.adjust.method="bonferroni"))
print(summary(aov.out))
print(PostHoc)``````

Okay, now the confession is that statistics is not my forte, and am a bit confused how to set up my repeated measures. I googled it and found a couple of formulas like so

Code:
``````    aov.out = aov(TotalActivity~FinalID*Trial + Error(AnimalID), data=Data)

aov.out = aov(TotalActivity~FinalID + Error(AnimalID/FinalID), data=Data)``````
I have no idea what's the right formula to use, or even if any f the above are right statistical technique... suggestions please?

KR
TBA