Hi,
I'm trying to analyse a hierachical design and am running into some
trouble. Clearly I don't fully understand "Error" and I was
hoping someone
could set me straight.
We measure percentage algal cover in each of 5 quadrats from each of 16
patches where 4 treatments are randomly allocated to a patch.
First suppose patches are coded 1 to 16. then the following gives the
results I would expect.
> Algae <- c(0, 0, 0, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0,
+ 0, 0, 13, 0, 23, 17, 0, 56, 46, 0, 79, 32, 51, 22, 5, 0, 0, 0,
+ 0, 0, 56, 3, 0, 41, 0, 5, 8, 0, 0, 0, 0, 0, 0, 0, 43, 8, 69,
+ 29, 39, 40, 63, 0, 71, 5, 46, 44, 41, 29, 11, 65, 55, 61, 74,
+ 55, 0, 5, 0, 0, 6, 30, 82, 70, 27, 83)>
> Treat <- gl(4,20)
> Patch <- gl(16,5)
> Quadrat <- gl(5,1,80)
>
> d <- data.frame(Treat,Patch,Quadrat,Algae)
> fit <- aov(Algae ~ Treat + Error(Patch),data=d)
> summary(fit)
Error: Patch
Df Sum Sq Mean Sq F value Pr(>F)
Treat 3 14429.1 4809.7 2.7171 0.09126 .
Residuals 12 21241.9 1770.2
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` '
1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 64 19110.4 298.6
But if patches are coded 1-4 within treatments, then the following also
gives results I would expect,
> Patch <- gl(4,5,80)
>
> d1 <- data.frame(Treat,Patch,Quadrat,Algae)
> fit <- aov(Algae ~ Treat + Error(Patch %in% Treat),data=d1)
Warning message:
Error model is singular in: aov(Algae ~ Treat + Error(Patch %in% Treat),
data = d1)> summary(fit)
Error: Patch:Treat
Df Sum Sq Mean Sq F value Pr(>F)
Treat 3 14429.1 4809.7 2.7171 0.09126 .
Residuals 12 21242.0 1770.2
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` '
1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 64 19110.4 298.6
But in R-1.9.0 beta (27/03/2004) I get the error about the model being
singular, which I do not get in 1.8.1. Why is this?
Secondly, I had the impression that "/" and "%in%" were
loosely synonymous,
so why is the following different?> fit <- aov(Algae ~ Treat + Error(Treat/Patch),data=d1)
> summary(fit)
Error: Treat
Df Sum Sq Mean Sq
Treat 3 14429.1 4809.7
Error: Treat:Patch
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 12 21241.9 1770.2
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 64 19110.4 298.6
I had a look at the help for "formula" but that does not mention
"/", and
the help for "Error" is not that enlightening either.
Any help is most welcome - sorry for yet again being a drain on everone's
time
Simon.
---