1、SAS程序范例15.9 历年农村家庭出售畜产品水产品因子分析SAS数据集d1是历年农村家庭出售畜产品水产品(单位:公斤)。SAS数据集d1中,x1是猪肉,x2是牛肉,x3是羊肉,x4是家禽,x5是蛋类,x6是牛羊奶,x7是蚕茧,x8是水产品。本例用Factor过程对SAS数据集进行因子分析。Method是因子分析方法,本例用主分量法(Prin);Rotate是因子旋转方法,本例用方差最大旋转方法(Varimax)。%let d1=fjc.njcps;%let c1=x1 x2 x3 x4 x5 x6 x7 x8;%let i1=date;%macro factor(method,rotate,
2、x);%do i=1 %to 1;title factor &d&i method=&method rotate=&rotate nfactors=&x;proc factor data=&d&i method=&method nfactors=&x screerotate=&rotate out=a&i;var &c&i;proc print data=a&i(keep=date factor1 factor2 factor3 factor4 factor5);run;%let plotitop=gopts=cback=blue, color=white, cframe=yellow;%pl
3、otit(data=a&i, labelvar=&i&i, plotvars=factor2 factor1,colors=magenta);%end;%mend;%factor(prin,varimax,5);表5.9.1 d1关于变量x1x8的因子分析The FACTOR ProcedureInitial Factor Method: Principal ComponentsPrior Communality Estimates: ONEEigenvalues of the Correlation Matrix: Total = 8 Average = 1 Eigenvalue Diffe
4、rence Proportion Cumulative1 6.62225751 5.86967308 0.8278 0.82782 0.75258443 0.32425526 0.0941 0.92193 0.42832917 0.32907087 0.0535 0.97544 0.09925829 0.04288428 0.0124 0.98785 0.05637402 0.03328087 0.0070 0.99496 0.02309315 0.00926142 0.0029 0.99777 0.01383173 0.00956001 0.0017 0.99958 0.00427171 0
5、.0005 1.00005 factors will be retained by the NFACTOR criterion.The FACTOR ProcedureInitial Factor Method: Principal ComponentsFactor Pattern Factor1 Factor2 Factor3 Factor4 Factor5x1 0.90528 0.00866 0.41222 0.05426 -0.03823x2 0.97855 -0.13329 -0.05374 0.09498 -0.01536x3 0.92755 -0.27112 0.19365 0.1
6、0781 0.10219x4 0.98131 0.00391 -0.15594 -0.06162 0.04219x5 0.96856 0.01692 0.00737 -0.22269 0.09560x6 0.88951 -0.05390 -0.43879 0.10359 -0.01067x7 0.58555 0.80789 0.02501 0.05477 0.01280x8 0.97450 -0.07313 0.02191 -0.09248 -0.18176Variance Explained by Each FactorFactor1 Factor2 Factor3 Factor4 Fact
7、or56.6222575 0.7525844 0.4283292 0.0992583 0.0563740Final Communality Estimates: Total = 7.958803x1 x2 x3 x4 x5 x6 x7 x80.99392902 0.98747327 0.99342858 0.99287697 0.99718365 0.99751385 0.99933606 0.99706201表5.9.2 d1用最大方差旋转法的因子分析The FACTOR ProcedureRotation Method: VarimaxOrthogonal Transformation M
8、atrix 1 2 3 4 51 0.67277 0.64735 0.32558 0.13995 0.052282 -0.27899 -0.18827 0.94127 0.01350 0.023453 0.67779 -0.73293 0.05375 -0.00160 0.022734 0.10045 0.08853 0.06986 -0.91644 -0.370575 0.00735 -0.02162 0.01558 0.37465 -0.92676Rotated Factor Pattern Factor1 Factor2 Factor3 Factor4 Factor5x1 0.89119
9、 0.28791 0.32825 0.06209 0.07223x2 0.66852 0.70669 0.19664 0.04243 0.02586x3 0.84250 0.51690 0.06633 0.06532 -0.08811x4 0.54753 0.74244 0.31115 0.20991 0.03159x5 0.63023 0.59664 0.31760 0.37566 0.04513x6 0.32638 0.91698 0.22236 0.02553 0.00677x7 0.19109 0.21319 0.95645 0.04741 0.01797x8 0.68023 0.62
10、430 0.24033 0.15201 0.25245Variance Explained by Each FactorFactor1 Factor2 Factor3 Factor4 Factor53.2536847 3.0327200 1.3704988 0.2211132 0.0807867Final Communality Estimates: Total = 7.958803X1 X2 X3 X4 X5 X6 X7 X80.99392902 0.98747327 0.99342858 0.99287697 0.99718365 0.99751385 0.99933606 0.99706
11、201The FACTOR ProcedureRotation Method: VarimaxScoring Coefficients Estimated by RegressionSquared Multiple Correlations of the Variables with Each FactorFactor1 Factor2 Factor3 Factor4 Factor51.0000000 1.0000000 1.0000000 1.0000000 1.0000000Standardized Scoring Coefficients Factor1 Factor2 Factor3
12、Factor4 Factor5x1 0.79098227 -0.5559747 0.13469736 -0.737355 0.45526125x2 0.15789915 0.31157218 -0.0627429 -0.9606059 -0.1013109x3 0.62360717 -0.115901 -0.1650845 -0.3022728 -2.0732228x4 -0.2053734 0.29064057 0.00185812 0.87071991 -0.4639014x5 -0.1090969 -0.1574243 -0.0606125 2.71209425 -0.7316066x6
13、 -0.4805728 0.94775021 -0.0087927 -1.0078485 -0.2292305x7 -0.1433306 -0.1437271 1.08444468 -0.3938737 -0.3837445x8 0.04347886 0.06328619 -0.156105 -0.3348687 3.33992889表5.9.3 d1因子分析结果Obs date Factor1 Factor2 Factor3 Factor4 Factor51 1985 -1.10911 -0.25369 -2.18150 1.34490 -0.076972 1989 -1.32763 -0.
14、10876 -0.95605 0.38668 0.134393 1990 -1.23713 -0.18648 -0.34555 -0.41269 -0.226334 1991 -0.93756 -0.27903 0.14972 -0.00863 0.131115 1992 -0.85212 -0.50413 0.57510 0.13313 0.541296 1993 -0.34236 -0.81686 0.94898 -0.49273 0.112067 1994 -0.48363 -0.87127 1.65538 -0.17423 -0.750948 1995 -0.32079 -0.8668
15、2 1.33370 0.06509 -0.797469 1996 0.99320 -0.22694 -1.26173 -2.16888 -1.4753610 1997 1.08633 -0.19954 -1.11979 -0.78386 -0.9912911 1998 -0.33411 -0.00303 -0.02264 -0.55799 1.3612212 1999 0.97092 -0.24442 -0.45168 -1.04865 2.5432713 2000 1.45850 -0.64049 -0.40071 2.44493 -0.4447114 2001 1.43904 -0.234
16、51 0.81261 0.45093 -0.6583815 2002 1.30292 0.46521 0.45525 0.57572 1.4023716 2003 0.20324 2.17527 0.28375 0.51298 -0.4163017 2004 -0.50971 2.79549 0.52515 -0.26668 -0.38796图5.9.1 d1的(Factor2,Factor1)图(标号年份)5.10 地区城镇居民平均每人全年家庭收入因子分析SAS数据集d1是各地区城镇居民平均每人全年家庭收入来源(2004年)。x1是可支配收入,x2是总收入,x3是工薪收入,x4是经营净收入,
17、x5是财产性收入,x6是转移性收入。本例用Factor过程对SAS数据集进行因子分析。Method是因子分析方法,本例用主分量法(Prin);Rotate是因子旋转方法,本例用方差最大旋转方法(Varimax)。“%plotit(data=b&i, labelvar=x1, plotvars=factor1 x1,colors=magenta);%plotit(data=b&i, labelvar=&i&i, plotvars=factor1 x1,colors=magenta);”表示画出b&i的两个图,标号分别x1为与地区。%let d1=fjc.dqrjsr;%let c1=x1 x2
18、x3 x4 x5 x6;%let i1=d;%macro factor(method,rotate,x);%do i=1 %to 1;title factor &d&i method=&method rotate=&rotate nfactors=&x;proc factor data=&d&i method=&method nfactors=&x screerotate=&rotate out=a&i;var &c&i;proc sort data=a&i out=b&i;by factor1;proc print data=b&i(keep=d factor1 factor2 factor
19、3);run;%let plotitop=gopts=cback=blue, color=white, cframe=yellow;%plotit(data=b&i, labelvar=x1, plotvars=factor1 x1,colors=magenta);%plotit(data=b&i, labelvar=&i&i, plotvars=factor1 x1,colors=magenta);%end;%mend;%factor(prin,varimax,3);表5.10.1 d1关于变量x1x6的因子分析The FACTOR ProcedureInitial Factor Metho
20、d: Principal ComponentsPrior Communality Estimates: ONEEigenvalues of the Correlation Matrix: Total = 6 Average = 1Eigenvalue Difference Proportion Cumulative1 3.96782888 2.89327101 0.6613 0.66132 1.07455786 0.54100608 0.1791 0.84043 0.53355178 0.11044110 0.0889 0.92934 0.42311068 0.42215987 0.0705
21、0.99985 0.00095081 0.00095081 0.0002 1.00006 0.00000000 0.0000 1.00003 factors will be retained by the NFACTOR criterion.Factor PatternFactor1 Factor2 Factor3x1 0.98304 -0.16578 -0.00417x2 0.97755 -0.19264 -0.03349x3 0.87138 -0.34573 -0.30864x4 0.45123 0.80966 0.06503x5 0.68638 0.48148 -0.27725x6 0.
22、78219 -0.05532 0.59670Variance Explained by Each FactorFactor1 Factor2 Factor33.9678289 1.0745579 0.5335518Final Communality Estimates: Total = 5.575939x1 x2 x3 x4 x5 x60.99386288 0.99383996 0.97409668 0.86339456 0.77980878 0.97093565表5.10.2 d1用最大方差旋转法的因子分析The FACTOR ProcedureRotation Method: Varima
23、xOrthogonal Transformation Matrix 1 2 31 0.78941 0.40202 0.463912 -0.41734 0.90568 -0.074673 -0.45017 -0.13466 0.88273Rotated Factor Pattern Factor1 Factor2 Factor3x1 0.84708 0.24562 0.46474x2 0.86716 0.22303 0.43832x3 0.97111 0.07876 0.15762x4 -0.01098 0.90594 0.20628x5 0.46571 0.74933 0.03773x6 0.
24、37194 0.18399 0.89373Variance Explained by Each FactorFactor1 Factor2 Factor32.7679157 1.5323486 1.2756742Final Communality Estimates: Total = 5.575939x1 x2 x3 x4 x5 x60.99386288 0.99383996 0.97409668 0.86339456 0.77980878 0.97093565The FACTOR ProcedureRotation Method: VarimaxScoring Coefficients Es
25、timated by RegressionSquared Multiple Correlations of the Variables with Each FactorFactor1 Factor2 Factor31.0000000 1.0000000 1.0000000Standardized Scoring CoefficientsFactor1 Factor2 Factor3x1 0.26347368 -0.039074 0.11958235x2 -0.6691815 -0.4043698 3.27897357x3 1.29142544 0.13631122 -2.7841675x4 -
26、0.1980202 0.74119647 -0.1663793x5 0.21648316 0.55725461 -0.5213599x6 0 0 0表5.10.3 d1因子分析结果(按Factor1排序)Obs d Factor1 Factor2 Factor31 Heilongjiang -1.17159 0.06134 0.475702 Jilin -1.07944 0.69307 0.195493 Guizhou -1.01586 0.04999 0.001994 Ningxia -0.98302 -0.18836 0.237965 Qinghai -0.89348 -0.74893 0
27、.559226 Inner Mongolia -0.75903 0.74000 -0.192187 Henan -0.72128 -0.06094 0.127058 Anhui -0.65367 0.17482 -0.316009 Jiangxi -0.64680 -0.21335 -0.1847710 Liaoning -0.57474 -0.66795 0.5411911 Hebei -0.57013 -0.46904 0.2954012 Sichuan -0.53594 0.34736 -0.2163613 Gansu -0.36463 -0.69588 -0.5045614 Jiang
28、su -0.34469 0.94388 1.2134715 Shaanxi -0.29071 -0.64101 -0.3378316 Xinjiang -0.23192 -0.53125 -0.7292217 Tianjin -0.15457 -0.06326 2.1214618 Hunan -0.13430 -0.12676 -0.3359019 Hainan -0.12742 0.23593 -0.7918520 Yunnan -0.08061 1.19116 -0.3511921 Shanxi -0.07836 -0.24479 -0.7695222 Hubei -0.06154 -0.
29、49023 -0.6004323 Guangxi 0.09846 -0.15394 -0.4153924 Chongqing 0.21982 -0.91288 0.1358525 Fujian 0.51892 1.62552 0.0594326 Shandong 0.82041 -0.62905 -1.1031227 Zhejiang 1.21550 3.23709 0.3319528 Tibet 1.79656 -1.94695 -2.4871429 Beijing 1.95068 -1.67416 2.7069630 Guangdong 2.30823 1.57961 -1.4105931
30、 Shanghai 2.54515 -0.42102 1.74293图5.10.1 d1的(Factor2,X1)图(标号X1)5.11 地区生产总值因子分析SAS数据集是地区生产总值(2004年),共有变量19个,分为4组。第一组变量x1-x11;x1是地区生产总值(单位:亿元),x2是第一产业,x3是第二产业,x4是工业,x5是建筑业,x6是第三产业,x7是交通运输仓储邮电通信业,x8是批发和零售贸易餐饮业,x9是金融,保险业,x10是房地产业,x11是其他行业。第二组变量x12-x14,代表地区生产总值构成(%);x12是第一产业,x13是第二产业,x14是第三产业。第三组变量x15-x
31、18,代表地区生产总值指数(上年=100);x15是地区生产总值,x16是第一产业,x17是第二产业,x18是第三产业。第四组是变量x19,为人均地区生产总值(元/人)。SAS数据集d1对变量x1-x11用Factor过程对SAS数据集进行因子分析;SAS数据集d2对变量x1 x2 x3 x6用Factor过程对SAS数据集进行因子分析。Method是因子分析方法,本例用主分量法(Prin);Rotate是因子旋转方法,本例用方差最大旋转方法(Varimax)。“%plotit(data=b&i, labelvar=x1, plotvars=factor1 x1,colors=magenta);%plotit(data=b&i, labelvar=&i&i, plotvars=factor1 x1,colors=magenta);”表示画出b&i的两个(Factor1,x1)图,标号分别x1为与地区。“%plotit(data=b&i, la
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1