Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why the polychoricpca command does not provide the eigenvectors

    Dear Statalisters,

    I am trying to getting familiar with the principal component analysis in order to apply it to a dataset whose features I described in this Statalist post:

    https://www.statalist.org/forums/for...on-individuals

    Amongst my variables, there are some that are continuous, others that are ordinal, and others that are dummies. From what I understood by reading different sources, such as these:

    https://onlinelibrary.wiley.com/doi/...1.2008.00309.x

    I should resort to polychoricpca.

    I also read this:

    https://www.statalist.org/forums/for...ca?view=thread

    and I tried to run the following commands on my database:

    Code:
    pca practicality-driv_pleas
    ,

    which returns the following output:

    Code:
    . pca practicality-driv_pleas
    
    Principal components/correlation                 Number of obs    =        870
                                                     Number of comp.  =         20
                                                     Trace            =         20
        Rotation: (unrotated = principal)            Rho              =     1.0000
    
        --------------------------------------------------------------------------
           Component |   Eigenvalue   Difference         Proportion   Cumulative
        -------------+------------------------------------------------------------
               Comp1 |      7.02921      4.61705             0.3515       0.3515
               Comp2 |      2.41216      1.16462             0.1206       0.4721
               Comp3 |      1.24754      .189893             0.0624       0.5344
               Comp4 |      1.05764      .251995             0.0529       0.5873
               Comp5 |      .805648      .101337             0.0403       0.6276
               Comp6 |      .704311     .0593641             0.0352       0.6628
               Comp7 |      .644947     .0197066             0.0322       0.6951
               Comp8 |      .625241     .0390891             0.0313       0.7263
               Comp9 |      .586152     .0240978             0.0293       0.7556
              Comp10 |      .562054     .0200735             0.0281       0.7837
              Comp11 |       .54198      .028251             0.0271       0.8108
              Comp12 |      .513729     .0362875             0.0257       0.8365
              Comp13 |      .477442     .0270003             0.0239       0.8604
              Comp14 |      .450441      .016936             0.0225       0.8829
              Comp15 |      .433505    .00178447             0.0217       0.9046
              Comp16 |      .431721     .0151015             0.0216       0.9262
              Comp17 |      .416619      .036927             0.0208       0.9470
              Comp18 |      .379692     .0311164             0.0190       0.9660
              Comp19 |      .348576     .0171863             0.0174       0.9834
              Comp20 |       .33139            .             0.0166       1.0000
        --------------------------------------------------------------------------
    
    Principal components (eigenvectors)
    
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            Variable |    Comp1     Comp2     Comp3     Comp4     Comp5     Comp6     Comp7     Comp8     Comp9    Comp10    Comp11    Comp12    Comp13    Comp14    Comp15    Comp16    Comp17    Comp18
        -------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        practicality |   0.2437   -0.0352    0.2588    0.1652   -0.1023   -0.3278    0.0369   -0.0374   -0.0613   -0.6074   -0.0068   -0.4662    0.2493   -0.1695   -0.1266   -0.0706    0.0530    0.1201
            planning |   0.1970   -0.2483    0.3637    0.0555   -0.0530    0.1194   -0.1421    0.4696    0.0352    0.2862    0.3424   -0.0288   -0.1115   -0.5228    0.0447    0.0152   -0.0324    0.0920
             anxiety |   0.2212    0.0170    0.4158    0.2559   -0.0604   -0.2954   -0.1364    0.0330    0.2856   -0.0576   -0.2117    0.4173   -0.2933    0.2462   -0.2444    0.1658    0.0381   -0.2239
           long_dist |   0.1917   -0.3195    0.2872   -0.0140   -0.0561    0.0105    0.3373    0.0057   -0.2858    0.0852    0.1058    0.3420    0.4398    0.3578    0.1033   -0.0524   -0.2099    0.1946
             ch_time |   0.2339   -0.2097    0.2201   -0.0925   -0.0096    0.1251   -0.0124   -0.1155   -0.3058    0.3423   -0.5344   -0.3989   -0.0656    0.0818    0.1441   -0.0142    0.1744   -0.2855
             ch_prob |   0.2389   -0.2493   -0.1753    0.0692   -0.1061    0.2116   -0.3041   -0.2445    0.2022    0.1677   -0.1337   -0.0244    0.0663   -0.0081   -0.4602   -0.1299    0.1589    0.3921
              ins_ch |   0.1989   -0.3342   -0.0920    0.0605    0.0653    0.1649    0.0802   -0.4191    0.3758   -0.2137   -0.0242    0.2520    0.0896   -0.3199    0.4472   -0.0639    0.0767   -0.2006
          elec_plant |   0.2427   -0.1497   -0.2643    0.1498   -0.3136    0.0331   -0.2874   -0.0172    0.0299   -0.0132    0.3197   -0.2622   -0.0819    0.3203    0.0963    0.0137   -0.4924   -0.3242
           elec_bill |   0.2393   -0.0030   -0.3742    0.1677   -0.4379    0.0071    0.1233    0.1899   -0.1242   -0.0031   -0.0128    0.1373   -0.0483    0.1068    0.0704    0.0827    0.3706    0.2690
              safety |   0.2415    0.3226    0.0588    0.0036   -0.0777   -0.1840    0.0189   -0.0394    0.1373    0.2237    0.0527    0.0034   -0.1236    0.0106    0.2146   -0.4286    0.0092    0.0108
           tech_risk |   0.2203    0.3567    0.0451    0.0286    0.0361   -0.2351    0.1390   -0.2145    0.1094    0.2604    0.0889   -0.1056   -0.0197    0.0129    0.1879   -0.2461   -0.0433    0.2535
             env_adv |   0.1900    0.2583    0.1576   -0.4381   -0.2213    0.2527   -0.0060    0.1119    0.3392   -0.1278   -0.1604   -0.1104    0.0399    0.1007    0.2415    0.4803   -0.1011    0.2341
           batt_disp |   0.2181    0.1846    0.0740   -0.5055   -0.1196    0.0633   -0.0013   -0.2199   -0.0497    0.0495    0.3557    0.1011    0.2352   -0.0615   -0.4072   -0.0351    0.1959   -0.3694
            batt_dur |   0.2610    0.0082   -0.0565   -0.2151    0.0661   -0.0872   -0.1576   -0.2376   -0.5589   -0.2306    0.0647    0.2273   -0.4949   -0.1706    0.0957    0.1335   -0.0686    0.1636
           pur_price |   0.2047   -0.2678   -0.1090   -0.1774    0.3372    0.0357    0.4619    0.1992    0.2096   -0.1207    0.2238   -0.2161   -0.3925    0.2838   -0.1017   -0.0671    0.2315   -0.0315
           elec_cost |   0.2450    0.0987   -0.3241   -0.0671   -0.1396   -0.0484    0.3174    0.3535   -0.0249   -0.0537   -0.3937    0.1591    0.0752   -0.3301   -0.1849   -0.1493   -0.2770   -0.2573
         resid_value |   0.2367    0.0571   -0.1085   -0.1587    0.4441    0.0339   -0.5149    0.3749   -0.0269   -0.1921   -0.0998    0.1301    0.2494    0.2025    0.1682   -0.2692    0.1024    0.0113
               maint |   0.2460   -0.0619   -0.2418    0.0159    0.4386   -0.3634    0.0323   -0.1000    0.0730    0.2907   -0.0199   -0.0732    0.1735   -0.1104   -0.1217    0.4645   -0.2460    0.1079
               accel |   0.1990    0.3029   -0.0604    0.4388    0.1234    0.1542    0.0300    0.0393   -0.1549    0.0549    0.1903   -0.0148    0.1965   -0.0093    0.1188    0.3429    0.3890   -0.2544
          driv_pleas |   0.1787    0.2863    0.1346    0.2964    0.2474    0.6139    0.1533   -0.1010   -0.0671   -0.1254   -0.0394   -0.0076   -0.1097    0.0092   -0.2199   -0.0988   -0.3185    0.1004
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        ------------------------------------------------
            Variable |   Comp19    Comp20 | Unexplained
        -------------+--------------------+-------------
        practicality |  -0.0395   -0.0600 |           0
            planning |  -0.0545    0.0685 |           0
             anxiety |  -0.0532    0.0982 |           0
           long_dist |   0.1516   -0.0670 |           0
             ch_time |  -0.1184    0.0429 |           0
             ch_prob |   0.3667   -0.0527 |           0
              ins_ch |  -0.1011    0.0369 |           0
          elec_plant |   0.0319    0.0685 |           0
           elec_bill |  -0.5106    0.0335 |           0
              safety |   0.0295   -0.6888 |           0
           tech_risk |   0.0741    0.6577 |           0
             env_adv |   0.1287   -0.0585 |           0
           batt_disp |  -0.2137    0.0491 |           0
            batt_dur |   0.1863   -0.0231 |           0
           pur_price |   0.1251    0.0013 |           0
           elec_cost |   0.2593    0.0896 |           0
         resid_value |  -0.0966    0.1058 |           0
               maint |  -0.2653   -0.1746 |           0
               accel |   0.4238   -0.0388 |           0
          driv_pleas |  -0.3218   -0.0329 |           0
        ------------------------------------------------

    Afterwards I ran this command:


    Code:
    polychoricpca practicality-driv_pleas
    and obtained the following results:

    Code:
    Polychoric correlation matrix
    
                  practicality      planning       anxiety     long_dist       ch_time       ch_prob        ins_ch    elec_plant     elec_bill        safety     tech_risk       env_adv     batt_disp
    practicality             1
        planning     .46887165             1
         anxiety     .55476727     .48296498             1
       long_dist     .46718179     .58813472     .43427449             1
         ch_time     .48750757     .54248733     .43528707     .58396926             1
         ch_prob     .41067713     .46715181     .36692686     .47536231     .55263095             1
          ins_ch     .40712897     .43675706     .33544393     .55435099       .505425     .64638532             1
      elec_plant     .44775213     .41857401      .3406354     .40976515     .43772118     .63096593     .52643512             1
       elec_bill     .38509483     .26585289      .3117979     .31739859     .34538106     .52971132     .41715367     .61974414             1
          safety     .43710027     .21463469     .47680019     .12978229     .30172985     .25737162     .12181734     .35575943     .44107087             1
       tech_risk     .41233114     .12749909     .41954204      .0815096      .2505261     .19523019      .0862999     .27916593     .37593173      .7234901             1
         env_adv     .31372293     .20176292     .31846783     .11551468     .28917119      .1911353     .09696787      .2261309     .28673824     .52815186     .49866812             1
       batt_disp     .35063497     .24051664     .29363291     .26200293     .33750162     .30937666     .20248101     .30267165     .31955302     .54546077     .52057275     .59619518             1
        batt_dur     .46910848     .34595909     .40099893      .3968134     .49034134     .46767487      .4267432     .48399172     .48482918     .48230543     .44452145     .39767814     .54208202
       pur_price     .38079009     .44053879     .26335672     .50233421     .47543892     .51078059     .55815531     .45157092     .39087453     .18019573     .14964534     .18476263     .28845316
       elec_cost     .38165003      .2268896     .29591694     .25708499     .34473421     .42301636     .33167376     .46663746     .62026213     .51626612     .46303236     .41464156     .43505393
     resid_value     .37487362     .32515586     .33632106     .25735509     .37568142     .41826521     .31720273     .41010176     .37430398     .45391778     .39345303     .39296702     .42958995
           maint     .40452551     .31327526     .34195969     .36205555     .42634147     .51607562     .48102522     .48034615     .44800222     .41086188     .43248485     .22309007     .35368913
           accel     .37370698      .1551999     .36747058     .05985803     .17803794     .21656976     .09798908     .32355482     .44439632     .55706164     .57254742     .31050701     .31133116
      driv_pleas     .32189344     .16196697      .3518798     .09673567     .22172954     .19446546     .10801442     .20142901     .25762503     .49091961     .50256195     .37894014     .32330302
    
                      batt_dur     pur_price     elec_cost   resid_value         maint         accel    driv_pleas
        batt_dur             1
       pur_price     .44953416             1
       elec_cost      .4985904     .40738182             1
     resid_value     .52230607     .41945232     .47256824             1
           maint     .51978832      .5372825     .51017407     .52462419             1
           accel     .35318229     .09837516     .41800321     .38888505      .3790175             1
      driv_pleas     .32474894     .11625503     .33979756     .34236231     .23654472     .60780512             1
    
    Principal component analysis
    
     k  |  Eigenvalues  |  Proportion explained  |  Cum. explained
    ----+---------------+------------------------+------------------
      1 |    8.229478   |    0.411474            |   0.411474
      2 |    2.616316   |    0.130816            |   0.542290
      3 |    1.270536   |    0.063527            |   0.605816
      4 |    1.051264   |    0.052563            |   0.658380
      5 |    0.753465   |    0.037673            |   0.696053
      6 |    0.647771   |    0.032389            |   0.728441
      7 |    0.564983   |    0.028249            |   0.756691
      8 |    0.544444   |    0.027222            |   0.783913
      9 |    0.487707   |    0.024385            |   0.808298
      10 |    0.471218  |    0.023561            |   0.831859
      11 |    0.450944  |    0.022547            |   0.854406
      12 |    0.437860  |    0.021893            |   0.876299
      13 |    0.384210  |    0.019210            |   0.895510
      14 |    0.350997  |    0.017550            |   0.913060
      15 |    0.344459  |    0.017223            |   0.930283
      16 |    0.323430  |    0.016172            |   0.946454
      17 |    0.310614  |    0.015531            |   0.961985
      18 |    0.276303  |    0.013815            |   0.975800
      19 |    0.251480  |    0.012574            |   0.988374
      20 |    0.232521  |    0.011626            |   1.000000
    What puzzles me, and I do apologise if my question is silly, is why when I use the

    Code:
    polychoricpca practicality-driv_pleas
    there is not a panel showing the Principal components (eigenvectors). I am inclined to think that this could be related to my lack of strong knowledge on the topic.

    I would be very grateful if anyone could provide me an insight.

    Many thanks.

    Marco
    Last edited by Marco Giansoldati; 16 Oct 2019, 10:04.

  • #2
    The user-contributed command -polychoricpca- stores the eigenvectors in the r() return list (see -help return- if you're not familiar with this). I discovered this fact by looking at -help polychoricpca- and then searching on "eigenvector." -help- is always worth trying, even for user-contributed commands. To see the eigenvectors, type:
    Code:
    matrix list r(eigenvectors)
    right after your -polychoricpca- command.

    Comment


    • #3
      Dear Mike Lacy, I do thank you very much for the precious indications. Many many thanks!

      Comment


      • #4
        Dear Mike Lacy, I take the chance of your kind reply to kindly ask you if there is a way to specify to retain maximum of # principal components, as available in the

        Code:
        pca
        command.

        Many many thanks.

        Marco

        Comment

        Working...
        X