本站分享:AI、大数据、数据分析师培训认证考试,包括:Python培训Excel培训Matlab培训SPSS培训SAS培训R语言培训Hadoop培训Amos培训Stata培训Eviews培训

单因素方差分析的SAS程序_sas单因素方差分析_SAS培训

sas培训 cdadata 4509℃

单因素方差分析的SAS程序

 

在阅读以下内容之前,请先阅读第一章”SAS软件基本操作”。

 

单因素实验设计又称为完全随机化实验设计。该实验设计要求实验条件或实验环境的同质性很高。例如,比较a个作物品种的产量,每一品种设置n个重复,全部实验共有an次。根据完全随机化实验设计的要求,试验田中的an个试验小区的土质、肥力、含水量、小气候、田间管理等条件必须完全一致。至于哪一个品种的哪一次重复安排在哪一个小区,完全是随机的,因此得到了“完全随机化实验设计”这一名称。

 

例2.9  下面以课本中例8.1的数据为例,给出单因素方差分析的SAS程序。

解:先按以下输入方式建立一个称为a:2-5data.dat的外部数据文件。

1 64.6 1 65.3 1 64.8 1 66.0 1 65.8 2 64.5 2 65.3 2 64.6
2 63.7 2 63.9 3 67.8 3 66.3 3 67.1 3 66.8 3 68.5 4 71.8
4 72.1 4 70.0 4 69.1 4 71.0 5 69.2 5 68.2 5 69.8 5 68.3
5 67.5                            

SAS程序如下:

options  linesize=76;

data wheat;

infile  ‘a:2-5data.dat’;

input  strain  hight  @@;

run;

proc  anova;

class  strain;

model  hight=strain;

means  strain / duncan;

means  strain / lsd  cldiff;

run;

在PROC ANOVA过程中的CLASS语句(分类语句)是必须的,而且一定要放在MODEL语句之前。在方差分析中要使用的分类变量(因素),首先要在CLASS语句中说明。分类变量可以是数值型的,也可以是字符型的。MODEL语句用来规定因素对实验结果的效应,一般形式为,因变量=因素效应。本例即为株高=品系效应。

MEANS语句应放在MODEL语句之后,MEANS语句后列出希望得到均值的那些变量。MEANS语句有很多选项,下面列出几个与本教材有关的选项,将选项写在MEANS语句的“/”之后。

DUNCAN: 对MEANS语句列出的所有主效应均值进行DUNCAN检验。

SNK: 对MEANS语句列出的所有主效应均值进行Student-Newman-Keuls检验。

T | LSD: 对MEANS语句列出的所有主效应均值进行两两t检验,它相当于在样本含          量相同时的LSD检验。

ALPHA=  均值间对比检验的显著水平,缺省值是0.05。当用DUNCAN选项时只能取0.01、0.05和0.10,对于其它选项,α可取0.0001到0.9999之间的任何值。

CLDIFF: 在选项T和LSD时,过程将两个均值之差以置信区间的形式输出。

CLM: 在选项T和LSD时,过程把变量的每一水平均值以置信区间的形式输出。

执行上述程序,输出结果见表2-13。

 

表 2-13例2.9方差分析输出结果

                                                                            

 

The SAS System

 

Analysis of Variance Procedure

Class Level Information

 

Class Levels Values
STRAIN 5 1 2 3 4 5
     

Number of observations in data set = 25

 

The SAS System

 

Analysis of Variance Procedure

 

Dependent Variable: HIGHT

 

    Sum of Mean    
Source DF Squares Square F Value Pr > F
           
Model 4 131.740000 32.935000 42.28 0.0001
Error 20 15.580000 0.779000    
Corrected Total 24 147.320000      

 

R-Square C.V. Root MSE HIGHT Mean
0.894244 1.311846 0.88261 67.2800

 

Source DF Anova SS Mean Square F Value Pr > F
STRAIN 4 131.740000 32.935000 42.28 0.0001

 

The SAS System

 

Analysis of Variance Procedure

 

Duncan’s Multiple Range Test for variable: HIGHT

 

NOTE: This test controls the type I comparisonwise error rate, not

the experimentwise error rate

 

Alpha= 0.05  df= 20  MSE= 0.779

 

Number of Means 2 3 4 5
Critical Range 1.164 1.222 1.259 1.285

 

Means with the same letter are not significantly different.

 

Duncan Grouping Mean N STRAIN
A 70.8000 5 4
B 68.6000 5 5
C 67.3000 5 3
D 65.3000 5 1
D 64.4000 5 2

 

The SAS System

 

Analysis of Variance Procedure

 

T tests (LSD) for variable: HIGHT

 

NOTE: This test controls the type I comparisonwise error rate not

the experimentwise error rate.

 

Alpha= 0.05  Confidence= 0.95  df= 20  MSE= 0.779

Critical Value of T= 2.08596

Least Significant Difference= 1.1644

 

Comparisons significant at the 0.05 level are indicated by ‘***’.

 

Lower Difference Upper    
STRAIN Confidence Between Confidence  
Comparison Limit Means Limit  
         
4  –  5 1.0356 2.2000 3.3644 ***
4  –  3 2.3356 3.5000 4.6644 ***
4  –  1 4.3356 5.5000 6.6644 ***
4  –  2 5.2356 6.4000 7.5644 ***
         
5  –  4 -3.3644 -2.2000 -1.0356 ***
5  –  3 0.1356 1.3000 2.4644 ***
5  –  1 2.1356 3.3000 4.4644 ***
5  –  2 3.0356 4.2000 5.3644 ***
         
3  –  4 -4.6644 -3.5000 -2.3356 ***
3  –  5 -2.4644 -1.3000 -0.1356 ***
3  –  1 0.8356 2.0000 3.1644 ***
3  –  2 1.7356 2.9000 4.0644 ***
         
1  –  4 -6.6644 -5.5000 -4.3356 ***
1  –  5 -4.4644 -3.3000 -2.1356 ***
1  –  3 -3.1644 -2.0000 -0.8356 ***
1  –  2 -0.2644 0.9000 2.0644  
         
2  –  4 -7.5644 -6.4000 -5.2356 ***
2  –  5 -5.3644 -4.2000 -3.0356 ***
2  –  3 -4.0644 -2.9000 -1.7356 ***
2  –  1 -2.0644 -0.9000 0.2644  

 

表中的各项内容都是很明确的,这里不再赘述。只有R2以前没有见过,请参阅课本11.2.1

方差分析应具备三个条件,有时这三个条件并不能够得到满足,这时对原始数据就要进行变换,见课本§ 9.7。对原始数据进行变换,只需加上一个赋值语句即可,可参考配对数据t检验的SAS程序。

转载请注明:数据分析 » 单因素方差分析的SAS程序_sas单因素方差分析_SAS培训

喜欢 (1)or分享 (0)