. do "C:\Users\hstryhn\AppData\Local\Temp\STD3de4_000000.tmp"

. * do-file for lecture 10 of VHM 802, Winter 2021
. version 16 /* works also with versions 14-15 */

. set more off

. cd "r:\"
r:\

.
. * Manly Example 6.1 - sparrow data
. import delimited r:\sparrow.csv, clear
(6 vars, 49 obs)

. pca total_length-l_keel_sternum

Principal components/correlation                 Number of obs    =         49
                                                 Number of comp.  =          5
                                                 Trace             =          5
    Rotation: (unrotated = principal)            Rho              =     1.0000

    -------------+------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
    Comp1   |      3.61598      3.08447             0.7232       0.7232
    Comp2   |      .531504       .14508             0.1063       0.8295
    Comp3   |      .386425      .084859             0.0773       0.9068
    Comp4   |      .301566      .137038             0.0603       0.9671
    Comp5   |      .164527            .             0.0329       1.0000
    -------------+------------------------------------------------------------

Principal components (eigenvectors)

    -------------+--------------------------------------------------+-------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5   | Unexplained
    -------------+--------------------------------------------------+-------------
    total_length   |   0.4518      0.0507     -0.6905      0.4204     -0.3739   |           0
    alar_extent   |   0.4617     -0.2996     -0.3405     -0.5479      0.5301   |           0
    l_beak_head   |   0.4505     -0.3246      0.4545      0.6063      0.3428   |           0
    l_humerous   |   0.4707     -0.1847      0.4109     -0.3883     -0.6517   |           0
    l_keel_ste~m   |   0.3977      0.8765      0.1785     -0.0689      0.1924   |           0
    -------------+--------------------------------------------------+-------------

. predict scor1-scor5, score

Scoring coefficients
    sum of squares(column-loading) = 1

    -------------+--------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5
    -------------+--------------------------------------------------
    total_length   |   0.4518      0.0507     -0.6905      0.4204     -0.3739
    alar_extent   |   0.4617     -0.2996     -0.3405     -0.5479      0.5301
    l_beak_head   |   0.4505     -0.3246      0.4545      0.6063      0.3428
    l_humerous   |   0.4707     -0.1847      0.4109     -0.3883     -0.6517
    l_keel_ste~m   |   0.3977      0.8765      0.1785     -0.0689      0.1924
    -------------+--------------------------------------------------

. scoreplot, comp(2) mlabel(survivorship)

. loadingplot

. screeplot

. biplot total_length- l_keel_sternum, std

Biplot of 49 observations and 5 variables

    Explained variance by component 1  0.7232
    Explained variance by component 2  0.1063
             Total explained variance  0.8295

. * note: a separate command, not a postestimation command
. encode survivorship, g(surv)

. replace surv=surv-1
(49 real changes made)

. logit surv total_length-l_keel_sternum

Iteration 0:   log likelihood = -33.462497
Iteration 1:   log likelihood = -32.041086
Iteration 2:   log likelihood = -32.035688
Iteration 3:   log likelihood = -32.035688

Logistic regression                             Number of obs     =         49
                                                LR chi2(5)        =       2.85
                                                Prob > chi2       =     0.7225
Log likelihood = -32.035688                     Pseudo R2         =     0.0426

---------------+----------------------------------------------------------------
           surv |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
---------------+----------------------------------------------------------------
  total_length |   -.1625675    .1396369     -1.16    0.244     -.4362508     .1111159
   alar_extent |   -.0276413    .1060235     -0.26    0.794     -.2354436     .1801609
   l_beak_head |   -.0837496     .628623     -0.13    0.894     -1.315828     1.148329
    l_humerous |    1.061744    1.023129      1.04    0.299     -.9435529     3.067041
l_keel_sternum |    .0715755    .4166297      0.17    0.864     -.7450037     .8881547
         _cons |    13.58231    15.86496      0.86    0.392     -17.51244     44.67706
---------------+----------------------------------------------------------------

. logit surv scor1-scor5

Iteration 0:   log likelihood = -33.462497
Iteration 1:   log likelihood = -32.041086
Iteration 2:   log likelihood = -32.035688
Iteration 3:   log likelihood = -32.035688

Logistic regression                             Number of obs     =         49
                                                LR chi2(5)        =       2.85
                                                Prob > chi2       =     0.7225
Log likelihood = -32.035688                     Pseudo R2         =     0.0426

-------------+----------------------------------------------------------------
         surv |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
       scor1 |   -.0528091    .1565831     -0.34    0.736     -.3597064     .2540881
       scor2 |   -.0150206    .4274524     -0.04    0.972     -.8528119     .8227707
       scor3 |    .6865037    .5071386      1.35    0.176     -.3074697     1.680477
       scor4 |   -.4508785    .5489788     -0.82    0.411     -1.526857     .6251002
       scor5 |   -.2517201    .7326623     -0.34    0.731     -1.687712     1.184272
       _cons |   -.3048856    .2979983     -1.02    0.306     -.8889515     .2791804
-------------+----------------------------------------------------------------

.
. * Manly Table 9.7 - Steneryd data
. import delimited "r:\steneryd.csv", clear varnames(1)
(30 vars, 17 obs)

. * include code to relabel spec1-spec25 as s1-s25
. foreach j of numlist 1(1)25 {
  2.    rename spec`j' s`j'
  3.    }

. tabstat s1-s25, statistics( mean min max sd var )

   stats |        s1        s2        s3        s4        s5        s6        s7        s8        s9       s10       s11       s12
---------+------------------------------------------------------------------------------------------------------------------------
mean   |  12.11765  11.17647  9.764706  7.647059  6.588235         6  5.647059  4.941176  4.882353  4.411765         4  3.588235
min   |         0         0         0         0         0         0         0         0         0         0         0         0
max   |        43        21        39        28        37        45        15        10        11        14         9        12
sd   |  16.22067  7.443414  11.42656  8.358687  11.40756  14.91643  5.049024  3.831948  4.029304  4.912469  3.640055   3.74264
variance   |  263.1103  55.40441  130.5662  69.86765  130.1324     222.5  25.49265  14.68382  16.23529  24.13235     13.25  14.00735
---------+------------------------------------------------------------------------------------------------------------------------

   stats |       s13       s14       s15       s16       s17       s18       s19       s20       s21       s22       s23       s24
---------+------------------------------------------------------------------------------------------------------------------------
mean   |  3.588235  3.588235  3.176471         3  2.941176  2.823529  2.764706  2.705882  2.647059  2.647059  2.470588  2.411765
min   |         0         0         0         0         0         0         0         0         0         0         0         0
max   |        30        10        15        18        16         9        12         9         9        10        16         8
sd   |  7.778647  3.985267  5.126345  5.689903  5.018349  3.339822  4.008264  2.931823  3.081014  3.444945  4.638395  2.895229
variance   |  60.50735  15.88235  26.27941    32.375  25.18382  11.15441  16.06618  8.595588  9.492647  11.86765  21.51471  8.382353
---------+------------------------------------------------------------------------------------------------------------------------

   stats |       s25
---------+----------
mean   |  2.411765
min   |         0
max   |        19
sd   |  5.579637
variance   |  31.13235
---------+----------

. pwcorr s1-s25

             |       s1       s2       s3       s4       s5       s6       s7
-------------+---------------------------------------------------------------
          s1 |   1.0000
          s2 |  -0.7171   1.0000
          s3 |  -0.5363   0.4980   1.0000
          s4 |   0.4106  -0.4540   0.2366   1.0000
          s5 |  -0.4408   0.3896   0.0059  -0.5614   1.0000
          s6 |  -0.3182   0.3304  -0.0708  -0.3910   0.7974   1.0000
          s7 |  -0.2444   0.2812   0.6918   0.2605  -0.4704  -0.4747   1.0000
          s8 |  -0.1055  -0.0500   0.2923   0.4169  -0.5239  -0.4647   0.4576
          s9 |  -0.3976   0.4404   0.6374   0.2195  -0.4186  -0.4316   0.7567
         s10 |  -0.5662   0.3209   0.5129  -0.2611  -0.0994  -0.2004   0.6009
         s11 |  -0.7187   0.3137   0.2960  -0.4355   0.4530   0.3096  -0.0408
         s12 |   0.1398  -0.2485  -0.0404   0.5984  -0.3746  -0.3672   0.0580
         s13 |  -0.0442   0.4266   0.2724  -0.0485  -0.1654  -0.1928   0.3812
         s14 |   0.8458  -0.5536  -0.5595   0.3762  -0.5071  -0.3722  -0.1195
         s15 |   0.5845  -0.5856  -0.5114   0.5150  -0.3802  -0.2648  -0.2124
         s16 |  -0.2404   0.1033   0.2249   0.2181  -0.3235  -0.2253   0.4764
         s17 |   0.8869  -0.7945  -0.4929   0.4703  -0.3596  -0.2505  -0.2278
         s18 |  -0.5580   0.2201  -0.0257  -0.4345   0.3490   0.5269  -0.1596
         s19 |  -0.2524   0.4665   0.6387   0.2567  -0.3699  -0.2917   0.6071
         s20 |  -0.4763   0.3920   0.4437  -0.0555  -0.1533  -0.2801   0.2459
         s21 |  -0.5006   0.4825   0.4502  -0.2721  -0.1378  -0.2693   0.4093
         s22 |  -0.4511   0.2707   0.1216  -0.3215  -0.1328   0.0839   0.1936
         s23 |   0.7859  -0.6687  -0.4695   0.5381  -0.3268  -0.2276  -0.2033
         s24 |  -0.4882   0.1907  -0.1046  -0.4172   0.1512   0.3618  -0.0664
         s25 |   0.2715  -0.2983  -0.3807   0.4455  -0.2652  -0.1847  -0.1409

             |       s8       s9      s10      s11      s12      s13      s14
-------------+---------------------------------------------------------------
          s8 |   1.0000
          s9 |   0.6755   1.0000
         s10 |   0.3865   0.5015   1.0000
         s11 |  -0.0851   0.0852   0.4369   1.0000
         s12 |   0.6780   0.3530  -0.1806  -0.1927   1.0000
         s13 |  -0.0805   0.4430  -0.2128  -0.1369  -0.1350   1.0000
         s14 |   0.1620  -0.1239  -0.5335  -0.6721   0.4111   0.1434   1.0000
         s15 |   0.4301  -0.1411  -0.4324  -0.5091   0.7663  -0.3037   0.7594
         s16 |   0.5676   0.4771   0.4897  -0.2625   0.3346  -0.1920  -0.0551
         s17 |  -0.1789  -0.4207  -0.4376  -0.5201   0.1384  -0.2873   0.6675
         s18 |  -0.1376  -0.1224   0.3171   0.7660  -0.3112  -0.2604  -0.5035
         s19 |   0.2920   0.7296   0.2084   0.1628   0.1140   0.6241  -0.1199
         s20 |   0.3544   0.6106   0.4516   0.5798   0.1421   0.1725  -0.3320
         s21 |   0.3422   0.5905   0.7865   0.4514  -0.0568  -0.0351  -0.4605
         s22 |   0.1782   0.2445   0.6554   0.5532  -0.1429  -0.2553  -0.3891
         s23 |   0.0298  -0.3513  -0.4644  -0.5627   0.3647  -0.2611   0.7820
         s24 |  -0.0653  -0.0706   0.3696   0.6761  -0.1506  -0.2778  -0.3690
         s25 |   0.3695  -0.0172  -0.3760  -0.4554   0.7269  -0.2119   0.5168

             |      s15      s16      s17      s18      s19      s20      s21
-------------+---------------------------------------------------------------
         s15 |   1.0000
         s16 |   0.1736   1.0000
         s17 |   0.5373  -0.2167   1.0000
         s18 |  -0.3522  -0.1217  -0.3698   1.0000
         s19 |  -0.2838   0.0082  -0.2990   0.0294   1.0000
         s20 |  -0.2999  -0.0562  -0.4133   0.2816   0.6639   1.0000
         s21 |  -0.4390   0.1854  -0.4380   0.2062   0.4079   0.7489   1.0000
         s22 |  -0.2794   0.1626  -0.3050   0.7004   0.2788   0.5213   0.6529
         s23 |   0.7296  -0.0924   0.7960  -0.4220  -0.3433  -0.4212  -0.4512
         s24 |  -0.2031   0.0379  -0.3295   0.9064   0.0358   0.2581   0.2695
         s25 |   0.8407   0.3425   0.2643  -0.3413  -0.2777  -0.2328  -0.3655

             |      s22      s23      s24      s25
-------------+------------------------------------
         s22 |   1.0000
         s23 |  -0.3723   1.0000
         s24 |   0.8050  -0.3597   1.0000
         s25 |  -0.3009   0.5306  -0.1814   1.0000

. pca s1-s25

Principal components/correlation                 Number of obs    =         17
                                                 Number of comp.  =         16
                                                 Trace             =         25
    Rotation: (unrotated = principal)            Rho              =     1.0000

    -------------+------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
    Comp1   |      8.79197      3.20666             0.3517       0.3517
    Comp2   |      5.58531      2.63045             0.2234       0.5751
    Comp3   |      2.95486      1.02607             0.1182       0.6933
    Comp4   |      1.92879      .348271             0.0772       0.7704
    Comp5   |      1.58052       .45002             0.0632       0.8337
    Comp6   |       1.1305      .137441             0.0452       0.8789
    Comp7   |      .993059      .448469             0.0397       0.9186
    Comp8   |       .54459      .143101             0.0218       0.9404
    Comp9   |      .401489     .0527806             0.0161       0.9564
    Comp10   |      .348708      .152947             0.0139       0.9704
    Comp11   |      .195761       .01967             0.0078       0.9782
    Comp12   |      .176091     .0492475             0.0070       0.9853
    Comp13   |      .126843     .0110218             0.0051       0.9903
    Comp14   |      .115821     .0414043             0.0046       0.9950
    Comp15   |      .074417     .0231439             0.0030       0.9979
    Comp16   |     .0512731     .0512731             0.0021       1.0000
    Comp17   |            0            0             0.0000       1.0000
    Comp18   |            0            0             0.0000       1.0000
    Comp19   |            0            0             0.0000       1.0000
    Comp20   |            0            0             0.0000       1.0000
    Comp21   |            0            0             0.0000       1.0000
    Comp22   |            0            0             0.0000       1.0000
    Comp23   |            0            0             0.0000       1.0000
    Comp24   |            0            0             0.0000       1.0000
    Comp25   |            0            .             0.0000       1.0000
    -------------+------------------------------------------------------------

Principal components (eigenvectors)

    -------------+--------------------------------------------------------------------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5    Comp6    Comp7    Comp8    Comp9    Comp10    Comp11
    -------------+--------------------------------------------------------------------------------------------------------------
    s1   |  -0.2984      0.0048     -0.0653     -0.2825     -0.0472     -0.0449      0.0023      0.1522      0.0422     -0.2297      0.0297
    s2   |   0.2499      0.0176     -0.1849      0.2426      0.1190     -0.2435     -0.0298      0.4761     -0.0501      0.1380     -0.1206
    s3   |   0.2008      0.2026     -0.1933      0.1048     -0.0931      0.4313      0.1706      0.0939      0.1062     -0.0028     -0.1654
    s4   |  -0.1730      0.2432      0.0068      0.0271      0.0698      0.4728      0.3278      0.0534     -0.2510      0.0039     -0.0818
    s5   |   0.1077     -0.3159     -0.0723      0.3085      0.0426      0.1811     -0.1457      0.1591      0.3219      0.0617      0.2677
    s6   |   0.0813     -0.3122      0.0179      0.2645      0.0978      0.0649      0.3008      0.4140      0.1248     -0.3116      0.0824
    s7   |   0.1139      0.3152     -0.1115     -0.0463     -0.2338     -0.0393      0.3090     -0.0450      0.3580      0.3377     -0.0590
    s8   |   0.0067      0.3364      0.2274      0.1539      0.0345      0.0158     -0.0877     -0.1021      0.2878     -0.5287     -0.2951
    s9   |   0.1456      0.3559     -0.0566      0.0695      0.0829     -0.0776     -0.0079      0.0427      0.1190     -0.0896      0.4060
    s10   |   0.2342      0.1458      0.1827     -0.0871     -0.3939     -0.0039     -0.0852      0.0190      0.2508      0.0631      0.0162
    s11   |   0.2550     -0.1110      0.1681     -0.0855      0.2218      0.2684     -0.0789     -0.2713      0.2808      0.2053      0.1611
    s12   |  -0.1298      0.2433      0.2261      0.2504      0.3127      0.1271     -0.1109     -0.0360      0.0329      0.0263      0.2661
    s13   |   0.0492      0.1170     -0.4448     -0.0450      0.2837     -0.3404      0.1320     -0.1939      0.1322      0.0692      0.0355
    s14   |  -0.2807      0.0928      0.0034     -0.1398      0.1552     -0.3003      0.0189      0.1035      0.3583     -0.0926      0.1336
    s15   |  -0.2661      0.1052      0.2553      0.1330      0.1757     -0.0590     -0.0185      0.0424      0.1655     -0.0304     -0.1046
    s16   |   0.0267      0.2269      0.1923      0.3268     -0.3751     -0.2106      0.1834     -0.0004     -0.2362     -0.0452      0.4193
    s17   |  -0.2707     -0.0209      0.0477     -0.3216     -0.0962      0.1741      0.0812      0.1999     -0.0222      0.0999      0.4668
    s18   |   0.2026     -0.1791      0.2872     -0.1034      0.1703     -0.0121      0.3216     -0.1036      0.0832     -0.0815     -0.0157
    s19   |   0.1471      0.2571     -0.1904     -0.1717      0.3259      0.0358      0.2491      0.1610     -0.1325     -0.0665      0.0588
    s20   |   0.2057      0.1767      0.0702     -0.1947      0.3393      0.1376     -0.3209      0.0764     -0.1651      0.0234      0.1047
    s21   |   0.2347      0.1646      0.1077     -0.1817     -0.0909     -0.0208     -0.4061      0.3399     -0.0340      0.0477     -0.0373
    s22   |   0.2133      0.0274      0.3352     -0.2637      0.0102     -0.1656      0.1426      0.2659     -0.1360     -0.0665     -0.1205
    s23   |  -0.2878      0.0259      0.0966     -0.1147     -0.0004      0.1075      0.0424      0.3534      0.3218      0.3103     -0.1740
    s24   |   0.1800     -0.1203      0.3641     -0.1210      0.1476     -0.1896      0.3265     -0.0824     -0.0077      0.1671      0.0226
    s25   |  -0.2056      0.1123      0.2161      0.3439      0.1671     -0.1272     -0.0366      0.0421     -0.1724      0.4584     -0.1857
    -------------+--------------------------------------------------------------------------------------------------------------

    -------------+--------------------------------------------------+-------------
    Variable   | Comp12    Comp13    Comp14    Comp15    Comp16   | Unexplained
    -------------+--------------------------------------------------+-------------
    s1   |  -0.1433      0.0057      0.1227      0.1378      0.3413   |           0
    s2   |  -0.0960     -0.0455      0.1203     -0.2622      0.1699   |           0
    s3   |  -0.0838     -0.0841      0.1289      0.3940      0.1590   |           0
    s4   |   0.1530     -0.1031     -0.1439     -0.1000      0.1298   |           0
    s5   |  -0.0428      0.0212      0.2524     -0.1464     -0.0883   |           0
    s6   |   0.0795      0.1659     -0.2130      0.3129      0.0377   |           0
    s7   |  -0.1883      0.2372      0.0155     -0.1041      0.0048   |           0
    s8   |   0.0910      0.1592     -0.0096     -0.1252      0.0594   |           0
    s9   |   0.1639      0.2252     -0.3766     -0.0139     -0.0913   |           0
    s10   |   0.0441      0.0451      0.2195      0.0613     -0.0424   |           0
    s11   |   0.0030     -0.0755     -0.0483      0.2233      0.0654   |           0
    s12   |  -0.4371     -0.2870     -0.1885     -0.0728     -0.0876   |           0
    s13   |   0.1233     -0.0501     -0.1909      0.1298     -0.0760   |           0
    s14   |   0.1412     -0.1736      0.1664      0.2419      0.2104   |           0
    s15   |  -0.2388      0.1209      0.2735     -0.0680     -0.1104   |           0
    s16   |   0.2391     -0.3099      0.2048      0.0562      0.0326   |           0
    s17   |  -0.0846      0.4132      0.0006     -0.1014      0.0297   |           0
    s18   |   0.3166      0.1239      0.0048     -0.4556      0.1210   |           0
    s19   |  -0.1522     -0.0272      0.3618     -0.1849     -0.1084   |           0
    s20   |   0.3886      0.0667      0.3557      0.1620     -0.0025   |           0
    s21   |  -0.0764     -0.0608     -0.3643     -0.1076      0.3666   |           0
    s22   |  -0.1724      0.0224     -0.0806      0.2874     -0.5566   |           0
    s23   |   0.3759     -0.3949     -0.1346     -0.1252     -0.2470   |           0
    s24   |  -0.1893     -0.1918     -0.0109      0.0833      0.4041   |           0
    s25   |   0.1564      0.4452      0.0117      0.2526      0.1363   |           0
    -------------+--------------------------------------------------+-------------

. screeplot

. scoreplot, comp(3) mlabel(plot)

. loadingplot

. predict sco1-sco4, score
(12 components skipped)

Scoring coefficients
    sum of squares(column-loading) = 1

    -------------+--------------------------------------------------------------------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5    Comp6    Comp7    Comp8    Comp9    Comp10    Comp11
    -------------+--------------------------------------------------------------------------------------------------------------
    s1   |  -0.2984      0.0048     -0.0653     -0.2825     -0.0472     -0.0449      0.0023      0.1522      0.0422     -0.2297      0.0297
    s2   |   0.2499      0.0176     -0.1849      0.2426      0.1190     -0.2435     -0.0298      0.4761     -0.0501      0.1380     -0.1206
    s3   |   0.2008      0.2026     -0.1933      0.1048     -0.0931      0.4313      0.1706      0.0939      0.1062     -0.0028     -0.1654
    s4   |  -0.1730      0.2432      0.0068      0.0271      0.0698      0.4728      0.3278      0.0534     -0.2510      0.0039     -0.0818
    s5   |   0.1077     -0.3159     -0.0723      0.3085      0.0426      0.1811     -0.1457      0.1591      0.3219      0.0617      0.2677
    s6   |   0.0813     -0.3122      0.0179      0.2645      0.0978      0.0649      0.3008      0.4140      0.1248     -0.3116      0.0824
    s7   |   0.1139      0.3152     -0.1115     -0.0463     -0.2338     -0.0393      0.3090     -0.0450      0.3580      0.3377     -0.0590
    s8   |   0.0067      0.3364      0.2274      0.1539      0.0345      0.0158     -0.0877     -0.1021      0.2878     -0.5287     -0.2951
    s9   |   0.1456      0.3559     -0.0566      0.0695      0.0829     -0.0776     -0.0079      0.0427      0.1190     -0.0896      0.4060
    s10   |   0.2342      0.1458      0.1827     -0.0871     -0.3939     -0.0039     -0.0852      0.0190      0.2508      0.0631      0.0162
    s11   |   0.2550     -0.1110      0.1681     -0.0855      0.2218      0.2684     -0.0789     -0.2713      0.2808      0.2053      0.1611
    s12   |  -0.1298      0.2433      0.2261      0.2504      0.3127      0.1271     -0.1109     -0.0360      0.0329      0.0263      0.2661
    s13   |   0.0492      0.1170     -0.4448     -0.0450      0.2837     -0.3404      0.1320     -0.1939      0.1322      0.0692      0.0355
    s14   |  -0.2807      0.0928      0.0034     -0.1398      0.1552     -0.3003      0.0189      0.1035      0.3583     -0.0926      0.1336
    s15   |  -0.2661      0.1052      0.2553      0.1330      0.1757     -0.0590     -0.0185      0.0424      0.1655     -0.0304     -0.1046
    s16   |   0.0267      0.2269      0.1923      0.3268     -0.3751     -0.2106      0.1834     -0.0004     -0.2362     -0.0452      0.4193
    s17   |  -0.2707     -0.0209      0.0477     -0.3216     -0.0962      0.1741      0.0812      0.1999     -0.0222      0.0999      0.4668
    s18   |   0.2026     -0.1791      0.2872     -0.1034      0.1703     -0.0121      0.3216     -0.1036      0.0832     -0.0815     -0.0157
    s19   |   0.1471      0.2571     -0.1904     -0.1717      0.3259      0.0358      0.2491      0.1610     -0.1325     -0.0665      0.0588
    s20   |   0.2057      0.1767      0.0702     -0.1947      0.3393      0.1376     -0.3209      0.0764     -0.1651      0.0234      0.1047
    s21   |   0.2347      0.1646      0.1077     -0.1817     -0.0909     -0.0208     -0.4061      0.3399     -0.0340      0.0477     -0.0373
    s22   |   0.2133      0.0274      0.3352     -0.2637      0.0102     -0.1656      0.1426      0.2659     -0.1360     -0.0665     -0.1205
    s23   |  -0.2878      0.0259      0.0966     -0.1147     -0.0004      0.1075      0.0424      0.3534      0.3218      0.3103     -0.1740
    s24   |   0.1800     -0.1203      0.3641     -0.1210      0.1476     -0.1896      0.3265     -0.0824     -0.0077      0.1671      0.0226
    s25   |  -0.2056      0.1123      0.2161      0.3439      0.1671     -0.1272     -0.0366      0.0421     -0.1724      0.4584     -0.1857
    -------------+--------------------------------------------------------------------------------------------------------------

    -------------+--------------------------------------------------
    Variable   | Comp12    Comp13    Comp14    Comp15    Comp16
    -------------+--------------------------------------------------
    s1   |  -0.1433      0.0057      0.1227      0.1378      0.3413
    s2   |  -0.0960     -0.0455      0.1203     -0.2622      0.1699
    s3   |  -0.0838     -0.0841      0.1289      0.3940      0.1590
    s4   |   0.1530     -0.1031     -0.1439     -0.1000      0.1298
    s5   |  -0.0428      0.0212      0.2524     -0.1464     -0.0883
    s6   |   0.0795      0.1659     -0.2130      0.3129      0.0377
    s7   |  -0.1883      0.2372      0.0155     -0.1041      0.0048
    s8   |   0.0910      0.1592     -0.0096     -0.1252      0.0594
    s9   |   0.1639      0.2252     -0.3766     -0.0139     -0.0913
    s10   |   0.0441      0.0451      0.2195      0.0613     -0.0424
    s11   |   0.0030     -0.0755     -0.0483      0.2233      0.0654
    s12   |  -0.4371     -0.2870     -0.1885     -0.0728     -0.0876
    s13   |   0.1233     -0.0501     -0.1909      0.1298     -0.0760
    s14   |   0.1412     -0.1736      0.1664      0.2419      0.2104
    s15   |  -0.2388      0.1209      0.2735     -0.0680     -0.1104
    s16   |   0.2391     -0.3099      0.2048      0.0562      0.0326
    s17   |  -0.0846      0.4132      0.0006     -0.1014      0.0297
    s18   |   0.3166      0.1239      0.0048     -0.4556      0.1210
    s19   |  -0.1522     -0.0272      0.3618     -0.1849     -0.1084
    s20   |   0.3886      0.0667      0.3557      0.1620     -0.0025
    s21   |  -0.0764     -0.0608     -0.3643     -0.1076      0.3666
    s22   |  -0.1724      0.0224     -0.0806      0.2874     -0.5566
    s23   |   0.3759     -0.3949     -0.1346     -0.1252     -0.2470
    s24   |  -0.1893     -0.1918     -0.0109      0.0833      0.4041
    s25   |   0.1564      0.4452      0.0117      0.2526      0.1363
    -------------+--------------------------------------------------

. pwcorr sco1-sco4 light-nitrogen

             |     sco1     sco2     sco3     sco4    light moisture reaction
-------------+---------------------------------------------------------------
        sco1 |   1.0000
        sco2 |   0.0000   1.0000
        sco3 |  -0.0000  -0.0000   1.0000
        sco4 |   0.0000  -0.0000  -0.0000   1.0000
       light |  -0.6719   0.6339   0.0299  -0.2520   1.0000
    moisture |   0.7569  -0.2847   0.0814   0.4686  -0.8648   1.0000
    reaction |   0.6830  -0.4116   0.3313   0.3385  -0.8591   0.9204   1.0000
    nitrogen |   0.5991  -0.4826   0.2227   0.4562  -0.8820   0.9246   0.9673

             | nitrogen
-------------+---------
    nitrogen |   1.0000

. scatter light sco1, mlabel(plot)

. scatter moisture sco1, mlabel(plot)

. biplot s1-s25, std xneg yneg alpha(1) stretch(10)

Biplot of 17 observations and 25 variables

    Explained variance by component 1  0.3517
    Explained variance by component 2  0.2234
             Total explained variance  0.5751

.
. * added code to demonstrate equivalence with mds (without standardization)
. pca s1-s25, comp(5) cov

Principal components/covariance                  Number of obs    =         17
                                                 Number of comp.  =          5
                                                 Trace             =   1257.816
    Rotation: (unrotated = principal)            Rho              =     0.8949

    -------------+------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
    Comp1   |        537.2      206.849             0.4271       0.4271
    Comp2   |      330.351      228.047             0.2626       0.6897
    Comp3   |      102.304      6.87169             0.0813       0.7711
    Comp4   |      95.4323       35.052             0.0759       0.8469
    Comp5   |      60.3802      17.7661             0.0480       0.8949
    Comp6   |      42.6141      10.1976             0.0339       0.9288
    Comp7   |      32.4165      13.7359             0.0258       0.9546
    Comp8   |      18.6805      7.56252             0.0149       0.9694
    Comp9   |       11.118      1.61979             0.0088       0.9783
    Comp10   |      9.49823      4.04332             0.0076       0.9858
    Comp11   |      5.45492       1.4904             0.0043       0.9902
    Comp12   |      3.96451       .61508             0.0032       0.9933
    Comp13   |      3.34943      1.07295             0.0027       0.9960
    Comp14   |      2.27648      .398974             0.0018       0.9978
    Comp15   |      1.87751      .978727             0.0015       0.9993
    Comp16   |      .898785      .898785             0.0007       1.0000
    Comp17   |            0            0             0.0000       1.0000
    Comp18   |            0            0             0.0000       1.0000
    Comp19   |            0            0             0.0000       1.0000
    Comp20   |            0            0             0.0000       1.0000
    Comp21   |            0            0             0.0000       1.0000
    Comp22   |            0            0             0.0000       1.0000
    Comp23   |            0            0             0.0000       1.0000
    Comp24   |            0            0             0.0000       1.0000
    Comp25   |            0            .             0.0000       1.0000
    -------------+------------------------------------------------------------

Principal components (eigenvectors)

    -------------+--------------------------------------------------+-------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5   | Unexplained
    -------------+--------------------------------------------------+-------------
    s1   |  -0.6297     -0.3017      0.3624     -0.0313     -0.1928   |        4.28
    s2   |   0.2446      0.1117      0.1700     -0.1205      0.3161   |       8.775
    s3   |   0.2205      0.4382      0.4183      0.4026     -0.3143   |       1.654
    s4   |  -0.2065      0.1400      0.1418      0.5964      0.0202   |       4.467
    s5   |   0.3560     -0.3587      0.1133      0.0381     -0.0576   |       17.88
    s6   |   0.4153     -0.5544      0.1964      0.3715      0.0921   |       10.68
    s7   |   0.0049      0.2335      0.0803      0.0434     -0.0262   |       6.594
    s8   |  -0.0322      0.1282     -0.1358      0.1336      0.1062   |       4.423
    s9   |   0.0222      0.1913      0.0209      0.0269      0.1350   |       2.665
    s10   |   0.0835      0.1605     -0.1947     -0.0399     -0.2585   |       3.811
    s11   |   0.1104      0.0164     -0.0843     -0.0465     -0.1395   |       4.502
    s12   |  -0.0630      0.0509     -0.1154      0.1801      0.2194   |       3.655
    s13   |   0.0114      0.1530      0.5251     -0.3199      0.4510   |       2.447
    s14   |  -0.1462     -0.0437      0.0380     -0.0175      0.1671   |       1.912
    s15   |  -0.1535     -0.0566     -0.1660      0.1892      0.2509   |       2.526
    s16   |   0.0009      0.1409     -0.2516      0.2052      0.1655   |       13.67
    s17   |  -0.1757     -0.0982      0.0347      0.0687     -0.1868   |       2.739
    s18   |   0.0870     -0.0336     -0.1167     -0.0240     -0.0758   |       4.923
    s19   |   0.0205      0.1555      0.1716     -0.0116      0.0639   |        4.58
    s20   |   0.0359      0.0957     -0.0312     -0.0536     -0.0225   |       4.474
    s21   |   0.0454      0.1019     -0.0789     -0.0808     -0.1032   |       3.051
    s22   |   0.0532      0.0462     -0.1589     -0.0556     -0.1094   |       6.041
    s23   |  -0.1538     -0.0812     -0.0048      0.1361      0.0066   |       4.861
    s24   |   0.0580     -0.0142     -0.1427     -0.0366     -0.0299   |       4.245
    s25   |  -0.1069     -0.0285     -0.2108      0.2287      0.4437   |       3.295
    -------------+--------------------------------------------------+-------------

. scoreplot, comp(2) mlabel(plot)

. mds s1-s25, config noplot id(plot)

Classical metric multidimensional scaling
    dissimilarity  : L2, computed on 25 variables

                                             Number of obs        =         17
    Eigenvalues > 0      =        16         Mardia fit measure 1 =     0.6897
    Retained dimensions  =         2         Mardia fit measure 2 =     0.9371

    -------------+------------------------------------------------------------
                 |                   abs(eigenvalue)          (eigenvalue)^2
      Dimension  |  Eigenvalue      Percent    Cumul.       Percent    Cumul.
    -------------+------------------------------------------------------------
              1  |    8595.198        42.71     42.71         67.99     67.99
              2  |   5285.6133        26.26     68.97         25.71     93.71
    -------------+------------------------------------------------------------
              3  |   1636.8631         8.13     77.11          2.47     96.17
              4  |   1526.9161         7.59     84.69          2.15     98.32
              5  |   966.08343         4.80     89.49          0.86     99.18
              6  |   681.82604         3.39     92.88          0.43     99.60
              7  |   518.66383         2.58     95.46          0.25     99.85
              8  |   298.88865         1.49     96.94          0.08     99.93
              9  |   177.88838         0.88     97.83          0.03     99.96
             10  |   151.97173         0.76     98.58          0.02     99.98
    -------------+------------------------------------------------------------

Configuration in 2-dimensional Euclidean space (principal normalization)

    plot   | dim1    dim2
    ------+----------------------------
    1   |      28.8934         13.5015
    2   |      35.3036         14.6290
    3   |      39.3429         14.7996
    4   |      29.4377          7.8792
    5   |      13.6051         -1.7839
    6   |       6.2638         -7.2729
    7   |       5.9312         -8.1215
    8   |      -8.2158        -21.9365
    9   |      -7.5651        -31.9075
    10   |      -9.4674        -26.6580
    11   |     -10.2235         -2.5168
    12   |      -9.8597        -12.9532
    13   |      -4.2394         -3.7437
    14   |     -15.5680         -2.3882
    15   |     -19.2499          4.3623
    16   |     -33.5732         30.0218
    17   |     -40.8156         34.0887
    ------+----------------------------

. * note: eigenvalues multiplied by (n-1)
. mdsconfig, xneg yneg

.
. * calf data
. use calf, clear

. * note: polychoric is an add-on command; Stata has a tetrachoric command for binary variables
. polychoric age sex-umb /* add verbose option to see lots of details! */

Polychoric correlation matrix

              age         sex        attd        dehy         eye        jnts        post       pulse        resp        temp
  age           1
  sex   .01026004           1
 attd  -.14081148  -.04479291           1
 dehy  -.12612086  -.14580851   .38207292           1
  eye    .0441196   .33056917   .15004459  -.09936422           1
 jnts    .0008926   .04775808   .08356658  -.03024093   .59635231           1
 post  -.09964047  -.06227926   .87386637   .39732633   .32318563   .08395814           1
pulse  -.18651421   .01407062  -.13078394  -.03287323   .07455487    .2575224  -.10822607           1
 resp  -.26418451  -.09805846   .17307776   -.0249882   .03454427  -.00540613   .19582088   .16964738           1
 temp  -.09753186   .06242938   -.3340238  -.30588409   .19888097   .07138087  -.37218583   .23121708   .22578032           1
  umb  -.05512062   .15237046   .14517111  -.08484105   .21072786    .3722088   .04435448   .12997537   .09122346   .12945084

              umb
  umb           1

. correlate age sex-umb /* note: comparison is not with pwcorr */
(obs=213)

             |      age      sex     attd     dehy      eye     jnts     post    pulse     resp     temp      umb
-------------+---------------------------------------------------------------------------------------------------
         age |   1.0000
         sex |   0.0080   1.0000
        attd |  -0.1175  -0.0297   1.0000
        dehy |  -0.1261  -0.1158   0.3201   1.0000
         eye |   0.0175   0.0894   0.0412  -0.0341   1.0000
        jnts |  -0.0104  -0.0071   0.0226  -0.0199   0.2205   1.0000
        post |  -0.0903  -0.0439   0.6322   0.3516   0.1025   0.0598   1.0000
       pulse |  -0.1865   0.0112  -0.1084  -0.0329   0.0245   0.1285  -0.0923   1.0000
        resp |  -0.2642  -0.0768   0.1435  -0.0250   0.0115  -0.0156   0.1738   0.1696   1.0000
        temp |  -0.0975   0.0505  -0.2839  -0.3059   0.0564   0.0233  -0.3447   0.2312   0.2258   1.0000
         umb |  -0.0386   0.0876   0.0856  -0.0633   0.0626   0.1468   0.0280   0.0920   0.0653   0.0925   1.0000


. * for display of correlations only
. foreach var of varlist age sex-umb {
  2.   egen s`var'=std(`var')
  3.   }
(1 missing value generated)
(2 missing values generated)
(6 missing values generated)
(14 missing values generated)
(18 missing values generated)
(11 missing values generated)
(6 missing values generated)
(9 missing values generated)
(19 missing values generated)
(7 missing values generated)
(11 missing values generated)

. sort case

. polychoric age sex-umb

Polychoric correlation matrix

              age         sex        attd        dehy         eye        jnts        post       pulse        resp        temp
  age           1
  sex   .01026004           1
 attd  -.14081148  -.04479291           1
 dehy  -.12612086  -.14580851   .38207292           1
  eye    .0441196   .33056917   .15004459  -.09936422           1
 jnts    .0008926   .04775808   .08356658  -.03024093   .59635231           1
 post  -.09964047  -.06227926   .87386637   .39732633   .32318563   .08395814           1
pulse  -.18651421   .01407062  -.13078394  -.03287323   .07455487    .2575224  -.10822607           1
 resp  -.26418451  -.09805846   .17307776   -.0249882   .03454427  -.00540613   .19582088   .16964738           1
 temp  -.09753186   .06242938   -.3340238  -.30588409   .19888097   .07138087  -.37218583   .23121708   .22578032           1
  umb  -.05512062   .15237046   .14517111  -.08484105   .21072786    .3722088   .04435448   .12997537   .09122346   .12945084

              umb
  umb           1

. matrix define polycorr=r(R)

. sort case /* the polychoric command resorts the data, so we have to reset */

. pcamat polycorr, n(213) /* n=number of complete rows */

Principal components/correlation                 Number of obs    =        213
                                                 Number of comp.  =         11
                                                 Trace             =         11
    Rotation: (unrotated = principal)            Rho              =     1.0000

    -------------+------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
    Comp1   |      2.48325      .341845             0.2257       0.2257
    Comp2   |       2.1414      .636921             0.1947       0.4204
    Comp3   |      1.50448      .489274             0.1368       0.5572
    Comp4   |      1.01521      .100485             0.0923       0.6495
    Comp5   |      .914724     .0820931             0.0832       0.7326
    Comp6   |      .832631      .155607             0.0757       0.8083
    Comp7   |      .677024     .0613992             0.0615       0.8699
    Comp8   |      .615625      .120503             0.0560       0.9259
    Comp9   |      .495122      .240377             0.0450       0.9709
    Comp10   |      .254746      .188966             0.0232       0.9940
    Comp11   |     .0657794            .             0.0060       1.0000
    -------------+------------------------------------------------------------

Principal components (eigenvectors)

    -------------+--------------------------------------------------------------------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5    Comp6    Comp7    Comp8    Comp9    Comp10    Comp11
    -------------+--------------------------------------------------------------------------------------------------------------
    age   |  -0.1121     -0.0940      0.5299     -0.1212      0.4967      0.0424      0.5664      0.3285      0.0306      0.0698     -0.0066
    sex   |  -0.0561      0.2508      0.3094      0.5392     -0.5986      0.0150      0.2841      0.1018      0.1680      0.2384      0.1129
    attd   |   0.5781      0.0125     -0.0264      0.1330      0.0732     -0.0995      0.0892     -0.0347     -0.3456      0.4561     -0.5435
    dehy   |   0.3715     -0.1919     -0.0889     -0.3194     -0.3236      0.1206     -0.0873      0.7093      0.2804     -0.0686     -0.0444
    eye   |   0.1546      0.5117      0.2799      0.1145      0.0951      0.4031     -0.1842      0.0176      0.0111     -0.5365     -0.3591
    jnts   |   0.1048      0.5024      0.1699     -0.4449      0.0937      0.0759     -0.2225     -0.1633      0.3302      0.5183      0.2036
    post   |   0.5926      0.0303      0.0104      0.1322      0.1192      0.1243      0.1078     -0.0660     -0.2556     -0.1660      0.7013
    pulse   |  -0.0932      0.3005     -0.3531     -0.4363     -0.2932      0.2076      0.5994     -0.1106     -0.2720     -0.0906     -0.0569
    resp   |   0.1119      0.1640     -0.5561      0.3306      0.3572      0.0184      0.2784      0.0273      0.5774     -0.0029     -0.0502
    temp   |  -0.3160      0.3185     -0.2702      0.1976      0.1981      0.1521     -0.2238      0.5488     -0.4341      0.2511      0.1466
    umb   |   0.0709      0.3968      0.0252     -0.0875      0.0022     -0.8504      0.0313      0.1786     -0.0495     -0.2650      0.0207
    -------------+--------------------------------------------------------------------------------------------------------------

    -------------+-------------
    Variable   | Unexplained
    -------------+-------------
    age   |           0
    sex   |           0
    attd   |           0
    dehy   |           0
    eye   |           0
    jnts   |           0
    post   |           0
    pulse   |           0
    resp   |           0
    temp   |           0
    umb   |           0
    -------------+-------------

. mkmat sage-sumb, matrix(sdata)

. *matrix list sdata
. matrix define load=e(L)

. matrix define scomat = sdata*load

. *matrix list scomat
. svmat scomat

. twoway (scatter scomat2 scomat1 if sepsis==0, msymbol(smx)) (scatter scomat2 scomat1 if sepsis==1, msymbol(smcircle_hollow)), ytitle(2nd principal component) xtitle(1st principal component) title(Polychoric PCA (x=no sepsis, o=sepsis), size(medium)) legend(off)

.
. pca age sex-umb

Principal components/correlation                 Number of obs    =        213
                                                 Number of comp.  =         11
                                                 Trace             =         11
    Rotation: (unrotated = principal)            Rho              =     1.0000

    -------------+------------------------------------------------------------
       Component |   Eigenvalue   Difference         Proportion   Cumulative
    -------------+------------------------------------------------------------
    Comp1   |      2.20632      .557409             0.2006       0.2006
    Comp2   |      1.64891      .329284             0.1499       0.3505
    Comp3   |      1.31963      .291605             0.1200       0.4704
    Comp4   |      1.02802     .0970539             0.0935       0.5639
    Comp5   |      .930968     .0103964             0.0846       0.6485
    Comp6   |      .920572      .183806             0.0837       0.7322
    Comp7   |      .736766     .0253664             0.0670       0.7992
    Comp8   |        .7114      .106639             0.0647       0.8639
    Comp9   |       .60476     .0606445             0.0550       0.9188
    Comp10   |      .544116      .195578             0.0495       0.9683
    Comp11   |      .348538            .             0.0317       1.0000
    -------------+------------------------------------------------------------

Principal components (eigenvectors)

    -------------+--------------------------------------------------------------------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5    Comp6    Comp7    Comp8    Comp9    Comp10    Comp11
    -------------+--------------------------------------------------------------------------------------------------------------
    age   |  -0.0952     -0.4431      0.3102     -0.0506      0.1656      0.3516      0.6483      0.1790      0.2882     -0.0798      0.0534
    sex   |  -0.0973      0.0219      0.3256      0.7102     -0.1504     -0.4916      0.1574     -0.1972      0.1971     -0.1131      0.0096
    attd   |   0.5363      0.1414      0.0534      0.1835      0.0699      0.1255      0.1354     -0.0686     -0.0703      0.4719      0.6201
    dehy   |   0.4308     -0.0289     -0.1336     -0.2059     -0.3052     -0.2640     -0.0995      0.3691      0.6485     -0.1481      0.0431
    eye   |   0.0242      0.1907      0.5419     -0.1440      0.5037     -0.2939     -0.1886      0.4842     -0.1547     -0.0904      0.0802
    jnts   |   0.0093      0.2445      0.5130     -0.4838     -0.1412      0.0249     -0.0343     -0.6049      0.2297     -0.0320      0.0371
    post   |   0.5576      0.1350      0.0828      0.0855      0.1441      0.0429      0.2150     -0.0639     -0.0825      0.1467     -0.7453
    pulse   |  -0.1580      0.4427     -0.0781     -0.2397     -0.3818     -0.2586      0.6011      0.2372     -0.2856      0.0517      0.0320
    resp   |   0.0628      0.5115     -0.2982      0.1280      0.3999      0.1947      0.1740     -0.1321      0.1896     -0.5733      0.1375
    temp   |  -0.4094      0.3514     -0.0902      0.0668      0.2139      0.0737     -0.0325      0.1097      0.5004      0.5977     -0.1559
    umb   |  -0.0133      0.2946      0.3319      0.2767     -0.4538      0.5918     -0.2259      0.3130     -0.0332     -0.1301     -0.0556
    -------------+--------------------------------------------------------------------------------------------------------------

    -------------+-------------
    Variable   | Unexplained
    -------------+-------------
    age   |           0
    sex   |           0
    attd   |           0
    dehy   |           0
    eye   |           0
    jnts   |           0
    post   |           0
    pulse   |           0
    resp   |           0
    temp   |           0
    umb   |           0
    -------------+-------------

. predict sco1-sco6
(score assumed)
(5 components skipped)

Scoring coefficients
    sum of squares(column-loading) = 1

    -------------+--------------------------------------------------------------------------------------------------------------
    Variable   | Comp1    Comp2    Comp3    Comp4    Comp5    Comp6    Comp7    Comp8    Comp9    Comp10    Comp11
    -------------+--------------------------------------------------------------------------------------------------------------
    age   |  -0.0952     -0.4431      0.3102     -0.0506      0.1656      0.3516      0.6483      0.1790      0.2882     -0.0798      0.0534
    sex   |  -0.0973      0.0219      0.3256      0.7102     -0.1504     -0.4916      0.1574     -0.1972      0.1971     -0.1131      0.0096
    attd   |   0.5363      0.1414      0.0534      0.1835      0.0699      0.1255      0.1354     -0.0686     -0.0703      0.4719      0.6201
    dehy   |   0.4308     -0.0289     -0.1336     -0.2059     -0.3052     -0.2640     -0.0995      0.3691      0.6485     -0.1481      0.0431
    eye   |   0.0242      0.1907      0.5419     -0.1440      0.5037     -0.2939     -0.1886      0.4842     -0.1547     -0.0904      0.0802
    jnts   |   0.0093      0.2445      0.5130     -0.4838     -0.1412      0.0249     -0.0343     -0.6049      0.2297     -0.0320      0.0371
    post   |   0.5576      0.1350      0.0828      0.0855      0.1441      0.0429      0.2150     -0.0639     -0.0825      0.1467     -0.7453
    pulse   |  -0.1580      0.4427     -0.0781     -0.2397     -0.3818     -0.2586      0.6011      0.2372     -0.2856      0.0517      0.0320
    resp   |   0.0628      0.5115     -0.2982      0.1280      0.3999      0.1947      0.1740     -0.1321      0.1896     -0.5733      0.1375
    temp   |  -0.4094      0.3514     -0.0902      0.0668      0.2139      0.0737     -0.0325      0.1097      0.5004      0.5977     -0.1559
    umb   |  -0.0133      0.2946      0.3319      0.2767     -0.4538      0.5918     -0.2259      0.3130     -0.0332     -0.1301     -0.0556
    -------------+--------------------------------------------------------------------------------------------------------------

. list sco1-sco5 scomat1-scomat5 in 250/254

     +-----------------------------------------------------------------------------------------------------------------------+
     |      sco1        sco2        sco3        sco4        sco5     scomat1     scomat2     scomat3     scomat4     scomat5 |
     +-----------------------------------------------------------------------------------------------------------------------+
250. |  1.326669   -.4072271   -.0941716    .7627372    .1074602    1.130997   -.6607679    .3077689    .7555366   -.7725231 |
251. |  .9534625    .7103059   -.5290972   -.2719495   -1.059138    .8767514   -.0802605   -1.011767   -.8056126   -.1324275 |
252. |  .8450878    1.529826   -1.726462    .1313511    2.096028     .851383   -.1763431   -2.277633    1.427279    1.672969 |
253. | -.1032492    .2870813   -1.062035   -.2860836    1.260549   -.1976646   -.4571058    -1.03413    .4784389    1.272845 |
254. |  -2.13716    .1485368   -1.182741   -1.420211   -.5071669   -2.249265   -.1667564   -1.140397   -1.217268   -.3986959 |
     +-----------------------------------------------------------------------------------------------------------------------+

. list age sex-umb in 250/254

     +-------------------------------------------------------------------------------------+
     | age      sex        attd   dehy   eye   jnts       post   pulse   resp   temp   umb |
     +-------------------------------------------------------------------------------------+
250. |   8     male   depressed   10.0    no      0    lateral     100     40   37.1    no |
251. |   5   female   depressed   15.0    no      0    sternal     100     42   39.1   yes |
252. |   3   female   depressed    6.5    no      0    lateral      85     90   39.6    no |
253. |   8   female   depressed    5.0    no      0    sternal     100     60   38.8    no |
254. |   5   female      bright    7.0    no      0   standing     150     28   39.7    no |
     +-------------------------------------------------------------------------------------+

. twoway (scatter sco2 sco1 if sepsis==0, msymbol(smx)) (scatter sco2 sco1 if sepsis==1, msymbol(smcircle_hollow)), ytitle(2nd principal component) xtitle(1st principal component) title(Ordinary PCA (x=no sepsis, o=sepsis), size(medium)) legend(off)

.
. tabstat sco1-sco6 scomat1-scomat6, statistics( mean semean ) by(sepsis)

Summary statistics: mean, se(mean)
  by categories of: sepsis (sepsis (0=no, 1=yes))

sepsis   |      sco1      sco2      sco3      sco4      sco5      sco6   scomat1   scomat2   scomat3   scomat4   scomat5   scomat6
-------+------------------------------------------------------------------------------------------------------------------------
no   | -.2813099 -.1836713 -.1133812   .013458  -.027279 -.0472951 -.3649133 -.1695357  .0056898 -.0259087 -.0454369  .0122261
       |  .1206508  .0919026  .0729616  .0752472  .0710346  .0697055  .1148666  .0742771  .0930896  .0737726  .0758695  .0671289
-------+------------------------------------------------------------------------------------------------------------------------
yes   |  .7009691  .4576728  .2825236 -.0335347  .0679738  .1178502  .7286027   .270085 -.1526351 -.0543031  .0531672 -.1816857
       |  .1582304  .1940434  .2029532   .154961  .1489091  .1500943  .1540909  .2072477  .1614268   .151281   .129867  .1445498
-------+------------------------------------------------------------------------------------------------------------------------
Total   | -1.08e-09 -7.00e-11  2.37e-09  2.82e-09 -1.33e-09  1.42e-10 -.0517467 -.0436349 -.0396521 -.0340405 -.0171982 -.0433073
       |  .1017758   .087985  .0787111  .0694723  .0661116  .0657414  .0989125   .080448  .0808757  .0679854  .0655906  .0634057
-------+------------------------------------------------------------------------------------------------------------------------

. foreach var of varlist sco1-sco6 scomat1-scomat6 {
  2.   ttest `var', by(sepsis) unpaired unequal
  3.   }

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.2813099    .1206508    1.487483   -.5196917   -.0429282
     yes |      61    .7009691    .1582304    1.235819    .3844611    1.017477
---------+--------------------------------------------------------------------
combined |     213   -1.08e-09    .1017758    1.485369   -.2006221    .2006221
---------+--------------------------------------------------------------------
    diff |            -.982279    .1989811               -1.375875   -.5886825
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -4.9365
Ho: diff = 0                     Satterthwaite's degrees of freedom =  132.283

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 1.0000

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.1836713    .0919026    1.133052   -.3652524   -.0020902
     yes |      61    .4576728    .1940434    1.515527    .0695283    .8458173
---------+--------------------------------------------------------------------
combined |     213   -7.00e-11     .087985    1.284099   -.1734376    .1734376
---------+--------------------------------------------------------------------
    diff |           -.6413441    .2147066               -1.068017   -.2146716
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -2.9871
Ho: diff = 0                     Satterthwaite's degrees of freedom =  88.1739

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0018         Pr(|T| > |t|) = 0.0036          Pr(T > t) = 0.9982

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.1133812    .0729616    .8995311   -.2575386    .0307763
     yes |      61    .2825236    .2029532    1.585115   -.1234432    .6884904
---------+--------------------------------------------------------------------
combined |     213    2.37e-09    .0787111     1.14875   -.1551566    .1551566
---------+--------------------------------------------------------------------
    diff |           -.3959048    .2156696               -.8254474    .0336379
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -1.8357
Ho: diff = 0                     Satterthwaite's degrees of freedom =  76.0065

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0352         Pr(|T| > |t|) = 0.0703          Pr(T > t) = 0.9648

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152     .013458    .0752472    .9277093   -.1352153    .1621312
     yes |      61   -.0335347     .154961    1.210284   -.3435028    .2764335
---------+--------------------------------------------------------------------
combined |     213    2.82e-09    .0694723    1.013914   -.1369449    .1369449
---------+--------------------------------------------------------------------
    diff |            .0469926    .1722645               -.2952589    .3892442
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =   0.2728
Ho: diff = 0                     Satterthwaite's degrees of freedom =  89.6508

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.6072         Pr(|T| > |t|) = 0.7856          Pr(T > t) = 0.3928

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152    -.027279    .0710346     .875773    -.167629    .1130711
     yes |      61    .0679738    .1489091    1.163018   -.2298888    .3658364
---------+--------------------------------------------------------------------
combined |     213   -1.33e-09    .0661116     .964867   -.1303203    .1303203
---------+--------------------------------------------------------------------
    diff |           -.0952528    .1649844                -.423094    .2325885
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -0.5773
Ho: diff = 0                     Satterthwaite's degrees of freedom =  88.5914

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.2826         Pr(|T| > |t|) = 0.5652          Pr(T > t) = 0.7174

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.0472951    .0697055     .859387   -.1850192    .0904289
     yes |      61    .1178502    .1500943    1.172274   -.1823831    .4180835
---------+--------------------------------------------------------------------
combined |     213    1.42e-10    .0657414    .9594644   -.1295906    .1295906
---------+--------------------------------------------------------------------
    diff |           -.1651453    .1654906               -.4940725    .1637819
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -0.9979
Ho: diff = 0                     Satterthwaite's degrees of freedom =  87.0631

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.1605         Pr(|T| > |t|) = 0.3211          Pr(T > t) = 0.8395

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.3649133    .1148666     1.41617   -.5918665     -.13796
     yes |      61    .7286027    .1540909    1.203488    .4203751     1.03683
---------+--------------------------------------------------------------------
combined |     213   -.0517467    .0989125    1.443581   -.2467247    .1432313
---------+--------------------------------------------------------------------
    diff |           -1.093516    .1921934               -1.473766   -.7132661
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -5.6897
Ho: diff = 0                     Satterthwaite's degrees of freedom =  129.341

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 1.0000

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.1695357    .0742771    .9157492   -.3162922   -.0227791
     yes |      61     .270085    .2072477    1.618657   -.1444722    .6846422
---------+--------------------------------------------------------------------
combined |     213   -.0436349     .080448    1.174099   -.2022153    .1149455
---------+--------------------------------------------------------------------
    diff |           -.4396206    .2201561               -.8781083    -.001133
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -1.9969
Ho: diff = 0                     Satterthwaite's degrees of freedom =  75.9062

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0247         Pr(|T| > |t|) = 0.0494          Pr(T > t) = 0.9753

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152    .0056898    .0930896    1.147685   -.1782365    .1896161
     yes |      61   -.1526351    .1614268    1.260783   -.4755367    .1702666
---------+--------------------------------------------------------------------
combined |     213   -.0396521    .0808757    1.180342   -.1990757    .1197715
---------+--------------------------------------------------------------------
    diff |            .1583249    .1863445               -.2112861    .5279359
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =   0.8496
Ho: diff = 0                     Satterthwaite's degrees of freedom =  102.056

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.8012         Pr(|T| > |t|) = 0.3975          Pr(T > t) = 0.1988

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.0259087    .0737726    .9095302   -.1716686    .1198512
     yes |      61   -.0543031     .151281    1.181542   -.3569102    .2483039
---------+--------------------------------------------------------------------
combined |     213   -.0340405    .0679854    .9922142   -.1680544    .0999735
---------+--------------------------------------------------------------------
    diff |            .0283944    .1683103               -.3059879    .3627767
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =   0.1687
Ho: diff = 0                     Satterthwaite's degrees of freedom =  89.9094

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.5668         Pr(|T| > |t|) = 0.8664          Pr(T > t) = 0.4332

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152   -.0454369    .0758695    .9353825   -.1953399     .104466
     yes |      61    .0531672     .129867    1.014294   -.2066055    .3129398
---------+--------------------------------------------------------------------
combined |     213   -.0171982    .0655906     .957263   -.1464915    .1120951
---------+--------------------------------------------------------------------
    diff |           -.0986041    .1504049               -.3968908    .1996826
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =  -0.6556
Ho: diff = 0                     Satterthwaite's degrees of freedom =   103.17

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.2568         Pr(|T| > |t|) = 0.5135          Pr(T > t) = 0.7432

Two-sample t test with unequal variances
---------+--------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
      no |     152    .0122261    .0671289     .827621   -.1204072    .1448594
     yes |      61   -.1816857    .1445498     1.12897   -.4708284    .1074569
---------+--------------------------------------------------------------------
combined |     213   -.0433073    .0634057    .9253751   -.1682936     .081679
---------+--------------------------------------------------------------------
    diff |            .1939118    .1593767               -.1228634    .5106871
---------+--------------------------------------------------------------------
    diff = mean(no) - mean(yes)                                   t =   1.2167
Ho: diff = 0                     Satterthwaite's degrees of freedom =  87.0618

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.8865         Pr(|T| > |t|) = 0.2270          Pr(T > t) = 0.1135

. logit sepsis sco1-sco6

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -108.69433
Iteration 2:   log likelihood = -108.11491
Iteration 3:   log likelihood = -108.11277
Iteration 4:   log likelihood = -108.11277

Logistic regression                             Number of obs     =        213
                                                LR chi2(6)        =      38.90
                                                Prob > chi2       =     0.0000
Log likelihood = -108.11277                     Pseudo R2         =     0.1525

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        sco1 |    .5396573     .123814      4.36    0.000      .2969863     .7823283
        sco2 |    .4392358    .1345844      3.26    0.001      .1754553     .7030163
        sco3 |    .3085128    .1455604      2.12    0.034      .0232196      .593806
        sco4 |   -.0485172    .1645482     -0.29    0.768     -.3710257     .2739912
        sco5 |    .0911894     .165198      0.55    0.581     -.2325927     .4149715
        sco6 |    .2045786    .1697519      1.21    0.228     -.1281291     .5372863
       _cons |   -1.094847    .1782135     -6.14    0.000     -1.444139    -.7455552
-------------+----------------------------------------------------------------

. logit sepsis sco1-sco3

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -109.58412
Iteration 2:   log likelihood = -109.02695
Iteration 3:   log likelihood = -109.02539
Iteration 4:   log likelihood = -109.02539

Logistic regression                             Number of obs     =        213
                                                LR chi2(3)        =      37.07
                                                Prob > chi2       =     0.0000
Log likelihood = -109.02539                     Pseudo R2         =     0.1453

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        sco1 |    .5356338    .1229745      4.36    0.000      .2946082     .7766594
        sco2 |    .4401884    .1343814      3.28    0.001      .1768057     .7035711
        sco3 |    .3031327    .1452505      2.09    0.037       .018447     .5878185
       _cons |   -1.089565    .1770145     -6.16    0.000     -1.436507    -.7426225
-------------+----------------------------------------------------------------

. logit sepsis sco1-sco2

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -111.92595
Iteration 2:   log likelihood = -111.39927
Iteration 3:   log likelihood = -111.39815
Iteration 4:   log likelihood = -111.39815

Logistic regression                             Number of obs     =        213
                                                LR chi2(2)        =      32.33
                                                Prob > chi2       =     0.0000
Log likelihood = -111.39815                     Pseudo R2         =     0.1267

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
        sco1 |    .5269849    .1218987      4.32    0.000      .2880679     .7659019
        sco2 |    .4419346    .1308304      3.38    0.001      .1855117     .6983575
       _cons |   -1.086557    .1751577     -6.20    0.000      -1.42986    -.7432543
-------------+----------------------------------------------------------------

. logit sepsis scomat1-scomat6

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -108.94862
Iteration 2:   log likelihood = -108.31062
Iteration 3:   log likelihood =  -108.3086
Iteration 4:   log likelihood =  -108.3086

Logistic regression                             Number of obs     =        213
                                                LR chi2(6)        =      38.51
                                                Prob > chi2       =     0.0000
Log likelihood =  -108.3086                     Pseudo R2         =     0.1509

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
     scomat1 |    .6675617    .1330421      5.02    0.000      .4068039     .9283195
     scomat2 |    .4025592    .1443202      2.79    0.005      .1196968     .6854216
     scomat3 |   -.0644614    .1431169     -0.45    0.652     -.3449654     .2160426
     scomat4 |       .0003    .1669568      0.00    0.999     -.3269294     .3275294
     scomat5 |    .1548837    .1716432      0.90    0.367     -.1815307     .4912981
     scomat6 |   -.1654206    .1702014     -0.97    0.331     -.4990092     .1681681
       _cons |   -1.055029    .1770475     -5.96    0.000     -1.402036    -.7080225
-------------+----------------------------------------------------------------

. logit sepsis scomat1-scomat3

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -109.76602
Iteration 2:   log likelihood = -109.19102
Iteration 3:   log likelihood = -109.18951
Iteration 4:   log likelihood = -109.18951

Logistic regression                             Number of obs     =        213
                                                LR chi2(3)        =      36.75
                                                Prob > chi2       =     0.0000
Log likelihood = -109.18951                     Pseudo R2         =     0.1440

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
     scomat1 |    .6622029    .1318271      5.02    0.000      .4038266     .9205792
     scomat2 |    .4176903    .1456581      2.87    0.004      .1322057     .7031749
     scomat3 |   -.0592413    .1413369     -0.42    0.675     -.3362566     .2177739
       _cons |   -1.040415    .1749272     -5.95    0.000     -1.383266    -.6975643
-------------+----------------------------------------------------------------

. logit sepsis scomat1-scomat2

Iteration 0:   log likelihood = -127.56209
Iteration 1:   log likelihood = -109.82172
Iteration 2:   log likelihood = -109.27859
Iteration 3:   log likelihood = -109.27734
Iteration 4:   log likelihood = -109.27734

Logistic regression                             Number of obs     =        213
                                                LR chi2(2)        =      36.57
                                                Prob > chi2       =     0.0000
Log likelihood = -109.27734                     Pseudo R2         =     0.1433

-------------+----------------------------------------------------------------
       sepsis |      Coef.    Std. Err.       z    P>|z|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
     scomat1 |    .6624942    .1316674      5.03    0.000      .4044308     .9205576
     scomat2 |    .4274262     .144854      2.95    0.003      .1435175     .7113348
       _cons |   -1.033279    .1737881     -5.95    0.000     -1.373898     -.692661
-------------+----------------------------------------------------------------

.
. * factor analysis
. factormat polycorr, n(213) pcf
(obs=213)

Factor analysis/correlation                      Number of obs    =        213
    Method: principal-component factors          Retained factors =          4
    Rotation: (unrotated)                        Number of params =         38

    -------------+------------------------------------------------------------
         Factor  | Eigenvalue     Difference        Proportion   Cumulative
    -------------+------------------------------------------------------------
    Factor1    |      2.48325      0.34184            0.2257       0.2257
    Factor2    |      2.14140      0.63692            0.1947       0.4204
    Factor3    |      1.50448      0.48927            0.1368       0.5572
    Factor4    |      1.01521      0.10049            0.0923       0.6495
    Factor5    |      0.91472      0.08209            0.0832       0.7326
    Factor6    |      0.83263      0.15561            0.0757       0.8083
    Factor7    |      0.67702      0.06140            0.0615       0.8699
    Factor8    |      0.61562      0.12050            0.0560       0.9259
    Factor9    |      0.49512      0.24038            0.0450       0.9709
    Factor10    |      0.25475      0.18897            0.0232       0.9940
    Factor11    |      0.06578            .            0.0060       1.0000
    -------------+------------------------------------------------------------
    LR test: independent vs. saturated:  chi2(55) =  801.64 Prob>chi2 = 0.0000

Factor loadings (pattern matrix) and unique variances

    -------------+----------------------------------------+--------------
    Variable   | Factor1    Factor2    Factor3    Factor4   | Uniqueness
    -------------+----------------------------------------+--------------
    age   |  -0.1766     -0.1376      0.6499     -0.1222   |     0.5125
    sex   |  -0.0884      0.3670      0.3796      0.5433   |     0.4183
    attd   |   0.9109      0.0182     -0.0324      0.1340   |     0.1509
    dehy   |   0.5854     -0.2808     -0.1091     -0.3218   |     0.4630
    eye   |   0.2437      0.7489      0.3433      0.1154   |     0.2486
    jnts   |   0.1652      0.7351      0.2083     -0.4483   |     0.1879
    post   |   0.9338      0.0444      0.0127      0.1332   |     0.1081
    pulse   |  -0.1468      0.4398     -0.4331     -0.4396   |     0.4042
    resp   |   0.1764      0.2400     -0.6820      0.3331   |     0.3352
    temp   |  -0.4979      0.4661     -0.3314      0.1991   |     0.3853
    umb   |   0.1117      0.5807      0.0309     -0.0881   |     0.6416
    -------------+----------------------------------------+--------------

. loadingplot

. rotate, varimax

Factor analysis/correlation                      Number of obs    =        213
    Method: principal-component factors          Retained factors =          4
    Rotation: orthogonal varimax (Kaiser off)    Number of params =         38

    -------------+------------------------------------------------------------
         Factor  | Variance     Difference        Proportion   Cumulative
    -------------+------------------------------------------------------------
    Factor1    |      2.45570      0.59006            0.2232       0.2232
    Factor2    |      1.86563      0.33343            0.1696       0.3928
    Factor3    |      1.53220      0.24139            0.1393       0.5321
    Factor4    |      1.29081            .            0.1173       0.6495
    -------------+------------------------------------------------------------
    LR test: independent vs. saturated:  chi2(55) =  801.64 Prob>chi2 = 0.0000

Rotated factor loadings (pattern matrix) and unique variances

    -------------+----------------------------------------+--------------
    Variable   | Factor1    Factor2    Factor3    Factor4   | Uniqueness
    -------------+----------------------------------------+--------------
    age   |  -0.1523      0.0279     -0.6623      0.1576   |     0.5125
    sex   |  -0.0313      0.1012     -0.0285      0.7548   |     0.4183
    attd   |   0.9142      0.0574      0.0993      0.0163   |     0.1509
    dehy   |   0.5549     -0.0293     -0.0948     -0.4682   |     0.4630
    eye   |   0.2109      0.6679      0.0060      0.5107   |     0.2486
    jnts   |   0.0571      0.8969     -0.0659     -0.0003   |     0.1879
    post   |   0.9365      0.0902      0.0692      0.0438   |     0.1081
    pulse   |  -0.2534      0.4970      0.3883     -0.3657   |     0.4042
    resp   |   0.1695     -0.0481      0.7953      0.0363   |     0.3352
    temp   |  -0.5169      0.1841      0.5085      0.2347   |     0.3853
    umb   |   0.0548      0.5554      0.1514      0.1548   |     0.6416
    -------------+----------------------------------------+--------------

Factor rotation matrix

    -------------+------------------------------------
       | Factor1    Factor2    Factor3    Factor4
    -------------+------------------------------------
    Factor1   |  0.9879     0.1230     0.0228    -0.0918
    Factor2   | -0.0785     0.8506     0.3525     0.3822
    Factor3   |  0.0414     0.1654    -0.8770     0.4493
    Factor4   |  0.1272    -0.4837     0.3258     0.8023
    -------------+------------------------------------

. loadingplot

.
. * sparrow data revisited for factor analysis
. import delimited r:\sparrow.csv, clear
(6 vars, 49 obs)

. factor total_length-l_keel_sternum, pcf /* only one factor */
(obs=49)

Factor analysis/correlation                      Number of obs    =         49
    Method: principal-component factors          Retained factors =          1
    Rotation: (unrotated)                        Number of params =          5

    -------------+------------------------------------------------------------
         Factor  | Eigenvalue     Difference        Proportion   Cumulative
    -------------+------------------------------------------------------------
    Factor1    |      3.61598      3.08447            0.7232       0.7232
    Factor2    |      0.53150      0.14508            0.1063       0.8295
    Factor3    |      0.38642      0.08486            0.0773       0.9068
    Factor4    |      0.30157      0.13704            0.0603       0.9671
    Factor5    |      0.16453            .            0.0329       1.0000
    -------------+------------------------------------------------------------
    LR test: independent vs. saturated:  chi2(10) =  153.49 Prob>chi2 = 0.0000

Factor loadings (pattern matrix) and unique variances

    -------------+----------+--------------
    Variable   | Factor1   | Uniqueness
    -------------+----------+--------------
    total_length   |   0.8591   |     0.2619
    alar_extent   |   0.8779   |     0.2293
    l_beak_head   |   0.8567   |     0.2660
    l_humerous   |   0.8951   |     0.1987
    l_keel_ste~m   |   0.7562   |     0.4281
    -------------+----------+--------------

. factor total_length-l_keel_sternum, pcf mineigen(0.5)
(obs=49)

Factor analysis/correlation                      Number of obs    =         49
    Method: principal-component factors          Retained factors =          2
    Rotation: (unrotated)                        Number of params =          9

    -------------+------------------------------------------------------------
         Factor  | Eigenvalue     Difference        Proportion   Cumulative
    -------------+------------------------------------------------------------
    Factor1    |      3.61598      3.08447            0.7232       0.7232
    Factor2    |      0.53150      0.14508            0.1063       0.8295
    Factor3    |      0.38642      0.08486            0.0773       0.9068
    Factor4    |      0.30157      0.13704            0.0603       0.9671
    Factor5    |      0.16453            .            0.0329       1.0000
    -------------+------------------------------------------------------------
    LR test: independent vs. saturated:  chi2(10) =  153.49 Prob>chi2 = 0.0000

Factor loadings (pattern matrix) and unique variances

    -------------+--------------------+--------------
    Variable   | Factor1    Factor2   | Uniqueness
    -------------+--------------------+--------------
    total_length   |   0.8591      0.0370   |     0.2605
    alar_extent   |   0.8779     -0.2184   |     0.1816
    l_beak_head   |   0.8567     -0.2366   |     0.2100
    l_humerous   |   0.8951     -0.1346   |     0.1806
    l_keel_ste~m   |   0.7562      0.6390   |     0.0198
    -------------+--------------------+--------------

.
end of do-file

. exit, clear