Model y1 y2 y3=/nouni; Manova h=intercept; Run;
练习2.2
令A=(a1,a2,…, am-1, am),B=diag(b1,b2,…bm) 对X作线性变换:Z=A+BX
则Z=A+BX, Vz=BVXB’ Vz-1=( BVXB’)-1= (B’) -1VX-1B-1 Tz=
n1n2(Zn1?n21-Z-1
2)’ Vz(Z1-Z2)=
n1n2(BXn1?n21-BX -1
2)’(B’)
VX-1B-1(BX1-BX2)=
n1n2(Xn1?n21-X-1-1-1
2)’B’(B’)VXBB(X1-X2)=
n1n2(X1-X2)’ VX-1 (X1-X2)= TX
n1?n2得证。 2-3
Title ‘hotelling T2 检验与t检验’; Data ex2-3; Input x@@; G=1;
If _n_>14 then g=2; Cards;
2.90 5.41 5.48 4.60 4.03 5.10 4.97 4.24 4.36 2.72 2.37 2.09 7.10 5.92 8.79 3.14 6.46 3.72 6.64 5.60 4.57 7.71 4.99 4.01 ;
Proc ttest; Var x; Class g; Run; Proc glm; Class g;
Model x=g/nouni; Manova h=g; Run; 2-4
Title ‘多元方差分析:成组分析’; DATA ex2_4;
Input h w b sex $ @@; CARDS;
171.1 58.5 81.0 M 152.0 44.8 74.0 F ………..
164.2 46.5 73.0 M
;
PROC GLM; CLASS sex;
MODEL h w b=sex/MOUNI; MANOVA H=sex; RUN; 练习2.5
TITLE’多元方差分析:区组设计’; DATA ex2_5;
INPUT x y a b@@; CARDS;
175 155 1 1 175 110 2 1 170 110 3 1 170 90 4 1 ……… 105 75 1 10 113 75 2 10 113 75 3 10 113 75 4 10 ;
PROC GLM; CLASS a b;
MODEL x y=a b /NOUNI; MANOVA H=a b; RUN; 练习2.6
TITLE’多元方差分析:析因设计’; DATA ex2_6;
INPUT x1 x2 x3 a b @@; CARDS;
6.5 9.5 4.4 1 1 6.9 9.1 5.7 2 1 ... ... ...
6.8 8.5 3.4 1 2 7.6 9.2 1.9 2 2 ;
PROC GLM; CLASS a b;
MODEL x1 x2 x3=a b a*b; RUN;
第三章答案:
3-1答:设两样本Y1、Y2,样本含量分别为n1、n2,均数分别为Y1、Y2,标准差分别为s1、s2。
不妨设回归方程为:Y=a+bg
? 则当g=1时,Y1=a+bg=Y1;当g=0时,Y2=a=Y2。 故有b=Y2-Y1。 此
时
??????S
Y.s=
?2?(Y?Y)n?2=
?2?2(Y?Y)?(Y?Y?11?2?2)n?2n1(1?=
(n1?1)s1?(n2?1)s2n?222=
?(g?g)2=
n1n2 n则 tb=
n1(1?g)2?n1(0?g)2=
n1n1)2?n2(0?)2=
n1?n2n1?n2Y2?Y1b==t
22sb(n1?1)s1?(n2?1)s2n1n2/n?2n1?n2得证。
均数 2.4025 2.6850 3.0975 3-2答:TITLE’回归方程F检验与均数之方差分析’; DATA ex3_2;
INPUT y g g1 g2 @@; CARDS;
2.62 1 0 0 2.82 2 1 0 2.91 3 0 1 2.23 1 0 0 2.76 2 1 0 3.02 3 0 1 2.36 1 0 0 2.43 2 1 0 3.28 3 0 1 2.40 1 0 0 2.73 2 1 0 3.18 3 0 1 PROC REG;
MODEL y=g1 g2; RUN;
PROC ANOVA; CLASS g; MODEL y=g; RUN;
3-3答:TITLE’方差分析模型与线性回归模型’ DATA ex3_3; DO b=1 to 5; DO a=1 to 4; INPUT x @@; OUTPUT; END; END;
CARDS;
0.80 0.36 0.17 0.28 0.74 0.50 0.42 0.36 0.31 0.20 0.38 0.25 0.48 0.18 0.44 0.22 0.76 0.26 0.28 0.13 ;
PROC ANOVA; CLASS a b; MODEL x=a b; RUN;
PROC GLM; CLASS a b; MODEL x=a b; RUN;
3-4答:TITLE”筛选自变量的最优子集”; DATA ex3_4;
INPUT age weight runtime rstpulse maxpulse oxy; CARDS;
44 89.47 11.37 62 178 182 44.609
………
52 82.78 10.50 53 170 172 47.467
;
PROC REG RSQUARE MSE CP AIC ADJRSQ SELECT=2;
MODEL oxy=age weight runtime rstpulse runpulse maxpulse; run; 练习3.5
X1 X2 X3 X4 Y X1
1.000000 0.567021 0.209841 -0.043467 0.604392 X2
0.567021 1.000000 0.207706 0.741491 0.956619 X3
0.209841 0.207706 1.000000 0.100186 0.22781 X4 Y -0.043467 0.604392 0.741491 0.956619 0.100186 0.227810 1.000000 0.765506 0.765506 1.000000
以(2,2)为主元作消去变换,结果如下:
X1 X2 X3 X4 Y X1
0.678487 0.567021 0.092067 -0.463908 0.061969 X2
-0.567021 1.000000 -0.207706 -0.711491 -0.956619 X3
0.092067 0.207706 0.956858 -0.053826 0.029114 X4 Y -0.463908 0.061969 0.741491 0.956619 -0.053826 0.029114 0.450191 0.056182 0.056182 0.084880
以(4,4)为主元作消去变换,结果如下:
X1 X2 X3 X4 Y