[R] F-values in nested designs
Marcus Nunes
marcus.nunes at gmail.com
Tue Oct 4 20:17:42 CEST 2011
Hello all
I'm trying to learn how to fit a nested model in R. I found a toy
example on internet where a dataset that have 3 areas and 4 sites
within these areas. When I use Minitab to fit a nested model to this
data, this is the ANOVA table that I got:
Nested ANOVA: y versus areas, sites
Analysis of Variance for y
Source DF SS MS F P
areas 2 4.5000 2.2500 0.158 0.856
sites 9 128.2500 14.2500 3.167 0.012
Error 24 108.0000 4.5000
Total 35 240.7500
When I use R, this is the ANOVA table that I got:
summary(aov(y ~ areas + Error(areas%in%sites)))
Error: areas:sites
Df Sum Sq Mean Sq F value Pr(>F)
areas 2 4.50 2.25 0.1579 0.8563
Residuals 9 128.25 14.25
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 24 108 4.5
Warning message:
In aov(y ~ areas + Error(areas %in% sites)) : Error() model is singular
The results are the same, except for one F-value and I don't
understand why. Hence, these are my questions:
1) I searched google and I can't find a reason to have this warning in
my code. Why is this happening?
2) why I don't have an F-value for the nested effect? I realize that R
call it as Residuals in the first part of the summary, but there is a
way to make R consider it s another factor?
INB4: if I have a nested design with treatment A and treatment B
within A, F-values are MSA/MSA(B) and MSA(B)/MSE, correct? How can I
make R give these values directly, without further coding?
Thanks for your help.
Below is my code and information about my system.
----------------------
y = c(10, 12, 8, 13, 14, 8, 10, 12, 9, 10, 12, 11, 11, 13, 9, 10, 14,
11, 10, 9, 8, 9, 8, 8, 13, 14, 7, 10, 10, 13, 9, 7, 16, 12, 5, 4)
areas = as.factor(rep(c("m1", "m2", "m3"), each=12))
#sites = as.factor(c(rep(c(1, 2, 3, 4), 3), rep(c(5, 6, 7, 8), 3),
rep(c(9, 10, 11, 12), 3)))
sites = as.factor(c(rep(c(1, 2, 3, 4), 9)))
repl = as.factor(rep(c(1, 2, 3), each=4, 3))
summary(aov(y ~ areas + Error(areas%in%sites)))
summary(aov(y ~ areas + Error(areas%in%sites)))
Error: areas:sites
Df Sum Sq Mean Sq F value Pr(>F)
areas 2 4.50 2.25 0.1579 0.8563
Residuals 9 128.25 14.25
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 24 108 4.5
Warning message:
In aov(y ~ areas + Error(areas %in% sites)) : Error() model is singular
sessionInfo()
R version 2.13.1 Patched (2011-08-25 r56798)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] car_2.0-11 survival_2.36-9 nnet_7.3-1
[4] MASS_7.3-14 lme4_0.999375-40 Matrix_0.999375-50
[7] lattice_0.19-33 nlme_3.1-102
loaded via a namespace (and not attached):
[1] grid_2.13.1 stats4_2.13.1 tools_2.13.1
--
Marcus Nunes
marcus.nunes at gmail.com
More information about the R-help
mailing list