[R] Repeated measures ANOVA
GIDEON WASSERBERG
wasserberg at wisc.edu
Thu May 20 07:11:46 CEST 2004
Dear friends
I am not sure that I am conducting this analysis correctly. I would really appreciate if someone can verify what I've done.
I conducted repeated measures ANOVA for some bugs data. These bugs were measured repeatedly over 32 weeks at the same trapping plots. I want to test a full model for the effect of time ("week") (the "within subject" variable), and the main effects are: place, station,species, and all the interactions thereof.
Below, I pasted the commands I used, the analysis output, and a segment of my data (2 out of the 32 weeks) in order to show how I coded the data.
> Rep1<-read.csv("C:/Documents and Settings/Gideon/My Documents/Vasily-Alon paper/Seasonal2.csv")
> summary(aov(Total~Place*Station*Species*Week+Error(Subject/Week),data=Rep1)
+ )
Output:
Error: Subject
Df Sum Sq Mean Sq
Place 1 2570.3 2570.3
Error: Subject:Week
Df Sum Sq Mean Sq
Week 1 977.08 977.08
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Place 2 9764 4882 45.4435 < 2.2e-16 ***
Station 3 7120 2373 22.0930 5.068e-14 ***
Species 4 35145 8786 81.7883 < 2.2e-16 ***
Week 1 5 5 0.0421 0.8374211
Place:Station 3 1355 452 4.2048 0.0056664 **
Place:Species 10 44468 4447 41.3934 < 2.2e-16 ***
Station:Species 15 20277 1352 12.5833 < 2.2e-16 ***
Place:Week 2 1674 837 7.7894 0.0004298 ***
Station:Week 3 2617 872 8.1194 2.286e-05 ***
Species:Week 4 4104 1026 9.5500 1.244e-07 ***
Place:Station:Species 15 6155 410 3.8196 9.862e-07 ***
Place:Station:Week 3 457 152 1.4188 0.2355024
Place:Species:Week 10 5830 583 5.4268 5.984e-08 ***
Station:Species:Week 15 4484 299 2.7826 0.0002802 ***
Place:Station:Species:Week 15 3363 224 2.0867 0.0084501 **
Residuals 1620 174033 107
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
Data:
Subject Place Station Species Week Total
1 Amnun Garden Aa 1 1
2 Amnun Garden As 1 0
3 Amnun Garden Lp 1 0
4 Amnun Garden Ls 1 0
5 Amnun Garden Lt 1 1
6 Amnun Garden Ps 1 0
7 Amnun Grass Aa 1 0
8 Amnun Grass As 1 0
9 Amnun Grass Lp 1 0
10 Amnun Grass Ls 1 0
11 Amnun Grass Lt 1 0
12 Amnun Grass Ps 1 0
13 Amnun Rocks Aa 1 1
14 Amnun Rocks As 1 0
15 Amnun Rocks Lp 1 0
16 Amnun Rocks Ls 1 0
17 Amnun Rocks Lt 1 0
18 Amnun Rocks Ps 1 0
19 Korazim 1 Garden Aa 1 0
20 Korazim 1 Garden As 1 0
21 Korazim 1 Garden Lp 1 0
22 Korazim 1 Garden Ls 1 0
23 Korazim 1 Garden Lt 1 0
24 Korazim 1 Garden Ps 1 0
25 Korazim 1 Grass Aa 1 0
26 Korazim 1 Grass As 1 0
27 Korazim 1 Grass Lp 1 0
28 Korazim 1 Grass Ls 1 0
29 Korazim 1 Grass Lt 1 0
30 Korazim 1 Grass Ps 1 0
31 Korazim 1 Rocks Aa 1 0
32 Korazim 1 Rocks As 1 0
33 Korazim 1 Rocks Lp 1 0
34 Korazim 1 Rocks Ls 1 0
35 Korazim 1 Rocks Lt 1 3
36 Korazim 1 Rocks Ps 1 0
37 Korazim 2 Garden Aa 1 0
38 Korazim 2 Garden As 1 0
39 Korazim 2 Garden Lp 1 0
40 Korazim 2 Garden Ls 1 0
41 Korazim 2 Garden Lt 1 0
42 Korazim 2 Garden Ps 1 0
43 Korazim 2 Ochard Aa 1 0
44 Korazim 2 Ochard As 1 0
45 Korazim 2 Ochard Lp 1 0
46 Korazim 2 Ochard Ls 1 0
47 Korazim 2 Ochard Lt 1 0
48 Korazim 2 Ochard Ps 1 0
49 Korazim 2 Rocks Aa 1 0
50 Korazim 2 Rocks As 1 0
51 Korazim 2 Rocks Lp 1 0
52 Korazim 2 Rocks Ls 1 0
53 Korazim 2 Rocks Lt 1 4
54 Korazim 2 Rocks Ps 1 0
1 Amnun Garden Aa 2 0
2 Amnun Garden As 2 0
3 Amnun Garden Lp 2 0
4 Amnun Garden Ls 2 0
5 Amnun Garden Lt 2 1
6 Amnun Garden Ps 2 0
7 Amnun Grass Aa 2 0
8 Amnun Grass As 2 0
9 Amnun Grass Lp 2 0
10 Amnun Grass Ls 2 0
11 Amnun Grass Lt 2 0
12 Amnun Grass Ps 2 0
13 Amnun Rocks Aa 2 0
14 Amnun Rocks As 2 0
15 Amnun Rocks Lp 2 0
16 Amnun Rocks Ls 2 0
17 Amnun Rocks Lt 2 0
18 Amnun Rocks Ps 2 0
19 Korazim 1 Garden Aa 2 0
20 Korazim 1 Garden As 2 0
21 Korazim 1 Garden Lp 2 0
22 Korazim 1 Garden Ls 2 0
23 Korazim 1 Garden Lt 2 0
24 Korazim 1 Garden Ps 2 0
25 Korazim 1 Grass Aa 2 0
26 Korazim 1 Grass As 2 0
27 Korazim 1 Grass Lp 2 0
28 Korazim 1 Grass Ls 2 0
29 Korazim 1 Grass Lt 2 0
30 Korazim 1 Grass Ps 2 0
31 Korazim 1 Rocks Aa 2 0
32 Korazim 1 Rocks As 2 0
33 Korazim 1 Rocks Lp 2 0
34 Korazim 1 Rocks Ls 2 0
35 Korazim 1 Rocks Lt 2 1
36 Korazim 1 Rocks Ps 2 0
37 Korazim 2 Garden Aa 2 0
38 Korazim 2 Garden As 2 0
39 Korazim 2 Garden Lp 2 0
40 Korazim 2 Garden Ls 2 0
41 Korazim 2 Garden Lt 2 0
42 Korazim 2 Garden Ps 2 0
43 Korazim 2 Ochard Aa 2 0
44 Korazim 2 Ochard As 2 0
45 Korazim 2 Ochard Lp 2 0
46 Korazim 2 Ochard Ls 2 0
47 Korazim 2 Ochard Lt 2 0
48 Korazim 2 Ochard Ps 2 0
49 Korazim 2 Rocks Aa 2 0
50 Korazim 2 Rocks As 2 0
51 Korazim 2 Rocks Lp 2 0
52 Korazim 2 Rocks Ls 2 0
53 Korazim 2 Rocks Lt 2 4
54 Korazim 2 Rocks Ps 2 0
Very Much obliged
Gideon Wasserberg
Wildlife research unit,
Department of wildlife ecology,
University of Wisconsin
218 Russell labs, 1630 Linden dr.,
Madison, Wisconsin 53706, USA.
Tel.:608 265 2130, Fax: 608 262 6099
More information about the R-help
mailing list