《应用多元统计分析SAS作业第三章.doc》由会员分享,可在线阅读,更多相关《应用多元统计分析SAS作业第三章.doc(22页珍藏版)》请在三一文库上搜索。
1、3-8假定人体尺寸有这样的一般规律,身高(X1),胸围(X2)和上半臂围(X3)的平均尺寸比例是6:4:1,假设为来自总体的随机样本,并设。试利用表3.4中男婴这一数据来检验其身高、胸围和上半臂围这三个尺寸变量是否符合这一规律(写出假设H0,并导出检验统计量)。表3.4 某地区农村两周岁婴儿的体格测量数据性别身高(X1)胸围(X2)上半臂围(X3)男7860.616.5男7658.112.5男9263.214.5男8159.014.0男8160.815.5男8459.514.0女8058.414.0女7559.215.0女7860.315.0女7557.413.0女7959.514.0女785
2、8.114.5女7558.012.5女6455.511.0女8059.212.5解:设。则检验三个变量是否符合规律的假设为。检验统计量为,由样本值计算得:,及,对给定显著性水平,利用软件SAS9.3进行检验时,首先计算p值:p=PF18.8574=0.0091948。因为p值=0.00919480.05,故接收,即认为男婴和女婴的测量数据无显著性差异。在这种情况下,可能犯第二类错误,且犯第二类错误的概率为。SAS程序及结果如下:proc iml;n=6;m=9; p=3;x= 78 60.6 16.5 ,76 58.1 12.5 ,92 63.2 14.5 ,81 59 14 ,81 60.8
3、 15.5 ,84 59.5 14 ;print x;ln=6 1 ;x0=(ln*x)/n; print x0;mx=i(n)-j(n,n,1)/n;a1=x*mx*x; print a1;y= 80 58.4 14 ,75 59.2 15 ,78 60.3 15 ,75 57.4 13 ,79 59.5 14 ,78 58.1 14.5 ,75 58 12.5 ,64 55.5 11 ,80 59.2 12.5 ;print y; lm=9 1 ;y0=(lm*y)/m; print y0;my=i(m)-j(m,m,1)/m;a2=y*my*y; print a2;a=a1+a2; xy
4、=x0-y0;ai=inv(a); print a ai;dd=xy*ai*xy; d2=(m+n-2)*dd;t2=n*m*d2/(n+m) ;f=(n+m-1-p)*t2/(n+m-2)*p);fa=finv(0.95,p,m+n-p-1);beta=probf(f,p,m+n-p-1,t2);print d2 t2 f beta;pp=1-probf(f,p,m+n-p-1);print pp; quit;3-12地质勘探中,在A,B,C三个地区采集了一些岩石,测量其部分化学成分,其数据见表3.5。假定这三个地区掩饰的成分遵从。(1)检验不全(2)检验;(3)检验;(4)检验三种化学成分
5、相互独立。表3.5 岩石部分化学成分数据SiO2FeOK2OA地区47.225.060.1047.454.350.1547.526.850.1247.864.190.1747.317.570.18B地区54.336.220.1256.173.310.1554.402.430.2252.625.920.12C地区43.1210.330.0542.059.670.0842.509.620.0240.779.680.04解:(1)检验假设,在H0成立时,取近似检验统计量为 统计量:。由样本值计算三个总体的样本协方差阵:进一步计算可得对给定显著性水平,利用软件SAS9.3进行检验时,首先计算p值:p=
6、P13.896916=0.3073394。因为p值=0.30733940.05,故接收,即认为方差阵之间无显著性差异。proc iml;n1=5;n2=4;n3=4;n=n1+n2+n3;k=3;p=3;x1=47.22 5.06 0.1,47.45 4.35 0.15,47.52 6.85 0.12,47.86 4.190.17,47.31 7.570.18;x2=54.33 6.22 0.12,56.17 3.310.15,54.4 2.430.22,52.62 5.920.12;x3=43.12 10.33 0.05,42.05 9.670.08,42.5 9.62 0.02,40.77
7、 9.680.04;xx=x1/x2/x3; /*三组样本纵向拼接*/mm1=i(5)-j(5,5,1)/n1;mm2=i(4)-j(4,4,1)/n2;mm=i(n)-j(n,n,1)/n;a1=x1*mm1*x1;print a1;a2=x2*mm2*x2;print a2;a3=x3*mm2*x3;print a3;tt=xx*mm*xx;print tt;/*总离差阵*/a=a1+a2+a3;print a;/*组内离差阵*/da=det(a/(n-k);/*合并样本协差阵*/da1=det(a1/(n1-1);/*每个总体的样本协差阵阵*/da2=det(a2/(n2-1);da3=
8、det(a3/(n3-1);m=(n-k)*log(da)-(4*log(da1)+3*log(da2)+3*log(da3);dd=(2*p*p+3*p-1)*(k+1)/(6*(p+1)*(n-k);df=p*(p+1)*(k-1)/2; /*卡方分布自由度*/kc=(1-dd)*m; /*统计量值*/print da da1 da2 da3 m dd df;p0=1-probchi(kc,df); /*显著性概率*/print kc p0;quit;(2) 提出假设。取检验统计量为,由样本值计算得:进一步计算得:对给定显著性水平,利用软件SAS9.3进行检验时,首先计算p值:p=PF32
9、.098939=0.0010831。因为p值=0.00108310.05,故否定,即认为A,B两地岩石化学成分数据存在显著性差异。在这种情况下,可能犯第一类错误,且犯第一类错误的概率为0.05。SAS程序及结果如下:proc iml;n=5;m=4; p=3;x= 47.22 5.06 0.1,47.45 4.35 0.15,47.52 6.85 0.12,47.86 4.190.17,47.31 7.570.18 ;ln=5 1 ;x0=(ln*x)/n; print x0;mx=i(n)-j(n,n,1)/n;a1=x*mx*x; print a1;y= 54.33 6.22 0.12,5
10、6.17 3.310.15,54.4 2.430.22,52.62 5.920.12 ;lm=4 1 ;y0=(lm*y)/m; print y0;my=i(m)-j(m,m,1)/m;a2=y*my*y; print a2;a=a1+a2; xy=x0-y0;ai=inv(a); print a ai;dd=xy*ai*xy; d2=(m+n-2)*dd;t2=n*m*d2/(n+m) ;f=(n+m-1-p)*t2/(n+m-2)*p);fa=finv(0.95,p,m+n-p-1);beta=probf(f,p,m+n-p-1,t2);print d2 t2 f beta;pp=1-pr
11、obf(f,p,m+n-p-1);print pp; quit;(3) 检验假设;因似然比统计量 ,本题中k-1=2,可以利用统计量与F统计量的关系,去检验统计量为F统计量:由样本值计算得:及 ,进一步计算得:对给定显著性水平,利用软件SAS9.3进行检验时,首先计算p值:p=PF18.390234=2.345110-6。因为p值=2.345110-60.05,故否定,即认为A,B,C三地岩石化学成分数据存在显著性差异。在这种情况下,可能犯第一类错误,且犯第一类错误的概率为0.05。proc iml;n1=5;n2=4;n3=4;n=n1+n2+n3;k=3;p=3;x1=47.22 5.06
12、 0.1,47.45 4.35 0.15,47.52 6.85 0.12,47.86 4.190.17,47.31 7.570.18;x2=54.33 6.22 0.12,56.17 3.310.15,54.4 2.430.22,52.62 5.920.12;x3=43.12 10.33 0.05,42.05 9.670.08,42.5 9.62 0.02,40.77 9.680.04;xx=x1/x2/x3; /*三组样本纵向拼接*/ln=51;lnn41;lnnn=131;x10=(ln*x1)/n1;x20=(lnn*x2)/n2;x30=(lnn*x3)/n3;xx0=(lnnn*x1
13、)/n1;mm1=i(5)-j(5,5,1)/n1;mm2=i(4)-j(4,4,1)/n2;mm=i(n)-j(n,n,1)/n;a1=x1*mm1*x1;a2=x2*mm2*x2;a3=x3*mm2*x3;tt=xx*mm*xx;print tt;/*总离差阵*/a=a1+a2+a3; print a;/*组内离差阵*/da=det(a);/*合并样本协差阵*/dt=det(tt);a0=da/dt;print da dt a0;b=sqrt(a0); print b;f=(n-k-p+1)*(1-b)/(b*p);df1=2*p;df2=2*(n-k-p+1);p0=1-probf(f,
14、df1,df2); /*显著性概率*/print f p0;f1=(tt1,1-a1,1)*(n-k)/(k-1)*a1,1);p1=1-probf(f1,k-1,n-k);fa=finv(0.95,k-1,n-k);print fa f1 p1;quit;(4) data chemical; input x1 x2 x3; cards;47.225.060.147.454.350.1547.526.850.1247.864.190.1747.317.570.1854.336.220.1256.173.310.1554.42.430.2252.625.920.1243.1210.330.054
15、2.059.670.0842.59.620.0240.779.680.04; proc iml; n1=5;n2=4;n3=4; n=n1+n2+n3;k=3; p=3; use chemical(obs=5); xa=x1 x2 x3; read all var xa into x11; print x11; use chemical(firstobs=6 obs=9); read all var xa into x22; print x22; use chemical(firstobs=10 obs=13); read all var xa into x33; print x33; xx=
16、x11/x22/x33; ln1=5 1 ; ln2=4 1; lnn=13 1; x110=(ln1*x11)/n1; print x110; x220=(ln2*x22)/n2; print x220; x330=(ln2*x33)/n3; print x330; xx0=(lnn*xx)/n; print xx0; mm1=i(n1)-j(n1,n1,1)/n1; mm2=i(n2)-j(n2,n2,1)/n2; a1=x11*mm1*x11; print a1; a2=x22*mm2*x22; print a2; a3=x33*mm2*x33; print a3; a=a1+a2+a3; print a; a0=det(a); print a da; a1=a1,1*a2,2*a3,3; print a1; v=a0/a1; print v; b=n-1.5-(p*p*p-3)/(3*p*p-3*3); df=0.5*(p*(p+1)-2*3); kc=-b*log(v); print b df; print kc; p0=1-probchi(kc,df); print p0;quit;22 / 22文档可自由编辑