您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > SAS统计分析范例(2009.11.10)
1SAS统计分析程序范例prociml;t={11.113.320.2};m3=orpol(t,2);printm3;run;Dataaa;Inputgroup$level$value@@;Cards;B11.920279933B11.994526316B12.362389023B12.276282528B12.261029412B21.962594458B21.825117986B21.881757169B21.782291667B21.909411765B21.88030751B22.154036458B31.846367656B31.904365904B31.787766878B31.779214781B31.729896907B31.823794997A11.979061785A11.752841868A11.754926511A11.882359081A12.103314572A12.13045085A11.820079863A21.846532218A21.878964401A21.678232216A21.704280557A21.673333333A21.9203412582A31.65288075A31.571456217A31.564559216A31.663129252A31.671637816A31.747802787;run;一.数据的正态性检验A.SAS统计分析程序------------------------------------------------------------------------------------------------------------------------------------------title'三种不同添加剂饲喂动物后尿中氨氮的排出量';optionsps=500ls=100;procimportdatafile=D:\三种不同添加剂饲喂动物后尿中氨氮的排出量.xlsout=adbms=excelreplace;run;dataax;seta;procprint;procUNIVARIATEnormal;varx;bygroup;run;-----------------------------------------------------------------------------------------------------------------------------------------3B.SAS统计分析相关数据文件三种不同添加剂饲喂动物后尿中氨氮的排出量.xlsgroupx130127135135129133132136126141133131243245253244251253254237247257248242382366366386356352376383372373359353注:数据文件中group为三种不同的添加剂处理,x为动物尿中氨氮排出量。4C.SAS程序运行后输出的主要结果---------------------------------------------------------------------------------------------------------------------------------------group=1TestsforNormalityTest--Statistic--------pValue------Shapiro-WilkW0.973131PrW0.9407Kolmogorov-SmirnovD0.105905PrD0.1500Cramer-vonMisesW-Sq0.020807PrW-Sq0.2500Anderson-DarlingA-Sq0.171307PrA-Sq0.2500group=2TestsforNormalityTest--Statistic--------pValue------Shapiro-WilkW0.970828PrW0.9193Kolmogorov-SmirnovD0.142503PrD0.1500Cramer-vonMisesW-Sq0.031749PrW-Sq0.2500Anderson-DarlingA-Sq0.205907PrA-Sq0.2500group=3TestsforNormalityTest--Statistic--------pValue------Shapiro-WilkW0.937086PrW0.4613Kolmogorov-SmirnovD0.124959PrD0.1500Cramer-vonMisesW-Sq0.0366PrW-Sq0.2500Anderson-DarlingA-Sq0.271405PrA-Sq0.2500---------------------------------------------------------------------------------------------------------------------------------------结果说明:由于Shapiro-Wilk检验的结果P均大于0.05,故判定三组数据均来自正态分布总体。附录:关于正态性检验说明在SAS正态分布检验中,当n≤2000时,应选用Shapiro-Wilk检验,当W值越接近于1,提示数据符合正态分布;当W值偏离1,提示数据不符合正态分布。当n>2000时,应选用Kolmogorov-Smirnov检验,D值越大,P值越小,表示数据不符合正态分布,反之,D值越小,P值越大,提示数据符合正态分布。(SAS软件标准)5二.数据的方差同质性检验及数据转化2.1数据的方差同质性检验A.SAS统计分析程序------------------------------------------------------------------------------------------------------------------------------------------Title'三种不同添加剂饲喂动物后尿中氨氮的排出量';optionsps=500ls=100;procimportdatafile=D:\三种不同添加剂饲喂动物后尿中氨氮的排出量.xlsout=adbms=excelreplace;run;quit;dataaa;seta;procmeans;varx;bygroup;run;procmeansnoprintdata=aa;varx;bygroup;outputout=mx1css=ssN=Nstd=s;run;datamx2;setmx1;f=N-1;u=1/f;_type_=1;logs=2*f*log(s);run;procmeansnoprintdata=mx2;varssNfulogs_type_;outputout=mx3sum=t_sst_Nt_ft_ut_logsk;dataresult;setmx3;sc2=t_ss/t_f;fz=t_f*log(sc2)-t_logs;fm=1+1/3/(k-1)*(t_u-1/t_f);df=k-1;chisqr=fz/fm;prob=1-probchi(chisqr,df);procprintnoobs;varchisqrdfprob;run;------------------------------------------------------------------------------------------------------------------------------------------6B.SAS统计分析相关数据文件与上表相同(三种不同添加剂饲喂动物后尿中氨氮的排出量.xls).C.SAS程序运行后输出的主要结果-------------------------------------------group=1--------------------------------------------AnalysisVariable:xMeanStdDevStdError32.33333334.16333201.2018504-------------------------------------------group=2--------------------------------------------AnalysisVariable:xMeanStdDevStdError47.83333335.90582661.7048653-------------------------------------------group=3--------------------------------------------AnalysisVariable:xMeanStdDevStdError68.666666711.90365363.4362888---------------------------------------------------------------------------------------------------chisqrdfprob12.13902.002312362----------------------------------------------------------------------------------------------------结果说明:P=0.0023<0.05,表明三组数据的方差异质。通过比较发现,均数较大的组,其标准差也较大,标准差与均数之间存在某种关系,故需要对原始数据进行对数转换。附录:常见的数据转换有四种①平方根转换适用于总体呈泊松分布的资料。②对数转换各组数据的标准差或全距与其平均数大体成比例的资料。③反正弦转换适用于如发病率、感染率、病死率等服从二项分布的资料。④BOX-COX转换模型残差不符合正态分布。72.2数据的方差异质时数据的转换A.SAS统计分析程序------------------------------------------------------------------------------------------------------------------------------------------Title'三种不同添加剂对动物尿中氨氮排出量的影响';optionsps=500ls=100;dataaa;inputgroupx;x=log10(x/10);cards;130127135………;procUNIVARIATEnormal;varx;bygroup;procmeans;varx;bygroup;run;procmeansnoprintdata=aa;varx;bygroup;outputout=mx1css=ssN=Nstd=s;run;datamx2;setmx1;f=N-1;u=1/f;_type_=1;logs=2*f*log(s);run;procmeansnoprintdata=mx2;varssNfulogs_type_;outputout=mx3sum=t_sst_Nt_ft_ut_logsk;dataresult;setmx3;sc2=t_ss/t_f;fz=t_f*log(sc2)-t_logs;fm=1+1/3/(k-1)*(t_u-1/t_f);df=k-1;chisqr=fz/fm;prob=1-probchi(chisqr,df);procprintnoobs;varchisqrdfprob;run;------------------------------------------------------------------------------------
本文标题:SAS统计分析范例(2009.11.10)
链接地址:https://www.777doc.com/doc-2849054 .html