2.5.4 两因素随机化区组实验的方差分析
一个两因素交叉分组实验,若每一处理重复n次,全部实验共abn次(见课本9.1.1)。这abn次实验的实验条件或实验材料必须具有同质性。否则,由于实验材料或实验条件的差异所引起的误差会混杂于实验误差中,影响试验结果的可靠性。为避免这种情况的发生,与随机化完全区组的做法一样,将每一套水平组合,安排在一个区组中,n次重复构成了n个区组。这样一种设计称为两因素随机化区组设计。统计模型为:
其中ai 、bj 和(ab)ij分别为A因素、B因素和AB交互作用效应,dk 是第k区组效应。设A因素为固定因素,B和区组为随机因素,模型中各分量的均方期望可由下表推演出。
因素 |
|
均方期望 |
|
均方期望 |
abn1 |
abn1 |
ijkl |
ijkl |
αi |
0bn1 |
|
0bn1 |
|
βj |
a1n1 |
|
a1n1 |
|
(αβ)ij |
01n1 |
|
01n1 |
|
δk |
ab11 |
|
ab11 |
|
(αδ)ik |
0b11 |
|
1111 |
|
(βδ)jk |
a111 |
(αβδ)ijk |
0111 |
ε(ijk)l |
1111 |
上表中的l为区组内的重复,因l = 1,这时s2无法估计(误差自由度dfe = 0)。假设区组与因素间不存在交互作用,即将上表左半部的后四行合并,作为误差估计,得到表的右半部。由均方期望可以得到检验统计量,FA = MSA / MSAB,FB = MSB / MSe,FAB = MSAB / MSe。两因素随机区组实验的方差分析与三因素交叉分组实验的方差分析程序基本相同。
例 2.13 课本上表9-11中的实验,共需32名同质受试者,因32名同质受试者很难找到,因此将实验的两个重复安排为两个区组,每一区组只要16名同质受试者即可。
解: 先创建一个名为a:\2-7data.dat的外部数据文件。SAS程序为:
options linesize = 76;
data work;
infile ‘a:\2-7data.dat’;
input block a b energy @@;
run;
proc anova;
class block a b;
model energy = block a b a*b;
test h = a e = a*b;
means a / duncan e = a*b;
run;
输出结果见表2-17。
表2-17 例2.13方差分析输出的结果
The SAS System
Analysis of Variance Procedure
Class Level Information
Class |
Levels |
Values |
BLOCK |
2 |
1 2 |
A |
4 |
1 2 3 4 |
B |
4 |
1 2 3 4 |
Number of observations in data set = 32
The SAS System
Analysis of Variance Procedure
Dependent Variable: ENERGY
|
|
Sum of |
Mean |
|
|
Source |
DF |
Squares |
Square |
F Value |
Pr > F |
|
|
|
|
|
|
Model |
16 |
13.1329000 |
0.8208062 |
8.16 |
0.0001 |
Error |
15 |
1.5083875 |
0.1005592 |
|
|
Corrected Total |
31 |
14.6412875 |
|
|
|
R-Square |
C.V. |
Root MSE |
ENERGY Mean |
0.896977 |
14.32864 |
0.31711 |
2.21313 |
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
|
|
|
|
|
|
BLOCK |
1 |
0.27751250 |
0.27751250 |
2.76 |
0.1174 |
A |
3 |
3.99633750 |
1.33211250 |
13.25 |
0.0002 |
B |
3 |
0.45056250 |
0.15018750 |
1.49 |
0.2567 |
A*B |
9 |
8.40848750 |
0.93427639 |
9.29 |
0.0001 |
Tests of Hypotheses using the Anova MS for A*B as an error term
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
A |
3 |
3.99633750 |
1.33211250 |
1.43 |
0.2982 |
The SAS System
Analysis of Variance Procedure
Duncan's Multiple Range Test for variable: ENERGY
NOTE: This test controls the type I comparisonwise error rate, not
the experimentwise error rate
Alpha=0.05 df=9 MSE=0.934276
Number of Means |
2 |
3 |
4 |
Critical Range |
1.093 |
1.141 |
1.169 |
Means with the same letter are not significantly different.
Duncan Grouping |
Mean |
N |
A |
|
|
|
|
A |
2.6400 |
8 |
4 |
A |
|
|
|
A |
2.2900 |
8 |
1 |
A |
|
|
|
A |
2.2650 |
8 |
2 |
A |
|
|
|
A |
1.6575 |
8 |
3 |
2.5.5 裂区实验设计的方差分析
裂区设计(split – plot design)与两因素随机区组设计近似。不同点是后者在每一区组内A、B两因素的ab次处理是完全随机化的。而裂区设计的每一区组内A因素先分为a个处理,在每一处理内B因素再分为b个处理。随机化过程只能在A因素的a个处理和B因素的b个处理之间进行。由A因素所划分的A个部分称为主区,每一主区再划分的b个部分称为次区。线性统计模型为:
其中ai 、bj 和 (ab)ij代表主区,分别相应于区组(因素A),主处理(因素B)和主区误差(AB交互作用);gk 、(ag)ik 、(bg)jk 和 (abg)ijk代表次区,分别相应于次处理(因素C),AC、BC交互作用以及次区误差(ABC交互作用)。裂区设计在多数情况下,区组为随机因素,设B和C为固定因素,均方期望推演如下。
因 素 |
|
|
均方期望 |
abcn |
|
ijkl |
|
主区 |
αi |
1bc1 |
|
|
βj |
a0c1 |
|
|
(αβ)ij |
10c1 |
|
|
|
|
|
|
|
次区 |
γk |
ab01 |
|
|
(αγ)ik |
1b01 |
|
|
(βγ)jk |
a001 |
|
|
(αβγ)ijk |
1001 |
|
|
ε(ijk)l |
1111 |
|
|
因区组内没有重复,所以s2 无法估计。主区中的主处理(B)是用AB交互作用检验的,次区中的次处理(C)用AC交互作用检验,BC交互作用用ABC交互作用进行检验。裂区设计的方差分析与三因素交叉分组实验的方差分析近似。
例 2.14 假设课本上表9-11中的实验是一个裂区实验,共有3个区组,在每一工作速度下(主处理A=4)安排不同受试时间(次处理B=5)。写出SAS程序并输出结果。
解:
options linesize = 76;
data split;
infile ‘a: \ 2-8data.dat’;
input block b c energy @@;
run;
proc anova;
class block b c;
model energy = block b c block*b block*c b*c block*b*c;
test h = b e = block*b ;
test h = c e = block*c;
test h = b*c e = block*b*c;
run;
输出结果见表2-18。
表2-18: 例2.14方差分析输出结果
The SAS System
Analysis of Variance Procedure
Class Level Information
Class |
Levels |
Values |
BLOCK |
2 |
1 2 |
B |
4 |
1 2 3 4 |
C |
4 |
1 2 3 4 |
Number of observations in data set = 32
The SAS System
Analysis of Variance Procedure
Dependent Variable: ENERGY
|
|
Sum of |
Mean |
|
|
Source |
DF |
Squares |
Square |
F Value |
Pr > F |
|
|
|
|
|
|
Model |
31 |
14.6412875 |
0.4722996 |
. |
. |
Error |
0 |
. |
. |
|
|
Corrected Total |
31 |
14.6412875 |
|
|
|
R-Square |
C.V. |
Root MSE |
ENERGY Mean |
1.000000 |
0 |
0 |
2.21313 |
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
|
|
|
|
|
|
BLOCK |
1 |
0.27751250 |
0.27751250 |
. |
. |
B |
3 |
3.99633750 |
1.33211250 |
. |
. |
C |
3 |
0.45056250 |
0.15018750 |
. |
. |
BLOCK*B |
3 |
0.19203750 |
0.06401250 |
. |
. |
BLOCK*C |
3 |
0.12271250 |
0.04090417 |
. |
. |
B*C |
9 |
8.40848750 |
0.93427639 |
. |
. |
BLOCK*B*C |
9 |
1.19363750 |
0.13262639 |
. |
. |
Tests of Hypotheses using the Anova MS for BLOCK*B as an error term
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
B |
3 |
3.99633750 |
1.33211250 |
20.81 |
0.0164 |
Tests of Hypotheses using the Anova MS for BLOCK*C as an error term
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
C |
3 |
0.45056250 |
0.15018750 |
3.67 |
0.1569 |
Tests of Hypotheses using the Anova MS for BLOCK*B*C as an error term
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
B*C |
9 |
8.40848750 |
0.93427639 |
7.04 |
0.0038 |
从表2-18的第一部分可见,误差自由度为0,得不到误差均方,因此模型效应无法估计。
在裂区设计的次区,还可以再细分,产生次-次区,从而构成裂-裂区设计。裂-裂区设计均方期望的推演、检验统计量的确定及SAS程序在这里不再详述,请读者自行完成。
2.5.6 套设计的方差分析
根据因素数的不同,套设计可分为二因素(二级)、三因素(三级)¼等套设计,这里只举出一个二级套设计的例子,说明二级套设计方差分析的SAS程序。二级套设计的统计模型如下:
其中ai 是A因素第i水平的效应,bj(i) 是在A因素第i水平内,B因素第j水平的效应,ek(ij)是在A因素第i水平,B因素第j水平下的第k次重复。由此可见,套设计实际上是一个因素的效应嵌套在另一个因素的效应之中。设A、B均为随机因素,可由下表推演出均方期望。
R R R
因 素 a b n 均 方 期 望
i j k
ai 1 b n s2 + ns2b + bns2a
bj(i) 1 1 n s2 + ns2b
ek(ij) 1 1 1 s2
检验统计量:FA = MSA / MSB(A) FB = MSB(A) / MSe 。
例 2.15 随机选取3株植物,在每一株内随机选取两片叶子(嵌套在植株因素下的第二个因素),用取样器从每一片叶子上选取同样面积的两个样本(两次重复),称取湿重。对以上结果进行方差分析。
解: SAS程序如下:
options linesize = 76;
data nested;
input plant $ leaf wt @@;
cards;
a 1 12.1 a 1 12.1 b 1 14.4 b 1 14.4 c 1 23.1 c 1 23.4
a 2 12.8 a 2 12.8 b 2 14.7 b 2 14.5 c 2 28.1 c 2 28.8
proc anova;
class plant leaf ;
model wr = plant leaf (plant);
test h = plant e = leaf (plant);
run;
输出结果见表2-19。
表2-19: 例2.15方差分析输出结果
The SAS System
Analysis of Variance Procedure
Class Level Information
Class |
Levels |
Values |
PLANT |
3 |
a b c |
LEAF |
2 |
1 2 |
Number of observations in data set = 12
The SAS System
Analysis of Variance Procedure
Dependent Variable: WT
|
|
Sum of |
Mean |
|
|
Source |
DF |
Squares |
Square |
F Value |
Pr > F |
|
|
|
|
|
|
Model |
5 |
444.350000 |
88.870000 |
1720.06 |
0.0001 |
Error |
6 |
0.310000 |
0.051667 |
|
|
Corrected Total |
11 |
444.660000 |
|
|
|
R-Square |
C.V. |
Root MSE |
WT Mean |
0.999303 |
1.291494 |
0.22730 |
17.6000 |
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
|
|
|
|
|
|
PLANT |
2 |
416.780000 |
208.390000 |
4033.35 |
0.0001 |
LEAF(PLANT) |
3 |
27.570000 |
9.190000 |
177.87 |
0.0001 |
Tests of Hypotheses using the Anova MS for LEAF(PLANT) as an error term
Source |
DF |
Anova SS |
Mean Square |
F Value |
Pr > F |
PLANT |
2 |
416.780000 |
208.390000 |
22.68 |
0.0155 |
三级以上套设计的计算方法与此类似,这里不再举例。
2.5.7 正交设计的方差分析
正交设计的方差分析与多因素交叉分组设计的SAS程序类似。实际上,正交设计的SAS程序比多因素交叉分组设计更简单些。因为正交设计的因素都属固定型,所有效应都用MSe检验,不像交叉分组设计的模型那么复杂。学习了以上几种实验设计方差分析的SAS程序以后,对于编写正交设计的SAS程序便不会有很多困难了,请读者尝试自行编写。
以上介绍了平衡设计的PROC ANOVA过程。除此之外,还有其它一些过程也可以进行方差分析,如PROC GLM,PROC NESTED,PROC LATTICE,PROC MIXED等,这里不再介绍。
|