2

I have a measurement for two groups of subjects where each subject contains 3 replicates. For example, the data is like below:

Group Subject Replicate Value
1 A 1 0.2
1 A 2 0.3
1 A 3 0.25
1 B 1 0.4
1 B 2 0.3
1 B 3 0.7
2 C 1 0.2
2 C 2 0.1
2 C 3 0.3
2 D 1 0.4
2 D 2 0.2
2 D 3 0.25

I am thinking of using ANOVA where the subject is the error term,e.g. aov(Value~Group+Error(Subject)) in R. Is it correct?

Thanks! Gim

Gim
  • 21
  • 1
  • 2

2 Answers2

1

To me it looks essentially correct. You still have to specify the data.frame the values are taken from in aov like

aov(Value~Group+Error(Subject), data)

This model assumes that subject were taken at random (within their group). It is justified to drop the variable "replicate" from the formula as it bears no information.

gui11aume
  • 13,383
  • 2
  • 44
  • 89
  • 1
    Thanks for the reply. I recently came across a post using somehow a different formula for this case, e.g. a nested one way anova model as aov(Value~Group/Subject,data). The results are different. Which one is more correct? – Gim Jun 02 '12 at 19:41
  • Nope, I think the latter one is not what you want. The slash notation is short for aov(Value~Group+Group:Subject,data), which is a fixed effect model. Be careful of the confusion with the lme function from the nlme package, which uses the vertical bar | to specify error. – gui11aume Jun 02 '12 at 23:26
0

In case you would like to add the within group variance of subjects to (what has been already suggested),

aov(Value~Group+Error(Subject), data)

you could introduce the Group in the error term (adapted from this answer):

aov(Value~Group+Error(Subject/Group), data)

which is essentially:

aov(Value~Group+Error(Subject+Subject:Group), data)

emre
  • 111
  • 2