Why

w=cov(p);
>> [e,v]=eig(w)
e =
    0.1745    0.0464   -0.8247   -0.0598    0.3313   -0.4170
   -0.0163   -0.0029    0.4217   -0.6721    0.4985   -0.3488
    0.0065    0.0055    0.3182    0.7380    0.4817   -0.3491
    0.8184    0.1726    0.0654   -0.0059    0.2877    0.4618
   -0.2120   -0.7656   -0.1396    0.0027    0.4090    0.4268
   -0.5044    0.6180   -0.1302   -0.0002    0.3995    0.4325

v =
    0.1526         0         0         0         0         0
         0    0.1992         0         0         0         0
         0         0    0.3226         0         0         0
         0         0         0    0.4572         0         0
         0         0         0         0    1.1332         0
         0         0         0         0         0    3.7352
>>result= p*e
result =
    0.2287    0.2175    0.2303    0.6621   -0.2899    1.8096
    0.5734   -0.5691    0.1343    0.0469   -0.9495   -1.3500
    0.4247   -0.2699   -0.0565   -0.7086   -2.7841    0.1246
    0.7863   -0.2544   -0.4901    0.3537   -0.4877   -0.4106
    0.6236   -0.0313   -0.0128    0.6155    0.4366    0.7842
    0.0080   -0.1394    0.1016   -0.3495   -0.3640   -1.1998
   -0.3532   -0.2878    0.6607   -0.0892   -2.2474   -1.0365
   -0.0340   -0.7334   -0.8750   -0.7119   -0.4259    0.8986
   -0.4590   -0.9110    0.3774   -0.9194   -0.6251   -3.3897
    0.0704   -0.1649    0.4111    0.3366    0.1572   -3.4531
   -0.0672   -0.1591    0.5883    0.5833    0.0237   -1.0316
    0.0396   -0.3472    0.6628   -1.4935   -2.1219   -0.8291
    0.3935   -0.5296   -0.7720    0.3591   -2.0459   -1.5344
    0.0805   -0.2446    0.7823    1.7032   -1.7042   -2.1538
    0.1575   -0.5518    0.2999   -0.5985    1.8450    0.2156
   -0.5680   -0.7977   -0.6141    0.6093   -0.1471    2.1642
    0.6503    0.0750    0.6337   -0.3597   -0.2268   -1.6013
    0.0814   -0.1168   -0.9051    0.4303   -0.8855   -1.1868
   -0.6151   -0.3798    0.8338    1.0057    0.0199    1.1357
   -0.2512   -0.9218   -0.4521    0.5877    0.1416    0.9573
    0.1688    0.0512   -0.8082    1.2628    0.5917   -2.0017
    0.1186   -0.1453    0.4028   -0.6265    0.7335    0.6471
   -0.6599    0.7454   -0.7825    0.7373    0.7285    0.0897
    0.3809    0.1680    0.3292   -0.4212   -0.0440    2.5180
   -0.0563   -0.7064    0.7727    1.0198   -0.0937   -1.6085
   -0.2219   -0.3412    0.4504    0.9396   -1.4414   -0.0787
   -0.4948   -0.5016   -0.4580    0.9469    0.3262   -2.9517
   -0.2585    0.4904    0.4591   -0.0827    0.8402   -0.7823
    0.1345    0.2634   -0.7183    0.1636   -0.3524   -2.7627
   -0.2376    0.3184    0.8414    1.0305   -0.2952   -2.8581
   -0.0686   -0.0762   -1.0825    0.0314   -0.0085   -1.6254
   -0.8539   -0.0449    0.4577   -0.6847    0.6747   -1.8761
   -0.6910   -0.2791    0.1706    0.9146   -0.5454    2.9810
   -0.2720    0.4703    0.7879    0.1592    1.4822    0.2725
    0.1616    0.1510   -0.1161   -0.2522   -2.7273    0.9014
    0.2939    0.0516    0.3815   -0.3118    0.5856   -0.6158
    0.0591   -0.5864   -0.1913    0.5617    0.7977    1.6287
    0.1761    0.0519   -0.6685   -0.2763    0.7225    2.7530
    0.5016   -0.0704   -0.2156   -0.0261    0.5904    1.5914
   -0.0915    0.0738   -0.6434   -0.9216    1.1584    1.7949
   -0.0171    0.3464    0.5986    0.9876    1.4701    3.3343
    0.5885   -0.2531    0.2394   -0.4505    2.2241    0.5813
   -0.3220   -0.0934   -0.2130   -0.4372    1.5018    0.0418
   -0.2759   -0.6776   -0.7200   -0.0515   -0.6999   -1.7958
   -0.2474    0.0365    0.4545   -0.6169    1.1813    1.7564
   -0.0023   -0.3438    0.1037    0.3744    1.1419   -1.8710
    0.2961    1.1905   -0.4076    0.8947    1.4033   -1.9164
   -0.5358   -0.5475    0.1650    0.6540   -0.0046   -0.4663
   -0.7222   -0.1424   -0.1187   -0.6225    0.7018   -2.6594
    0.4877    0.5497    0.9439   -0.6675    0.1996    1.6182
    0.1394    0.0236   -0.2964    0.9698    1.9586   -0.9112
   -0.3727    0.5540    0.4776   -0.5436    0.4018   -2.1319
   -0.2102    0.1315    0.7387   -0.6327   -0.6206    0.7813
    0.0639    0.4618    0.1728    0.5125   -1.7728    1.9625
   -0.3954    0.0384    0.2160   -0.2761    0.1758   -0.4140
    0.3557    0.1117    1.4957    0.5230   -0.1038    1.0013
    0.0205   -0.5161   -0.0134   -0.1120   -1.7875    1.2916
    0.0456   -0.0006   -0.5963   -0.6021    0.5226    4.4178
    0.0694    0.1692    0.3223    0.7353   -1.3567    2.9253
   -0.2184    0.6774   -0.1134    1.1745   -1.3587    2.1732
    0.7528   -0.2057   -0.6126    0.8189    1.9827    0.2337
    0.5502   -1.0285    0.7067    0.5168    0.0704    0.9230
   -0.2066   -0.0587   -0.2499   -0.8777    0.5968    4.4617
   -0.2067    0.3109    0.5672   -0.5926    0.2796   -2.1093
    0.5129    0.7724    0.4749   -0.4039   -0.1404    1.2830
   -0.7304    0.1764    0.2731   -0.9490   -0.2182   -0.6209
    0.0630    0.4184    0.1952   -0.9746   -0.3067   -0.4219
   -0.3776   -0.0195   -0.7614    0.5754    0.1631   -0.5925
    0.3049   -0.5775    0.8082   -0.7865   -1.0371   -0.2708
    0.0049    0.1479    0.0678   -0.7343    0.5638   -2.0426
   -0.1352    0.3216   -0.1037   -0.1078   -0.4204   -1.3769
    0.6360    0.1709   -0.8886   -0.7195   -1.5723    1.8818
    0.1022    0.1649    0.9183    0.8798    0.2859   -1.6591
    0.6669   -0.2043   -0.1077   -0.2996    0.5718   -1.2660
    0.4545    0.4046   -0.3773    0.5053   -0.1306   -2.9127
   -0.1389    0.1479   -0.0867   -0.7366    0.0996    0.8047
    0.3839   -0.5413   -0.0238   -0.4166    1.2844   -1.7476
    0.8658   -0.1247    0.4726    0.4933    0.4113    1.1502
   -0.2337   -0.2149    0.4255   -0.8846    0.2680    0.1141
   -0.1521    0.9720    0.3005   -1.2637   -1.0167   -3.4092
   -0.2515    0.2820   -0.5813   -0.1593   -0.4511   -0.2550
   -0.2934   -0.3913    0.5622   -0.2847    1.4599    1.6504
    0.3382    0.2144   -0.3575    0.2122    0.9634   -1.3680
   -0.6642    0.0631   -1.1403   -0.2469   -0.5742   -0.9168
    0.0007    1.0448   -0.3873    0.6533   -1.5150   -0.6674
    0.1825    0.2161   -0.5192    0.0775    1.1203   -3.9396
    0.6583   -0.0843   -0.9287   -0.8541   -1.2838    0.4580
   -0.1505    0.2164    0.5061   -0.7150    0.8049    0.4397
    0.4932    0.9623   -0.3342   -0.9965    0.0839   -2.5340
   -0.5966    0.6068   -0.3004   -0.1627   -1.0670    1.0677
   -0.2516    1.1793   -0.1864    0.9679   -1.5835    0.7254
    0.1070   -0.0306   -0.2205    0.6508   -0.8961    2.8852
   -0.2084    0.1598   -1.1293    0.1698   -0.0857    4.2944
    0.0279   -0.0402   -0.7743    0.1262    1.9864   -3.0947
   -0.0433   -0.1845   -0.6908   -0.8297    0.6059    1.1804
   -0.3411    0.4666    0.8149    0.3049    0.7929    4.5720
   -0.0992   -0.2656   -0.2453   -0.7739   -0.6688    1.2265
   -0.8115   -0.1451   -0.5384   -0.2927    0.4179    1.3257
    0.0448   -0.0380   -0.1062    0.1608    1.2730    1.9506
    0.1354    0.0519    0.2023   -0.0906    0.6607    1.9280




[pc1, score1, variance1, t21]=princomp(p)
pc1 =
    0.4170   -0.3313   -0.0598    0.8247   -0.0464   -0.1745
    0.3488   -0.4985   -0.6721   -0.4217    0.0029    0.0163
    0.3491   -0.4817    0.7380   -0.3182   -0.0055   -0.0065
   -0.4618   -0.2877   -0.0059   -0.0654   -0.1726   -0.8184
   -0.4268   -0.4090    0.0027    0.1396    0.7656    0.2120
   -0.4325   -0.3995   -0.0002    0.1302   -0.6180    0.5044

score1 =
   -1.8096    0.2899    0.6621   -0.2303   -0.2175   -0.2287
    1.3501    0.9495    0.0469   -0.1343    0.5691   -0.5734
   -0.1246    2.7841   -0.7086    0.0565    0.2699   -0.4247
    0.4106    0.4877    0.3537    0.4901    0.2544   -0.7863
   -0.7842   -0.4366    0.6155    0.0129    0.0313   -0.6236
    1.1998    0.3640   -0.3495   -0.1016    0.1394   -0.0080
    1.0365    2.2474   -0.0892   -0.6607    0.2878    0.3532
   -0.8986    0.4259   -0.7119    0.8751    0.7334    0.0340
    3.3897    0.6251   -0.9194   -0.3774    0.9110    0.4590
    3.4531   -0.1572    0.3366   -0.4111    0.1649   -0.0704
    1.0316   -0.0237    0.5833   -0.5883    0.1591    0.0672
    0.8291    2.1219   -1.4935   -0.6628    0.3472   -0.0396
    1.5344    2.0459    0.3591    0.7720    0.5296   -0.3935
    2.1538    1.7042    1.7032   -0.7823    0.2446   -0.0805
   -0.2156   -1.8450   -0.5985   -0.2999    0.5518   -0.1575
   -2.1642    0.1471    0.6093    0.6141    0.7977    0.5680
    1.6013    0.2268   -0.3597   -0.6336   -0.0750   -0.6503
    1.1868    0.8855    0.4303    0.9051    0.1168   -0.0814
   -1.1357   -0.0199    1.0057   -0.8338    0.3798    0.6151
   -0.9573   -0.1416    0.5877    0.4521    0.9218    0.2512
    2.0017   -0.5917    1.2628    0.8082   -0.0512   -0.1688
   -0.6471   -0.7335   -0.6265   -0.4028    0.1453   -0.1186
   -0.0897   -0.7285    0.7373    0.7825   -0.7454    0.6599
   -2.5180    0.0440   -0.4212   -0.3292   -0.1680   -0.3809
    1.6085    0.0937    1.0198   -0.7727    0.7064    0.0563
    0.0787    1.4414    0.9396   -0.4504    0.3412    0.2219
    2.9517   -0.3262    0.9469    0.4580    0.5016    0.4948
    0.7823   -0.8402   -0.0827   -0.4591   -0.4904    0.2585
    2.7627    0.3524    0.1636    0.7183   -0.2634   -0.1345
    2.8581    0.2952    1.0305   -0.8414   -0.3184    0.2376
    1.6254    0.0085    0.0314    1.0825    0.0762    0.0686
    1.8761   -0.6747   -0.6847   -0.4577    0.0449    0.8539
   -2.9810    0.5454    0.9146   -0.1706    0.2791    0.6910
   -0.2725   -1.4822    0.1592   -0.7879   -0.4703    0.2720
   -0.9014    2.7273   -0.2522    0.1161   -0.1510   -0.1616
    0.6158   -0.5856   -0.3118   -0.3815   -0.0516   -0.2939
   -1.6287   -0.7977    0.5617    0.1913    0.5864   -0.0591
   -2.7530   -0.7225   -0.2763    0.6685   -0.0519   -0.1761
   -1.5914   -0.5904   -0.0261    0.2156    0.0704   -0.5016
   -1.7949   -1.1584   -0.9216    0.6434   -0.0738    0.0915
   -3.3343   -1.4701    0.9876   -0.5986   -0.3464    0.0171
   -0.5813   -2.2241   -0.4505   -0.2394    0.2531   -0.5885
   -0.0418   -1.5018   -0.4372    0.2130    0.0934    0.3220
    1.7958    0.6999   -0.0515    0.7200    0.6776    0.2759
   -1.7564   -1.1813   -0.6169   -0.4545   -0.0365    0.2474
    1.8710   -1.1420    0.3744   -0.1037    0.3438    0.0023
    1.9164   -1.4033    0.8947    0.4077   -1.1905   -0.2961
    0.4663    0.0046    0.6540   -0.1650    0.5475    0.5358
    2.6594   -0.7018   -0.6225    0.1187    0.1424    0.7222
   -1.6182   -0.1996   -0.6675   -0.9439   -0.5497   -0.4877
    0.9112   -1.9586    0.9698    0.2964   -0.0236   -0.1394
    2.1319   -0.4018   -0.5436   -0.4775   -0.5540    0.3727
   -0.7813    0.6206   -0.6327   -0.7387   -0.1315    0.2102
   -1.9625    1.7728    0.5125   -0.1728   -0.4618   -0.0639
    0.4140   -0.1758   -0.2761   -0.2160   -0.0384    0.3954
   -1.0013    0.1038    0.5230   -1.4957   -0.1117   -0.3557
   -1.2916    1.7875   -0.1120    0.0134    0.5161   -0.0205
   -4.4178   -0.5226   -0.6021    0.5963    0.0006   -0.0456
   -2.9253    1.3567    0.7353   -0.3223   -0.1692   -0.0694
   -2.1732    1.3587    1.1745    0.1134   -0.6774    0.2184
   -0.2337   -1.9827    0.8189    0.6126    0.2057   -0.7528
   -0.9230   -0.0704    0.5168   -0.7067    1.0285   -0.5502
   -4.4617   -0.5968   -0.8777    0.2499    0.0587    0.2066
    2.1093   -0.2796   -0.5926   -0.5672   -0.3109    0.2067
   -1.2830    0.1404   -0.4039   -0.4749   -0.7724   -0.5129
    0.6209    0.2182   -0.9490   -0.2731   -0.1764    0.7304
    0.4219    0.3067   -0.9746   -0.1952   -0.4184   -0.0630
    0.5925   -0.1631    0.5754    0.7614    0.0195    0.3776
    0.2708    1.0371   -0.7865   -0.8082    0.5775   -0.3049
    2.0426   -0.5638   -0.7343   -0.0678   -0.1479   -0.0049
    1.3769    0.4204   -0.1078    0.1037   -0.3216    0.1352
   -1.8818    1.5723   -0.7195    0.8886   -0.1709   -0.6360
    1.6591   -0.2859    0.8798   -0.9183   -0.1649   -0.1022
    1.2660   -0.5718   -0.2996    0.1077    0.2043   -0.6669
    2.9127    0.1306    0.5053    0.3773   -0.4046   -0.4545
   -0.8047   -0.0996   -0.7366    0.0867   -0.1479    0.1389
    1.7476   -1.2844   -0.4166    0.0238    0.5413   -0.3839
   -1.1502   -0.4113    0.4933   -0.4726    0.1247   -0.8658
   -0.1141   -0.2680   -0.8846   -0.4255    0.2149    0.2337
    3.4092    1.0167   -1.2637   -0.3005   -0.9720    0.1521
    0.2550    0.4511   -0.1593    0.5813   -0.2820    0.2515
   -1.6504   -1.4599   -0.2847   -0.5622    0.3913    0.2934
    1.3680   -0.9635    0.2122    0.3575   -0.2144   -0.3382
    0.9168    0.5742   -0.2469    1.1403   -0.0631    0.6642
    0.6674    1.5150    0.6533    0.3873   -1.0448   -0.0007
    3.9396   -1.1203    0.0775    0.5192   -0.2161   -0.1825
   -0.4580    1.2838   -0.8541    0.9287    0.0843   -0.6583
   -0.4397   -0.8049   -0.7150   -0.5061   -0.2164    0.1505
    2.5340   -0.0839   -0.9965    0.3342   -0.9623   -0.4932
   -1.0677    1.0670   -0.1628    0.3004   -0.6068    0.5966
   -0.7254    1.5835    0.9679    0.1864   -1.1793    0.2516
   -2.8852    0.8961    0.6508    0.2205    0.0306   -0.1070
   -4.2944    0.0857    0.1698    1.1293   -0.1598    0.2084
    3.0947   -1.9864    0.1262    0.7743    0.0402   -0.0279
   -1.1804   -0.6059   -0.8297    0.6908    0.1845    0.0433
   -4.5720   -0.7929    0.3049   -0.8149   -0.4666    0.3411
   -1.2265    0.6688   -0.7739    0.2453    0.2656    0.0992
   -1.3257   -0.4179   -0.2927    0.5384    0.1451    0.8115
   -1.9506   -1.2730    0.1608    0.1062    0.0380   -0.0448
   -1.9280   -0.6607   -0.0906   -0.2023   -0.0519   -0.1354

variance1 =
    3.7352
    1.1332
    0.4572
    0.3226
    0.1992
    0.1526

t21 =
    2.6544
    5.1254
    9.5004
    5.6509
    3.7154
    0.8995
    7.3490
    6.5665
   11.2589
    4.1548
    2.2593
   11.0134
    8.8767
   12.3898
    5.7697
    8.5627
    5.0595
    4.1255
    7.9177
    6.3317
    7.0949
    2.1466
    9.2015
    3.5158
    7.3526
    5.3019
    7.9057
    3.1001
    4.2777
    7.6602
    4.4023
    7.8076
    8.0815
    5.5342
    7.2476
    1.6475
    3.8245
    4.2590
    2.8052
    5.2698
    8.7322
    7.6685
    3.2727
    5.7118
    3.9381
    3.0214
   12.6772
    4.4649
    6.7393
    7.5484
    6.0671
    5.1635
    3.4467
    5.5689
    1.4164
    8.7029
    4.6340
    7.3749
    5.5952
    8.5665
   10.0405
    9.6591
    7.8194
    3.7910
    6.2334
    5.9991
    3.2313
    3.5753
    6.6308
    2.7012
    1.3612
    9.5069
    5.3216
    4.0743
    5.4616
    1.6287
    5.0918
    6.7186
    2.9296
   12.6917
    2.1138
    5.0998
    2.7951
    7.5916
    9.0240
    6.5640
    8.6564
    2.9193
   10.4871
    5.8287
   11.9074
    4.0942
    9.3728
    7.9523
    3.8652
   10.2683
    2.7127
    6.1325
    2.5606
    1.6588
     原来Spss在计算PCA的时候已经做了标准化处理,因为我在Matlab下用元数据和标准化的数据计算的不一样,但是标准化后的数据计算结果却和Matlab里面的特征值和特征向量一样,但是为什么有一个符号的差别?而主成分得分却完全不一样?

       今天和学长商讨了一下,原来Spss并没有提供专门的PCA分析模块。只是因子分析需要建立在PCA的基础上而已。但是我在Matlab中一步步按照书上给的步骤去计算缺的的结果和Matlab自带的函数有点差异的时候,觉得是特征向量的时候出现了问题,又看了一下线性代数才找到答案。
Why

这也是我喜欢Matlab的原因,我可以去模拟,去对比,在这个过程之后发现问题,然后解决,看自己缺少那些知识,然后自己去弥补…… ,看来线代知识不够扎实,还需要努力,努力……
上一篇:分享相关资料


下一篇:JavaWeb学习之路(47)–CSS内联样式/内部样式表/外部样式表