SAS程序范例2.docx
《SAS程序范例2.docx》由会员分享,可在线阅读,更多相关《SAS程序范例2.docx(13页珍藏版)》请在冰豆网上搜索。
SAS程序范例2
5.13矿物数据典型相关分析
SAS数据集是某矿区下部矿矿物数据。
x1是铂,x2是钯,y1是铜,y2镍。
用Cancorr过程进行典型相关分析。
一组变量为(x1x2),另一组变量为(y1y2)。
(v1w1)是第一对典型变量,(v2w2)是第二对典型变量。
“%plotit(data=a&i,labelvar=x1,
plotvars=w1v1,colors=red);
%plotit(data=a&i,labelvar=y1,
plotvars=w1v1,colors=magenta);”
表示画出(w1,v1)的两个图,分别标出x1与y1。
%letd1=fjc.ms10d1;
%letc1=x1x2;
%letb1=y1y2;
%macrocancorr;
%doi=1%to1;
title"cancorr&&d&i";
proccancorrdata=&&d&iout=a&i;
var&&c&i;
with&&b&i;
run;
procprintdata=a&i(keep=v1w1v2w2);
run;
%letplotitop=gopts=cback=blue,color=white,cframe=yellow;
%plotit(data=a&i,labelvar=x1,
plotvars=w1v1,colors=red);
%plotit(data=a&i,labelvar=y1,
plotvars=w1v1,colors=magenta);
%end;
%mend;
%cancorr;
表5.13.1d1的典型相关系数及显著性检验
TheCANCORRProcedure
CanonicalCorrelationAnalysis
AdjustedApproximateSquared
CanonicalCanonicalStandardCanonical
CorrelationCorrelationErrorCorrelation
10.8946180.8894690.0391560.800341
20.009496.0.1960980.000090
TestofH0:
Thecanonicalcorrelationsinthe
EigenvaluesofInv(E)*Hcurrentrowandallthatfollowarezero
=CanRsq/(1-CanRsq)
LikelihoodApproximate
EigenvalueDifferenceProportionCumulativeRatioFValueNumDFDenDFPr>F
14.00854.00841.00001.00000.1996413714.24446<.0001
20.00010.00001.00000.999909830.001240.9633
MultivariateStatisticsandFApproximations
S=2M=-0.5N=10.5
StatisticValueFValueNumDFDenDFPr>F
Wilks'Lambda0.1996413714.24446<.0001
Pillai'sTrace0.800430808.01448<.0001
Hotelling-LawleyTrace4.0086203222.76426.595<.0001
Roy'sGreatestRoot4.0085301448.10224<.0001
NOTE:
FStatisticforRoy'sGreatestRootisanupperbound.
NOTE:
FStatisticforWilks'Lambdaisexact.
表5.13.2d1的典型相关分析
TheCANCORRProcedure
CanonicalCorrelationAnalysis
RawCanonicalCoefficientsfortheVARVariables
V1V2
x1-0.1054235865.1216636294
x22.5630585828-1.945443218
RawCanonicalCoefficientsfortheWITHVariables
W1W2
y12.6083711454-10.72223803
y210.20545216715.508887379
TheCANCORRProcedure
CanonicalCorrelationAnalysis
StandardizedCanonicalCoefficientsfortheVARVariables
V1V2
x1-0.02631.2754
x21.0161-0.7712
StandardizedCanonicalCoefficientsfortheWITHVariables
W1W2
y10.3231-1.3282
y20.75141.1419
TheCANCORRProcedure
CanonicalStructure
CorrelationsBetweentheVARVariablesandTheirCanonicalVariables
V1V2
x10.60460.7965
x20.99980.0206
CorrelationsBetweentheWITHVariablesandTheirCanonicalVariables
W1W2
y10.8354-0.5497
y20.97170.2364
CorrelationsBetweentheVARVariablesandtheCanonicalVariablesoftheWITHVariables
W1W2
x10.54090.0076
x20.89440.0002
CorrelationsBetweentheWITHVariablesandtheCanonicalVariablesoftheVARVariables
V1V2
y10.7473-0.0052
y20.86930.0022
表5.13.3d1的典型变量
ObsV1V2W1W2
1-0.89636-0.48855-0.686161.18193
2-0.39007-0.570340.417191.24319
3-1.37491-0.52865-1.91082-0.67914
4-1.37596-0.47743-0.762140.91962
5-1.09930-0.43535-0.812020.55009
60.524520.348780.343500.39691
7-0.47013-0.35832-0.80746-0.61787
8-0.802014.73356-0.835830.07333
90.00209-0.01093-0.297190.15757
10-0.150640.05458-0.451410.21693
110.278760.03116-0.72921-0.93954
120.49118-0.482990.52837-0.93763
130.526630.246350.651950.27819
141.237960.008921.420780.56539
150.61090-0.170530.391111.35042
160.78610-0.101850.73020-0.04347
170.322640.350770.395670.18246
180.273490.287241.38229-2.72403
190.56280-0.285270.60662-1.25930
201.611880.229271.416211.73335
211.615040.075621.83811-1.15017
221.95984-0.740670.96267-0.42450
230.53296-0.060950.801611.38679
24-1.47427-0.60448-1.246320.03695
25-0.95395-0.14234-1.272410.14417
26-1.39843-0.61163-1.19188-0.76147
27-0.95078-0.29599-0.88343-0.88018
图5.13.1d1的(W1,V1)图(标号X1)
图5.13.2d1的(W1,V1)图(标号Y1)
5.14各地区接待入境旅游人数典型相关分析
SAS数据集是各地区接待入境旅游人数。
SAS数据集d1中,x1是1995年旅游人数,x2是2000年旅游人数,x3是2003年旅游人数,x4是2004年旅游人数;SAS数据集d2中,y1是1995年外国人旅游人数,y2是2000年外国人旅游人数,y3是2003年外国人旅游人数,y4是2004年外国人旅游人数。
用Cancorr过程进行典型相关分析。
一组变量为(x1x2x3x4),另一组变量为(y1y2y3y4)。
(v1w1)是第一对典型变量,(v2w2)是第二对典型变量,(v3w3)是第三对典型变量,(v4w4)是第四对典型变量。
分别画出(d,v1)、(d,w1)、(d,v2)、(d,w2)图,标号为地区。
%letd1=fjc.dqlyrs;
%letc1=x1-x4;
%letb1=y1-y4;
%macrocancorr;
%doi=1%to1;
title"cancorr&&d&i";
proccancorrdata=&&d&iout=a&i;
var&&c&i;
with&&b&i;
run;
procprintdata=a&i(keep=dv1w1v2w2);
run;
procgplotdata=a&i;
plotd*v1/cframe=yellow;
plotd*w1/cframe=cyan;
plotd*v2/cframe=pink;
plotd*w2/cframe=orange;
symbolv=dotc=redpointlabel;
run;
%end;
%mend;
%cancorr;
表5.14.1d1的典型相关系数及显著性检验
TheCANCORRProcedure
CanonicalCorrelationAnalysis
AdjustedApproximateSquared
CanonicalCanonicalStandardCanonical
CorrelationCorrelationErrorCorrelation
10.9868940.9837370.0048350.973960
20.9727110.9711860.0099970.946166
30.8005500.7809490.0666870.640880
40.658403.0.1051980.433494
TestofH0:
Thecanonicalcorrelationsinthe
EigenvaluesofInv(E)*Hcurrentrowandallthatfollowarezero
=CanRsq/(1-CanRsq)
LikelihoodApproximate
EigenvalueDifferenceProportionCumulativeRatioFValueNumDFDenDFPr>F
137.402819.82720.65020.65020.0002851957.101667.849<.0001
217.575615.79100.30550.95570.0109522133.62956.127<.0001
31.78461.01940.03100.98670.2034437414.60448<.0001
40.76520.01331.00000.5665059019.131250.0002
MultivariateStatisticsandFApproximations
S=4M=-0.5N=10
StatisticValueFValueNumDFDenDFPr>F
Wilks'Lambda0.0002851957.101667.849<.0001
Pillai'sTrace2.9944999518.6116100<.0001
Hotelling-LawleyTrace57.5281553775.871638.364<.0001
Roy'sGreatestRoot37.40278297233.77425<.0001
NOTE:
FStatisticforRoy'sGreatestRootisanupperbound.
表5.14.2d1的典型相关分析
TheCANCORRProcedure
CanonicalCorrelationAnalysis
RawCanonicalCoefficientsfortheVARVariables
V1V2V3V4
x10.0176483864-0.018438494-0.072065034-0.036908372
x2-0.004138819-0.0164834630.03924026980.0378485365
x3-0.0440675710.0168780218-0.067099874-0.010344513
x40.03148829690.00857747630.0490970681-0.003744316
RawCanonicalCoefficientsfortheWITHVariables
W1W2W3W4
y10.0268298418-0.023770114-0.069220296-0.124811032
y.025*******
y.025*******
y40.04161347330.00901485850.08661633550.0026487349
TheCANCORRProcedure
CanonicalCorrelationAnalysis
StandardizedCanonicalCoefficientsfortheVARVariables
V1V2V3V4
x12.0275-2.1182-8.2789-4.2401
x2-0.8954-3.56608.48938.1882
x3-9.60323.6781-14.6224-2.2543
x48.99502.450314.0252-1.0696
StandardizedCanonicalCoefficientsfortheWITHVariables
W1W2W3W4
y11.0219-0.9054-2.6365-4.7539
y2-0.5954-1.16081.45046.1246
y3-3.60221.5443-7.6390-1.4531
y43.97990.86228.28400.2533
TheCANCORRProcedure
CanonicalStructure
CorrelationsBetweentheVARVariablesandTheirCanonicalVariables
V1V2V3V4
x10.58100.3565-0.38760.6206
x20.49810.3942-0.33520.6958
x30.46610.5182-0.34140.6306
x40.52740.5121-0.31050.6026
CorrelationsBetweentheWITHVariablesandTheirCanonicalVariables
W1W2W3W4
y10.87380.0805-0.43440.2031
y20.81000.1712-0.41840.3736
y30.68990.5452-0.39630.2642
y40.77250.4984-0.30970.2429
CorrelationsBetweentheVARVariablesandtheCanonicalVariablesoftheWITHVariables
W1W2W3W4
x10.57340.3468-0.31030.4086
x20.49160.3834-0.26840.4581
x30.46000.5040-0.27330.4152
x40.52050.4981-0.24860.3968
CorrelationsBetweentheWITHVariablesandtheCanonicalVariablesoftheVARVariables
V1V2V3V4
y10.86240.0783-0.34780.1337
y20.79940.1665-0.33490.2459
y30.68080.5303-0.31720.1740
y40.76230.4848-0.24790.1599
表5.14.3d1的典型相关分析结果
ObsDV1V2W1W2
1Beijing3.50032-2.803893.45586-2.82174
2Tianjin-0.768790.22625-0.959630.31867
3Hebei-0.04681-0.186320.00253-0.21539
4Shanxi-0.28237-0.12460-0.39521-0.29193
5InnerMongolia0.305100.013030.56018-0.03581
6Liaoning-0.576830.57580-0.679970.70734
7Jilin-0.48922-0.19005-0.45423-0.31409
8Heilongjiang-0.981500.24046-1.188460.34949
9Shanghai2.256881.753752.272772.12562
10Jiangsu-0.251882.157200.052092.10248
11Zhejiang0.704492.158600.703511.81583
12Anhui-0.29929-0.05501-0.31896-0.10866
13Fujian-0.98139-0.49088-0.70698-0.11379
14Jiangxi-0.52130-0.04863-0.57200-0.26682
15Shandong0.070780.14063-0.008640.42451
16Henan0.07757-0.40429-0.30917-0.38144
17Hubei-0.32718-0.20418-0.43890-0.15484
18Hunan0.42951-0.511190.41897-0.15033
19Guangdong1.721512.237041.606252.08179
20Guangxi0.30715-0.862040.54000-0.60313
21Hainan-0.77586-0.74224-0.73227-0.09372
22Sichuan0.76562-0.035330.58319-0.17655
23Guizhou-0.20683-0.39726-0.39349-0.49691
24Yunnan-1.06109-0.28876-0.94736-0.45790
25Tibet-0.62581-0.37420-0.57004-0.53245
26Shaanxi0.19275-0.688280.47605-1.10330
27Gansu-0.39091-0.31438-0.43389-0.44805
28Qinghai-0.73687-0.19395-0.69015-0.31613
29Ningxia-0.74773-0.17897-0.69357-0.30441
30Xinjiang-0.26001-0.40831-0.17848-0.53832
图5.14.1d1的(D,V1)图(标号地区)
图5.14.2d1的(D,W1)图(标号地区)
图5.14.3d1的(D,V2)图(标号地区)
图5.19.4d1的(D,W2)图(标号地区)