2.5 常用实验设计方差分析的SAS程序 在这本教材中我们只介绍了完全随机化实验设计和交叉分组实验设计的方差分析。除这两种实验设计外,还有很多实验设计需要用方差分析的方法处理数据。如随机化完全区组设计、拉丁方设计、裂区设计、套设计、正交设计等。这些实验设计方法在很多教材中都可以找到,限于篇幅在这里就不做更多的介绍了,只给出线性统计模型、均方期望和检验统计量。完全随机化实验设计的SAS程序在§ 2.4中已经做过介绍,这一节将给出其它一些实验设计方差分析的SAS程序。在阅读以下内容之前,请先阅读第一章“SAS软件基本操作”。 2.5.1 三因素交叉分组实验的方差分析 在课本9.5.3中已经给出了一个混合模型(A、C固定,B随机)三因素交叉分组实验设计的均方期望及检验统计量。下面以一个一般化的三因素交叉分组实验为例说明方差分析的SAS程序。 例 2.10 由A、B、C三个因素构成一个三因素交叉分组实验,其中A、C固定,B随机。A因素有三个水平,记为A1-A3;B因素有四个水平,记为B1-B4;C因素有五个水平,记为C1-C5,实验重复两次。记录了R1和R2两个因变量(即实验结果,如作物的株高、穗长,人的血压、血黏度等),原始数据不再给出。按每一观测的A、B、C、R1、R2的顺序建立外部数据文件,路径和文件名为a:\2-6data.dat。 1 1 1 18.0 24.1 1 1 2 19.6 24.7 1 1 3 17.5 24.7 1 1 4 17.9 25.8 1 1 5 19.1 25.2 1 2 1 23.4 33.4 1 2 2 23.0 33.2 1 2 3 23.9 32.9 1 2 4 23.2 34.3 1 2 5 27.0 35.0 1 3 1 24.5 29.6 1 3 2 23.7 30.8 1 3 3 23.5 31.7 1 3 4 21.2 32.2 1 3 5 25.7 31.9 1 4 1 19.4 27.6 1 4 2 17.3 27.8 1 4 3 18.1 28.0 1 4 4 18.8 28.7 1 4 5 18.8 28.4 2 1 1 18.8 28.7 2 1 2 19.6 28.6 2 1 3 18.6 29.8 2 1 4 18.2 30.1 2 1 5 20.8 31.0 2 2 1 24.2 38.2 2 2 2 24.4 37.9 2 2 3 25.3 38.3 2 2 4 24.0 38.6 2 2 5 27.3 33.7 2 3 1 25.9 35.1 2 3 2 23.6 34.4 2 3 3 23.8 36.1 2 3 4 21.1 35.9 2 3 5 26.4 36.4 2 4 1 18.9 34.2 2 4 2 21.9 31.9 2 4 3 23.5 32.3 2 4 4 20.0 33.0 2 4 5 20.4 33.3 3 1 1 19.2 31.2 3 1 2 19.6 30.6 3 1 3 19.2 32.5 3 1 4 18.9 33.1 3 1 5 20.0 32.3 3 2 1 22.6 38.7 3 2 2 23.4 39.4 3 2 3 25.5 41.0 3 2 4 24.2 41.2 3 2 5 28.3 42.4 3 3 1 25.3 36.3 3 3 2 23.9 37.2 3 3 3 23.8 36.9 3 3 4 21.2 38.4 3 3 5 25.4 37.4 3 4 1 17.2 30.9 3 4 2 17.9 32.0 3 4 3 20.8 31.8 3 4 4 18.2 33.1 3 4 5 16.4 31.5 1 1 1 18.3 24.4 1 1 2 19.2 24.2 1 1 3 18.4 25.5 1 1 4 18.1 26.3 1 1 5 19.2 25.3 1 2 1 23.3 33.2 1 2 2 23.0 32.9 1 2 3 25.1 34.2 1 2 4 24.6 35.6 1 2 5 26.0 34.0 1 3 1 24.5 29.5 1 3 2 23.1 30.0 1 3 3 23.0 31.1 1 3 4 20.3 31.3 1 3 5 25.5 31.4 1 4 1 19.6 27.4 1 4 2 19.8 25.9 1 4 3 22.2 27.3 1 4 4 19.5 28.5 1 4 5 19.6 28.1 2 1 1 18.0 28.0 2 1 2 19.6 28.4 2 1 3 19.3 30.6 2 1 4 18.0 30.0 2 1 5 20.1 30.3 2 2 1 24.0 38.8 2 2 2 23.8 37.4 2 2 3 24.2 36.9 2 2 4 24.2 38.9 2 2 5 27.8 37.0 2 3 1 25.6 34.7 2 3 2 23.4 34.0 2 3 3 23.7 35.7 2 3 4 20.6 35.3 2 3 5 26.1 35.9 2 4 1 20.4 32.3 2 4 2 24.6 34.6 2 4 3 23.9 32.8 2 4 4 21.1 34.1 2 4 5 20.0 33.0 3 1 1 18.3 30.1 3 1 2 19.8 31.0 3 1 3 17.6 30.6 3 1 4 17.9 31.9 3 1 5 20.8 32.8 3 2 1 23.4 39.8 3 2 2 23.4 39.4 3 2 3 26.5 41.7 3 2 4 24.4 41.6 3 2 5 27.1 41.3 3 3 1 25.6 36.6 3 3 2 23.5 37.0 3 3 3 23.7 37.9 3 3 4 21.4 38.4 3 3 5 25.5 37.5 3 4 1 17.5 31.5 3 4 2 19.5 31.6 3 4 3 21.7 32.4 3 4 4 18.4 33.4 3 4 5 16.5 31.5 解:SAS程序如下: options linesize=76; data example; infile ‘a:\2-6data.dat’; input a b c r1 r2 @@; run; proc anova; class a b c; model r1 r2 = a b c a*b a*c b*c a*b*c; test h = a e = a*b; test h = c e = b*c; test h = a*c e = a*b*c; means a / duncan e = a*b alpha = 0.01; means c / lsd e = b*c alpha = 0.01; run; 与单因素方差分析的SAS程序相比,大同小异。在这里由于因素由1个变为3个,因此分类变量相应变为3个。在MODEL语句中r1 r2 = a b c a*b a*c b*c a*b*c; 的含义是,需要分析a、b、c三个主效应,两两交互作用及三重交互作用对因变量r1和r2的贡献。实际上,这里是两次方差分析,得到两个方差分析表,一个是对r1进行的方差分析,一个是对r2进行的方差分析。当然也可以只计算其中的一部分,如r1 r2 = a b c b*c或r2 = a b c a*b a*b*c 等。 TEST语句中h = a e = a*b 的含义是用A´B交互作用检验A因素效应,即FA =MSA / MSAB,另外两个TEST语句含义为FC=MSC / MSBC,FAC=MSAC / MSABC。在没有特别说明时,因素的效应都是用MSe检验的(见课本9.5.3)。当然,随着模型的改变,检验统计量会相应改变,这里的TEST语句也要改变。 MEANS语句中选项e = a*b是指明在做DUNCAN检验时,应使用MSAB作为误差均方检验因素A的效应,否则将使用MSe做检验。 实验结果中,若有缺失数据,缺失的数据在方差分析中将被忽略掉,因此实验结果中的数据应完整。 执行上述程序,输出的结果见表2-14。 表2-14 例2.10方差分析输出的结果 The SAS System Analysis of Variance Procedure Class Level Information
Number of observations in data set = 120 The SAS System Analysis of Variance Procedure Dependent Variable: R1
Tests of Hypotheses using the Anova MS for A*B as an error term
Tests of Hypotheses using the Anova MS for B*C as an error term
Tests of Hypotheses using the Anova MS for A*B*C as an error term
The SAS System Analysis of Variance Procedure Dependent Variable: R2
Tests of Hypotheses using the Anova MS for A*B as an error term
Tests of Hypotheses using the Anova MS for B*C as an error term
Tests of Hypotheses using the Anova MS for A*B*C as an error term
The SAS System Analysis of Variance Procedure Duncan's Multiple Range Test for variable: R1 NOTE: This test controls the type I comparisonwise error rate, not the experimentwise error rate Alpha=0.01 df=6 MSE=5.751889
Means with the same letter are not significantly different.
The SAS System Analysis of Variance Procedure Duncan's Multiple Range Test for variable: R2 NOTE: This test controls the type I comparisonwise error rate, not the experimentwise error rate Alpha=0.01 df=6 MSE=8.91225
Means with the same letter are not significantly different.
The SAS System Analysis of Variance Procedure T tests (LSD) for variable: R1 NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate. Alpha=0.01 df=12 MSE=10.77939 Critical Value of T=3.05 Least Significant Difference=2.895 Means with the same letter are not significantly different.
The SAS System Analysis of Variance Procedure T tests (LSD) for variable: R2 NOTE: This test controls the type I comparisonwise error rate not the experimentwise error rate. Alpha=0.01 df=12 MSE=0.626083 Critical Value of T=3.05 Least Significant Difference= 0.6977 Means with the same letter are not significantly different.
本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。 |