嵌套设计(nested design)又称为窝设计和套设计,与析因设计的处理不同,嵌套设计不是各因素个水平的全面组合,而是各因素按其隶属关系系统分组,各因素水平之间没有交叉。 [^]:图片取自孙振球老师 《医学统计学》P208
dat<-data.frame( x=c(82,84,91,88,85,83,65,61 ,62 ,59 ,56, 60 ,71 ,67 ,75 ,78 ,85 ,89), cuihuaji=gl(3,6), wendu=factor(rep(c(1,1,2,2,3,3),3)) ) dat
## x cuihuaji wendu
## 1 82 1 1
## 2 84 1 1
## 3 91 1 2
## 4 88 1 2
## 5 85 1 3
## 6 83 1 3
## 7 65 2 1
## 8 61 2 1
## 9 62 2 2
## 10 59 2 2
## 11 56 2 3
## 12 60 2 3
## 13 71 3 1
## 14 67 3 1
## 15 75 3 2
## 16 78 3 2
## 17 85 3 3
## 18 89 3 3
summary(aov(x~cuihuaji*wendu,data = dat)) # two way ANOVA
## Df Sum Sq Mean Sq F value Pr(>F)
## cuihuaji 2 1956.0 978.0 177.818 5.83e-08 ***
## wendu 2 74.3 37.2 6.758 0.016142 *
## cuihuaji:wendu 4 326.7 81.7 14.848 0.000534 ***
## Residuals 9 49.5 5.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(aov(x~cuihuaji/wendu,data = dat)) # nested design ANOVA
## Df Sum Sq Mean Sq F value Pr(>F)
## cuihuaji 2 1956.0 978.0 177.82 5.83e-08 ***
## cuihuaji:wendu 6 401.0 66.8 12.15 0.000716 ***
## Residuals 9 49.5 5.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Another version :nested ANOVA summary(aov(x~cuihuaji + Error(cuihuaji/wendu),data=dat))
##
## Error: cuihuaji
## Df Sum Sq Mean Sq
## cuihuaji 2 1956 978
##
## Error: cuihuaji:wendu
## Df Sum Sq Mean Sq F value Pr(>F)
## Residuals 6 401 66.83
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## Residuals 9 49.5 5.5