X1 X2 X3 X4 Y 0.200144 1.331105 0.036601 -1.030469 0.119863 -1.331105 2.221279 -0.296361 -1.647059 -0.864084 0.036601 0.296361 0.950422 -0.119563 0.035831 1.030469 0.119863 -1.647059 0.864084 0.119563 0.035831 2.221279 0.124796 -0.124796 0.077869
以(1,1)为主元作消去变换,结果如下:
X1 X2 X3 X4 Y X1 X2
4.988925 -6.640783 -6.640783 11.060858 -0.182600 -0.053302 5.140932 -8.490180 -0.597987 -0.068100 X3 X4 Y
0.182600 5.140932 0.597987 0.053302 -8.490180 0.068100 6.943739 -0.068600 0.013944 0.068600 7.518850 0.741004 0.0139441 -0.741004 0.006192
以(2,2)为主元作消去变换,结果如下:
X1 X2 X3 X4 Y
练习3.6
X1
1.001893 -0.600386 -0.214602 0.043548 -0.638873 X2
0.600386 0.090409 0.004819 0.767588 0.006157 X3
0.214602 0.004819 6.943996 0.109514 1.001891 X4
0.043548 -0.767588 -0.109514 1.001891 -0.793277 Y
0.638873 0.006157 0.014272 0.793277 0.006611 因b0?y?b1x1?b2x2???bmxm,U??????bl?iiyxi,故:
?l^r^?yyyylyylyy???(yi?1ni?y)(yi?y)n^??^???(yi?1n?y)(b0?b1xi1???bmxim?y)lyyU
lyy??(yi?y)i?1?[(y?y)?b(xijnmij?xj)]???i?1j?1?b[?(y?y)(xjij?1j?1mm?ij?xj)]
?lYY?UlYY?U?bl?j?1mjyxilYY?U?U?R lYY得证。
练习3.7
TITLE”小学生的身高、年龄和体重的数据”; DATA ex3_7;
INPUT sex $ age height weight @@;
CARDS;
f 143 56.3 85.0 f 155 62.3 105.0 f 153 63.3 108.0 ... ... ...
m 164 61.5 140.0 m 167 62.0 107.5 m 151 59.3 87.0 ;
PROC REG OUTEST=est1 OUTSSCP=sscp1; BY sex;
EQ1:MODEL weight=height; EQ2:MODEL weight=height age; PROC PRINT DATA=sscp1; TITLE2”sscp类型的数据集”; PROC PRINT DATA=est1; TITLE2”est 类型的数据集”; RUN;
练习3.8
TITLE’逐步回归’;
OPTION LINESIZE=120; DATA ex3_8(TYPE=CORR); _TYPE_=”CORR”;
INPUT _name_$ x1 x2 x3 x4 x5 y; CARDS;
x1 1 . . . x2 -0.039603 1 .
. x3 -0.041057 0.965977 1 . x4 -0.034447 0.921631 0.938234 1 x5 0.047992 0.908298 0.915332 0.966865 y 0.037969 0.855474 0.883853 0.863441 ;
RUN;
PROC STEPWISE;
MODEL Y=x1 x2 x3 x4 x5/SLENTRY=0.15 SLSTAY=0.14 DETAILS; RUN;
练习3.9
TITLE’所有子集的回归’; DATA ex3_9;
INPUT x1 x2 x3 x4 x5 @@; CARDS;
289 101 109 107 73 3900 268 103 95 101 73 3200 ... ... ...
285 109 102 104 88 3800 276 106 193 103 74 3650
. . . .
1 0.850318 . . . . . 1
;
PROC REG;
MODEL y=x1-x5/SELECTION=RSQUARE ADJRSQ CP MSE AIC BEST=10; RUN; 练习4.1
TITLE’主成分分析’; DATA ex4-1; INPUT x1-x12; CARDS;
46 55 126 51 75.0 25 72 6.8 489 27 8 360 ... … …
48 68 100 45 53.6 23 70 7.2 522 28 9 352 … … … ;
PROC PRINCOMP; RUN;
练习4.2
??1????令?I3?A?????1???0,解得:?1=1+2? ?2=1?? ?3?1??
??????1?x1??0??3????1?2?I?Ax?0?对于?1=1+2?有?求得其特征向量为???????2????3??x??0??3???333? ??3??x1??0?????1??I?A?对于?2=1??有???????x2???0?求得其特征向量为K1?1?K2?2?K1,K2不同时为0?
?x??0??3???其中?1=?0???22??22??=,?1??22???0?2?? 2??练习4-3
TITLE’主成分分析’
OPTION LINESIZE=120; DATA ex4-3;
INPUT mz $ x1-x8; CARDS
满族 16.01 6.06 62.73 494.5 17.02 139.3 7.2 8.34 … … …
毛南族 25.83 7.14 117.30 220.0 29.13 81.0 20.3 3.76 ;
;
PROC PRINCOMP N=4 OUT=COMP;
RUN
PROC SORT DATA=COMP; BY PRIN1 RUN
PROC PRINT ID mz
VAR PRIN1 PRIN2 X1-X8
TITLE’用第一主成分对42个少数民族进行排序‘;
;
RUN;
练习4.4
TITLE’从方差协方差矩阵出发进行主成分分析和因子分析;
DATA ex4-4(TYPE=COV)OUTPUT a(TYPE=CORR); -TYPE-=’COV\\
INPUT –name-$ x1-x14; CARDS;
7.033 2.168 3.540 1.213 1.681 1.498 1.276 2.718 2.827 9.358 8.889 5.154 2.227 5.213
4.89 2.874 0.709 1.276 1.178 1.161 1.765 1.799 8.043 7.611 5.68 2.155 2.939
30.53 5.336 4.638 5.359 5.864 5.713 4.423
2.678 1.254 1.543 1.538 1.512
3.107 1.6 1.851 1.74
4.028 2.164 1.479
3.86 1.197
5.241
PROC PRINCOMP; RUN;
5-1
答:主成分分析与因子分析都是研究多个变量间的互依性,但出发点不同。主成分分析是寻找出能反映原变量信息的综合指标,是对变量共性的一种提取,主成分的个数与原变量数相同,贡献大的主成分常用于评价,或进一步分析,贡献小的主成分常用于判断变量间的关系。因子分析是寻找出能解释原变量的公共因子,这些公共因子互相独立代表某一方面的特性,