. * do-file for lecture 10 of VHM 802, Winter 2024 . version 18 /* works also with versions 14-17 */ . set more off . set scheme stcolor_alt . cd "r:\" r:\ . . * Manly Example 6.1 - sparrow data . import delimited sparrow.csv, clear (encoding automatically selected: ISO-8859-1) (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 | Coefficient Std. err. z P>|z| [95% conf. 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 | Coefficient Std. err. z P>|z| [95% conf. 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 steneryd.csv, clear varnames(1) (encoding automatically selected: UTF-8) (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 s13 s14 s15 s16 s17 s18 s19 s20 s21 > s22 s23 s24 ---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > --------------------------- Mean | 12.11765 11.17647 9.764706 7.647059 6.588235 6 5.647059 4.941176 4.882353 4.411765 4 3.588235 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 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 30 10 15 18 16 9 12 9 9 > 10 16 8 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 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 | 263.1103 55.40441 130.5662 69.86765 130.1324 222.5 25.49265 14.68382 16.23529 24.13235 13.25 14.00735 60.50735 15.88235 26.27941 32.375 25.18382 11.15441 16.06618 8.595588 9.492647 1 > 1.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 Comp12 Comp13 Comp14 Comp15 Comp16 | Unexplained -------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+------------- s1 | -0.2984 0.0048 -0.0653 -0.2825 -0.0472 -0.0449 0.0023 0.1522 0.0422 -0.2297 0.0297 -0.1433 0.0057 0.1227 0.1378 0.3413 | 0 s2 | 0.2499 0.0176 -0.1849 0.2426 0.1190 -0.2435 -0.0298 0.4761 -0.0501 0.1380 -0.1206 -0.0960 -0.0455 0.1203 -0.2622 0.1699 | 0 s3 | 0.2008 0.2026 -0.1933 0.1048 -0.0931 0.4313 0.1706 0.0939 0.1062 -0.0028 -0.1654 -0.0838 -0.0841 0.1289 0.3940 0.1590 | 0 s4 | -0.1730 0.2432 0.0068 0.0271 0.0698 0.4728 0.3278 0.0534 -0.2510 0.0039 -0.0818 0.1530 -0.1031 -0.1439 -0.1000 0.1298 | 0 s5 | 0.1077 -0.3159 -0.0723 0.3085 0.0426 0.1811 -0.1457 0.1591 0.3219 0.0617 0.2677 -0.0428 0.0212 0.2524 -0.1464 -0.0883 | 0 s6 | 0.0813 -0.3122 0.0179 0.2645 0.0978 0.0649 0.3008 0.4140 0.1248 -0.3116 0.0824 0.0795 0.1659 -0.2130 0.3129 0.0377 | 0 s7 | 0.1139 0.3152 -0.1115 -0.0463 -0.2338 -0.0393 0.3090 -0.0450 0.3580 0.3377 -0.0590 -0.1883 0.2372 0.0155 -0.1041 0.0048 | 0 s8 | 0.0067 0.3364 0.2274 0.1539 0.0345 0.0158 -0.0877 -0.1021 0.2878 -0.5287 -0.2951 0.0910 0.1592 -0.0096 -0.1252 0.0594 | 0 s9 | 0.1456 0.3559 -0.0566 0.0695 0.0829 -0.0776 -0.0079 0.0427 0.1190 -0.0896 0.4060 0.1639 0.2252 -0.3766 -0.0139 -0.0913 | 0 s10 | 0.2342 0.1458 0.1827 -0.0871 -0.3939 -0.0039 -0.0852 0.0190 0.2508 0.0631 0.0162 0.0441 0.0451 0.2195 0.0613 -0.0424 | 0 s11 | 0.2550 -0.1110 0.1681 -0.0855 0.2218 0.2684 -0.0789 -0.2713 0.2808 0.2053 0.1611 0.0030 -0.0755 -0.0483 0.2233 0.0654 | 0 s12 | -0.1298 0.2433 0.2261 0.2504 0.3127 0.1271 -0.1109 -0.0360 0.0329 0.0263 0.2661 -0.4371 -0.2870 -0.1885 -0.0728 -0.0876 | 0 s13 | 0.0492 0.1170 -0.4448 -0.0450 0.2837 -0.3404 0.1320 -0.1939 0.1322 0.0692 0.0355 0.1233 -0.0501 -0.1909 0.1298 -0.0760 | 0 s14 | -0.2807 0.0928 0.0034 -0.1398 0.1552 -0.3003 0.0189 0.1035 0.3583 -0.0926 0.1336 0.1412 -0.1736 0.1664 0.2419 0.2104 | 0 s15 | -0.2661 0.1052 0.2553 0.1330 0.1757 -0.0590 -0.0185 0.0424 0.1655 -0.0304 -0.1046 -0.2388 0.1209 0.2735 -0.0680 -0.1104 | 0 s16 | 0.0267 0.2269 0.1923 0.3268 -0.3751 -0.2106 0.1834 -0.0004 -0.2362 -0.0452 0.4193 0.2391 -0.3099 0.2048 0.0562 0.0326 | 0 s17 | -0.2707 -0.0209 0.0477 -0.3216 -0.0962 0.1741 0.0812 0.1999 -0.0222 0.0999 0.4668 -0.0846 0.4132 0.0006 -0.1014 0.0297 | 0 s18 | 0.2026 -0.1791 0.2872 -0.1034 0.1703 -0.0121 0.3216 -0.1036 0.0832 -0.0815 -0.0157 0.3166 0.1239 0.0048 -0.4556 0.1210 | 0 s19 | 0.1471 0.2571 -0.1904 -0.1717 0.3259 0.0358 0.2491 0.1610 -0.1325 -0.0665 0.0588 -0.1522 -0.0272 0.3618 -0.1849 -0.1084 | 0 s20 | 0.2057 0.1767 0.0702 -0.1947 0.3393 0.1376 -0.3209 0.0764 -0.1651 0.0234 0.1047 0.3886 0.0667 0.3557 0.1620 -0.0025 | 0 s21 | 0.2347 0.1646 0.1077 -0.1817 -0.0909 -0.0208 -0.4061 0.3399 -0.0340 0.0477 -0.0373 -0.0764 -0.0608 -0.3643 -0.1076 0.3666 | 0 s22 | 0.2133 0.0274 0.3352 -0.2637 0.0102 -0.1656 0.1426 0.2659 -0.1360 -0.0665 -0.1205 -0.1724 0.0224 -0.0806 0.2874 -0.5566 | 0 s23 | -0.2878 0.0259 0.0966 -0.1147 -0.0004 0.1075 0.0424 0.3534 0.3218 0.3103 -0.1740 0.3759 -0.3949 -0.1346 -0.1252 -0.2470 | 0 s24 | 0.1800 -0.1203 0.3641 -0.1210 0.1476 -0.1896 0.3265 -0.0824 -0.0077 0.1671 0.0226 -0.1893 -0.1918 -0.0109 0.0833 0.4041 | 0 s25 | -0.2056 0.1123 0.2161 0.3439 0.1671 -0.1272 -0.0366 0.0421 -0.1724 0.4584 -0.1857 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 Comp12 Comp13 Comp14 Comp15 Comp16 -------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------- s1 | -0.2984 0.0048 -0.0653 -0.2825 -0.0472 -0.0449 0.0023 0.1522 0.0422 -0.2297 0.0297 -0.1433 0.0057 0.1227 0.1378 0.3413 s2 | 0.2499 0.0176 -0.1849 0.2426 0.1190 -0.2435 -0.0298 0.4761 -0.0501 0.1380 -0.1206 -0.0960 -0.0455 0.1203 -0.2622 0.1699 s3 | 0.2008 0.2026 -0.1933 0.1048 -0.0931 0.4313 0.1706 0.0939 0.1062 -0.0028 -0.1654 -0.0838 -0.0841 0.1289 0.3940 0.1590 s4 | -0.1730 0.2432 0.0068 0.0271 0.0698 0.4728 0.3278 0.0534 -0.2510 0.0039 -0.0818 0.1530 -0.1031 -0.1439 -0.1000 0.1298 s5 | 0.1077 -0.3159 -0.0723 0.3085 0.0426 0.1811 -0.1457 0.1591 0.3219 0.0617 0.2677 -0.0428 0.0212 0.2524 -0.1464 -0.0883 s6 | 0.0813 -0.3122 0.0179 0.2645 0.0978 0.0649 0.3008 0.4140 0.1248 -0.3116 0.0824 0.0795 0.1659 -0.2130 0.3129 0.0377 s7 | 0.1139 0.3152 -0.1115 -0.0463 -0.2338 -0.0393 0.3090 -0.0450 0.3580 0.3377 -0.0590 -0.1883 0.2372 0.0155 -0.1041 0.0048 s8 | 0.0067 0.3364 0.2274 0.1539 0.0345 0.0158 -0.0877 -0.1021 0.2878 -0.5287 -0.2951 0.0910 0.1592 -0.0096 -0.1252 0.0594 s9 | 0.1456 0.3559 -0.0566 0.0695 0.0829 -0.0776 -0.0079 0.0427 0.1190 -0.0896 0.4060 0.1639 0.2252 -0.3766 -0.0139 -0.0913 s10 | 0.2342 0.1458 0.1827 -0.0871 -0.3939 -0.0039 -0.0852 0.0190 0.2508 0.0631 0.0162 0.0441 0.0451 0.2195 0.0613 -0.0424 s11 | 0.2550 -0.1110 0.1681 -0.0855 0.2218 0.2684 -0.0789 -0.2713 0.2808 0.2053 0.1611 0.0030 -0.0755 -0.0483 0.2233 0.0654 s12 | -0.1298 0.2433 0.2261 0.2504 0.3127 0.1271 -0.1109 -0.0360 0.0329 0.0263 0.2661 -0.4371 -0.2870 -0.1885 -0.0728 -0.0876 s13 | 0.0492 0.1170 -0.4448 -0.0450 0.2837 -0.3404 0.1320 -0.1939 0.1322 0.0692 0.0355 0.1233 -0.0501 -0.1909 0.1298 -0.0760 s14 | -0.2807 0.0928 0.0034 -0.1398 0.1552 -0.3003 0.0189 0.1035 0.3583 -0.0926 0.1336 0.1412 -0.1736 0.1664 0.2419 0.2104 s15 | -0.2661 0.1052 0.2553 0.1330 0.1757 -0.0590 -0.0185 0.0424 0.1655 -0.0304 -0.1046 -0.2388 0.1209 0.2735 -0.0680 -0.1104 s16 | 0.0267 0.2269 0.1923 0.3268 -0.3751 -0.2106 0.1834 -0.0004 -0.2362 -0.0452 0.4193 0.2391 -0.3099 0.2048 0.0562 0.0326 s17 | -0.2707 -0.0209 0.0477 -0.3216 -0.0962 0.1741 0.0812 0.1999 -0.0222 0.0999 0.4668 -0.0846 0.4132 0.0006 -0.1014 0.0297 s18 | 0.2026 -0.1791 0.2872 -0.1034 0.1703 -0.0121 0.3216 -0.1036 0.0832 -0.0815 -0.0157 0.3166 0.1239 0.0048 -0.4556 0.1210 s19 | 0.1471 0.2571 -0.1904 -0.1717 0.3259 0.0358 0.2491 0.1610 -0.1325 -0.0665 0.0588 -0.1522 -0.0272 0.3618 -0.1849 -0.1084 s20 | 0.2057 0.1767 0.0702 -0.1947 0.3393 0.1376 -0.3209 0.0764 -0.1651 0.0234 0.1047 0.3886 0.0667 0.3557 0.1620 -0.0025 s21 | 0.2347 0.1646 0.1077 -0.1817 -0.0909 -0.0208 -0.4061 0.3399 -0.0340 0.0477 -0.0373 -0.0764 -0.0608 -0.3643 -0.1076 0.3666 s22 | 0.2133 0.0274 0.3352 -0.2637 0.0102 -0.1656 0.1426 0.2659 -0.1360 -0.0665 -0.1205 -0.1724 0.0224 -0.0806 0.2874 -0.5566 s23 | -0.2878 0.0259 0.0966 -0.1147 -0.0004 0.1075 0.0424 0.3534 0.3218 0.3103 -0.1740 0.3759 -0.3949 -0.1346 -0.1252 -0.2470 s24 | 0.1800 -0.1203 0.3641 -0.1210 0.1476 -0.1896 0.3265 -0.0824 -0.0077 0.1671 0.0226 -0.1893 -0.1918 -0.0109 0.0833 0.4041 s25 | -0.2056 0.1123 0.2161 0.3439 0.1671 -0.1272 -0.0366 0.0421 -0.1724 0.4584 -0.1857 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 . /* to install the package, use: > net describe polychoric, from(https://staskolenikov.net/stata) > net install polychoric > */ . 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 umb 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 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 . drop if missing(age+sex+attd+dehy+eye+jnts+post+pulse+resp+temp+umb+sepsis)==1 (41 observations deleted) . * restrict dataset to complete observations (without missing values) . foreach var of varlist age sex-umb { 2. egen s`var'=std(`var') 3. } . sort case . polychoric age sex-umb /* note: results not completely identical to above */ Polychoric correlation matrix age sex attd dehy eye jnts post pulse resp temp umb age 1 sex .01010373 1 attd -.13950976 -.04479291 1 dehy -.12612086 -.14575855 .38192896 1 eye .04328154 .33056917 .15004459 -.09958976 1 jnts .0007256 .04775808 .08356658 -.03035267 .59635231 1 post -.09867841 -.06227926 .87386637 .39701107 .32318563 .08395814 1 pulse -.18651421 .01399805 -.12854908 -.03287323 .07428001 .2535835 -.10637662 1 resp -.26418451 -.09671084 .17053345 -.0249882 .03344114 -.00556296 .19301091 .16964738 1 temp -.09753186 .06344047 -.338388 -.30588409 .20261028 .07270049 -.37706664 .23121708 .22578032 1 umb -.05461964 .15237046 .14517111 -.08483236 .21072786 .3722088 .04435448 .12807892 .08980629 .13150165 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.48458 .342874 0.2259 0.2259 Comp2 | 2.1417 .63795 0.1947 0.4206 Comp3 | 1.50375 .490978 0.1367 0.5573 Comp4 | 1.01277 .0992471 0.0921 0.6493 Comp5 | .913527 .0805611 0.0830 0.7324 Comp6 | .832966 .153287 0.0757 0.8081 Comp7 | .679678 .0631407 0.0618 0.8699 Comp8 | .616538 .120842 0.0560 0.9260 Comp9 | .495695 .242187 0.0451 0.9710 Comp10 | .253508 .188227 0.0230 0.9941 Comp11 | .0652815 . 0.0059 1.0000 -------------------------------------------------------------------------- Principal components (eigenvectors) ------------------------------------------------------------------------------------------------------------------------------------------ Variable | Comp1 Comp2 Comp3 Comp4 Comp5 Comp6 Comp7 Comp8 Comp9 Comp10 Comp11 | Unexplained -------------+--------------------------------------------------------------------------------------------------------------+------------- age | -0.1101 -0.0949 0.5312 -0.1278 0.4912 0.0490 0.5629 0.3375 0.0324 0.0695 -0.0061 | 0 sex | -0.0573 0.2510 0.3077 0.5485 -0.5920 0.0104 0.2792 0.1068 0.1724 0.2361 0.1135 | 0 attd | 0.5778 0.0169 -0.0270 0.1316 0.0757 -0.0988 0.0929 -0.0375 -0.3414 0.4624 -0.5402 | 0 dehy | 0.3723 -0.1888 -0.0912 -0.3134 -0.3286 0.1162 -0.1019 0.7121 0.2710 -0.0695 -0.0446 | 0 eye | 0.1511 0.5140 0.2777 0.1128 0.0930 0.4044 -0.1852 0.0175 0.0017 -0.5345 -0.3614 | 0 jnts | 0.1021 0.5027 0.1691 -0.4464 0.0873 0.0760 -0.2209 -0.1648 0.3391 0.5128 0.2041 | 0 post | 0.5923 0.0348 0.0096 0.1307 0.1197 0.1256 0.1098 -0.0670 -0.2537 -0.1661 0.7015 | 0 pulse | -0.0941 0.2972 -0.3550 -0.4316 -0.3025 0.2072 0.6037 -0.1061 -0.2638 -0.0876 -0.0562 | 0 resp | 0.1081 0.1641 -0.5569 0.3286 0.3646 0.0216 0.2717 0.0407 0.5760 -0.0082 -0.0514 | 0 temp | -0.3207 0.3178 -0.2675 0.1901 0.1983 0.1505 -0.2273 0.5387 -0.4423 0.2577 0.1505 | 0 umb | 0.0682 0.3972 0.0257 -0.0889 0.0077 -0.8504 0.0333 0.1766 -0.0536 -0.2652 0.0194 | 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 seps > is, o=sepsis), size(medium)) legend(off) . drop __POLY* /* two variables created by polychoric with unclear use */ . . 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 | Unexplained -------------+--------------------------------------------------------------------------------------------------------------+------------- age | -0.0952 -0.4431 0.3102 -0.0506 0.1656 0.3516 0.6483 0.1790 0.2882 -0.0798 0.0534 | 0 sex | -0.0973 0.0219 0.3256 0.7102 -0.1504 -0.4916 0.1574 -0.1972 0.1971 -0.1131 0.0096 | 0 attd | 0.5363 0.1414 0.0534 0.1835 0.0699 0.1255 0.1354 -0.0686 -0.0703 0.4719 0.6201 | 0 dehy | 0.4308 -0.0289 -0.1336 -0.2059 -0.3052 -0.2640 -0.0995 0.3691 0.6485 -0.1481 0.0431 | 0 eye | 0.0242 0.1907 0.5419 -0.1440 0.5037 -0.2939 -0.1886 0.4842 -0.1547 -0.0904 0.0802 | 0 jnts | 0.0093 0.2445 0.5130 -0.4838 -0.1412 0.0249 -0.0343 -0.6049 0.2297 -0.0320 0.0371 | 0 post | 0.5576 0.1350 0.0828 0.0855 0.1441 0.0429 0.2150 -0.0639 -0.0825 0.1467 -0.7453 | 0 pulse | -0.1580 0.4427 -0.0781 -0.2397 -0.3818 -0.2586 0.6011 0.2372 -0.2856 0.0517 0.0320 | 0 resp | 0.0628 0.5115 -0.2982 0.1280 0.3999 0.1947 0.1740 -0.1321 0.1896 -0.5733 0.1375 | 0 temp | -0.4094 0.3514 -0.0902 0.0668 0.2139 0.0737 -0.0325 0.1097 0.5004 0.5977 -0.1559 | 0 umb | -0.0133 0.2946 0.3319 0.2767 -0.4538 0.5918 -0.2259 0.3130 -0.0332 -0.1301 -0.0556 | 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 1/5 +-----------------------------------------------------------------------------------------------------------------------+ | sco1 sco2 sco3 sco4 sco5 scomat1 scomat2 scomat3 scomat4 scomat5 | |-----------------------------------------------------------------------------------------------------------------------| 1. | -2.44531 -.8043134 -.7452768 -.8335332 .3806761 -2.610665 -.4952926 -.1272509 -.2516125 .4102666 | 2. | .5995948 -1.179423 -.3471844 -1.023328 -.1128355 .3270429 -1.216479 .4410701 -1.056379 .3552441 | 3. | -1.182303 -.7322186 -.4973935 -.8034819 .1122511 -1.308873 -.5795658 .0396257 -.6177249 .4194184 | 4. | .4215459 -2.548945 .9689444 .7864367 .0941712 .0930695 -1.340782 2.476868 .5437759 -.2081751 | 5. | 1.893089 -1.843985 1.772735 1.865979 -.6890295 1.749807 -.7147474 2.585642 .7578143 .0399886 | +-----------------------------------------------------------------------------------------------------------------------+ . list age sex-umb in 1/5 +-------------------------------------------------------------------------------------+ | age sex attd dehy eye jnts post pulse resp temp umb | |-------------------------------------------------------------------------------------| 1. | 6 female bright 3.0 no 0 standing 100 20 40.0 no | 2. | 14 female depressed 9.0 no 0 sternal 120 28 36.5 no | 3. | 10 female depressed 4.5 no 0 standing 120 20 39.0 no | 4. | 17 male depressed 5.0 no 0 sternal 80 16 35.0 no | 5. | 17 male comatose 7.0 no 0 sternal 60 22 34.5 yes | +-------------------------------------------------------------------------------------+ . 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) Group variable: 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 -.3212777 -.1427129 .0403154 .0026226 -.0330248 .0438504 | .1206508 .0919026 .0729616 .0752472 .0710346 .0697055 .1169062 .0748924 .0947006 .0742237 .0763126 .0680037 -------+------------------------------------------------------------------------------------------------------------------------ yes | .7009691 .4576728 .2825236 -.0335347 .0679738 .1178502 .8005608 .3556125 -.1004579 -.0065351 .0822913 -.1092667 | .1582304 .1940434 .2029532 .154961 .1489091 .1500943 .1576926 .2253974 .167468 .1523248 .1309676 .1544467 -------+------------------------------------------------------------------------------------------------------------------------ Total | -1.08e-09 -7.00e-11 2.37e-09 2.82e-09 -1.33e-09 1.42e-10 -8.50e-09 9.13e-09 6.93e-09 3.46e-09 3.95e-09 -9.13e-09 | .1017758 .087985 .0787111 .0694723 .0661116 .0657414 .1008735 .0849003 .0827686 .0684174 .0660538 .0656244 -------------------------------------------------------------------------------------------------------------------------------- . 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 H0: 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 H0: 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 H0: 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 H0: 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 H0: 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 H0: 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 -.3212777 .1169062 1.441316 -.5522608 -.0902946 yes | 61 .8005608 .1576926 1.231619 .4851286 1.115993 ---------+-------------------------------------------------------------------- Combined | 213 -8.50e-09 .1008735 1.472201 -.1988436 .1988436 ---------+-------------------------------------------------------------------- diff | -1.121838 .1963008 -1.510235 -.7334421 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = -5.7149 H0: diff = 0 Satterthwaite's degrees of freedom = 128.637 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 -.1427129 .0748924 .9233357 -.2906852 .0052595 yes | 61 .3556125 .2253974 1.76041 -.0952494 .8064744 ---------+-------------------------------------------------------------------- Combined | 213 9.13e-09 .0849003 1.239079 -.1673569 .1673569 ---------+-------------------------------------------------------------------- diff | -.4983254 .2375139 -.9716224 -.0250283 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = -2.0981 H0: diff = 0 Satterthwaite's degrees of freedom = 73.623 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.0197 Pr(|T| > |t|) = 0.0393 Pr(T > t) = 0.9803 Two-sample t test with unequal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- no | 152 .0403154 .0947006 1.167548 -.1467941 .2274248 yes | 61 -.1004579 .167468 1.307967 -.4354438 .234528 ---------+-------------------------------------------------------------------- Combined | 213 6.93e-09 .0827686 1.207968 -.1631549 .1631549 ---------+-------------------------------------------------------------------- diff | .1407733 .1923896 -.2409022 .5224488 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = 0.7317 H0: diff = 0 Satterthwaite's degrees of freedom = 100.428 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.7670 Pr(|T| > |t|) = 0.4660 Pr(T > t) = 0.2330 Two-sample t test with unequal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- no | 152 .0026226 .0742237 .9150917 -.1440285 .1492738 yes | 61 -.0065351 .1523248 1.189695 -.31123 .2981599 ---------+-------------------------------------------------------------------- Combined | 213 3.46e-09 .0684174 .9985186 -.1348655 .1348655 ---------+-------------------------------------------------------------------- diff | .0091577 .1694462 -.3274838 .3457992 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = 0.0540 H0: diff = 0 Satterthwaite's degrees of freedom = 89.8617 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.5215 Pr(|T| > |t|) = 0.9570 Pr(T > t) = 0.4785 Two-sample t test with unequal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- no | 152 -.0330248 .0763126 .9408445 -.1838031 .1177535 yes | 61 .0822913 .1309676 1.02289 -.179683 .3442655 ---------+-------------------------------------------------------------------- Combined | 213 3.95e-09 .0660538 .9640239 -.1302064 .1302064 ---------+-------------------------------------------------------------------- diff | -.115316 .1515788 -.4159388 .1853067 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = -0.7608 H0: diff = 0 Satterthwaite's degrees of freedom = 102.943 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.2243 Pr(|T| > |t|) = 0.4485 Pr(T > t) = 0.7757 Two-sample t test with unequal variances ------------------------------------------------------------------------------ Group | Obs Mean Std. err. Std. dev. [95% conf. interval] ---------+-------------------------------------------------------------------- no | 152 .0438504 .0680037 .8384065 -.0905113 .1782121 yes | 61 -.1092667 .1544467 1.206267 -.4182061 .1996728 ---------+-------------------------------------------------------------------- Combined | 213 -9.13e-09 .0656244 .9577568 -.12936 .1293599 ---------+-------------------------------------------------------------------- diff | .1531171 .1687551 -.1824559 .48869 ------------------------------------------------------------------------------ diff = mean(no) - mean(yes) t = 0.9073 H0: diff = 0 Satterthwaite's degrees of freedom = 84.261 Ha: diff < 0 Ha: diff != 0 Ha: diff > 0 Pr(T < t) = 0.8166 Pr(|T| > |t|) = 0.3668 Pr(T > t) = 0.1834 . 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 | Coefficient Std. err. z P>|z| [95% conf. 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 | Coefficient Std. err. z P>|z| [95% conf. 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 | Coefficient Std. err. z P>|z| [95% conf. 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.75811 Iteration 2: Log likelihood = -108.13007 Iteration 3: Log likelihood = -108.12793 Iteration 4: Log likelihood = -108.12793 Logistic regression Number of obs = 213 LR chi2(6) = 38.87 Prob > chi2 = 0.0000 Log likelihood = -108.12793 Pseudo R2 = 0.1524 ------------------------------------------------------------------------------ sepsis | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- scomat1 | .6476041 .1298367 4.99 0.000 .3931289 .9020794 scomat2 | .38853 .1351751 2.87 0.004 .1235916 .6534683 scomat3 | -.0755895 .1378584 -0.55 0.583 -.345787 .1946081 scomat4 | -.0084634 .1651533 -0.05 0.959 -.3321579 .3152311 scomat5 | .1518494 .1703247 0.89 0.373 -.1819808 .4856796 scomat6 | -.1815719 .1627748 -1.12 0.265 -.5006047 .1374609 _cons | -1.100297 .1783789 -6.17 0.000 -1.449913 -.7506807 ------------------------------------------------------------------------------ . logit sepsis scomat1-scomat3 Iteration 0: Log likelihood = -127.56209 Iteration 1: Log likelihood = -109.66913 Iteration 2: Log likelihood = -109.12697 Iteration 3: Log likelihood = -109.12551 Iteration 4: Log likelihood = -109.12551 Logistic regression Number of obs = 213 LR chi2(3) = 36.87 Prob > chi2 = 0.0000 Log likelihood = -109.12551 Pseudo R2 = 0.1445 ------------------------------------------------------------------------------ sepsis | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- scomat1 | .6390479 .1284708 4.97 0.000 .3872497 .890846 scomat2 | .3932847 .1395737 2.82 0.005 .1197252 .6668442 scomat3 | -.0754824 .1374788 -0.55 0.583 -.3449359 .1939711 _cons | -1.087493 .1767718 -6.15 0.000 -1.43396 -.741027 ------------------------------------------------------------------------------ . logit sepsis scomat1-scomat2 Iteration 0: Log likelihood = -127.56209 Iteration 1: Log likelihood = -109.77408 Iteration 2: Log likelihood = -109.27714 Iteration 3: Log likelihood = -109.27603 Iteration 4: Log likelihood = -109.27603 Logistic regression Number of obs = 213 LR chi2(2) = 36.57 Prob > chi2 = 0.0000 Log likelihood = -109.27603 Pseudo R2 = 0.1434 ------------------------------------------------------------------------------ sepsis | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- scomat1 | .6381828 .1282141 4.98 0.000 .3868877 .8894778 scomat2 | .4023098 .1405466 2.86 0.004 .1268436 .677776 _cons | -1.080515 .1758392 -6.14 0.000 -1.425154 -.7358767 ------------------------------------------------------------------------------ . . * technical, for demonstration purposes . polychoricpca age sex-umb, score(polysco) nscore(6) /* same as with pcamat above */ Polychoric correlation matrix age sex attd dehy eye jnts post pulse resp temp umb age 1 sex .01010373 1 attd -.13950976 -.04479291 1 dehy -.12612086 -.14575855 .38192896 1 eye .04328154 .33056917 .15004459 -.09958976 1 jnts .0007256 .04775808 .08356658 -.03035267 .59635231 1 post -.09867841 -.06227926 .87386637 .39701107 .32318563 .08395814 1 pulse -.18651421 .01399805 -.12854908 -.03287323 .07428001 .2535835 -.10637662 1 resp -.26418451 -.09671084 .17053345 -.0249882 .03344114 -.00556296 .19301091 .16964738 1 temp -.09753186 .06344047 -.338388 -.30588409 .20261028 .07270049 -.37706664 .23121708 .22578032 1 umb -.05461964 .15237046 .14517111 -.08483236 .21072786 .3722088 .04435448 .12807892 .08980629 .13150165 1 Principal component analysis k | Eigenvalues | Proportion explained | Cum. explained ----+---------------+------------------------+------------------ 1 | 2.484577 | 0.225871 | 0.225871 2 | 2.141703 | 0.194700 | 0.420571 3 | 1.503753 | 0.136705 | 0.557276 4 | 1.012774 | 0.092070 | 0.649346 5 | 0.913527 | 0.083048 | 0.732394 6 | 0.832966 | 0.075724 | 0.808118 7 | 0.679678 | 0.061789 | 0.869907 8 | 0.616538 | 0.056049 | 0.925956 9 | 0.495695 | 0.045063 | 0.971019 10 | 0.253508 | 0.023046 | 0.994065 11 | 0.065282 | 0.005935 | 1.000000 Scoring coefficients Variable | Coeff. 1 | Coeff. 2 | Coeff. 3 ------------------------------------------------------ age | -0.110078 | -0.094856 | 0.531185 sex 0 | 0.046860 | -0.205252 | -0.251615 1 | -0.044290 | 0.193995 | 0.237815 attd 0 | -0.994278 | -0.029053 | 0.046519 1 | -0.057320 | -0.001675 | 0.002682 2 | 0.854373 | 0.024965 | -0.039973 dehy | 0.372261 | -0.188823 | -0.091168 eye 0 | -0.009056 | -0.030814 | -0.016649 1 | 0.347813 | 1.183493 | 0.639463 jnts 0 | -0.021443 | -0.105577 | -0.035524 1 | 0.155110 | 0.763688 | 0.256961 2 | 0.219958 | 1.082969 | 0.364391 4 | 0.278263 | 1.370035 | 0.460981 post 0 | -0.593876 | -0.034851 | -0.009615 1 | 0.090762 | 0.005326 | 0.001469 2 | 0.735721 | 0.043175 | 0.011912 pulse | -0.094149 | 0.297249 | -0.354982 resp | 0.108061 | 0.164079 | -0.556871 temp | -0.320655 | 0.317770 | -0.267468 umb 0 | -0.026983 | -0.157247 | -0.010162 1 | 0.089250 | 0.520126 | 0.033611 . * _tt variables with latent variables values used for score coefficients in table (latent variable*eigenvalue) . * method behind construction of latent variables not documented, appears to be quite ad-hoc . . * 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.48458 0.34287 0.2259 0.2259 Factor2 | 2.14170 0.63795 0.1947 0.4206 Factor3 | 1.50375 0.49098 0.1367 0.5573 Factor4 | 1.01277 0.09925 0.0921 0.6493 Factor5 | 0.91353 0.08056 0.0830 0.7324 Factor6 | 0.83297 0.15329 0.0757 0.8081 Factor7 | 0.67968 0.06314 0.0618 0.8699 Factor8 | 0.61654 0.12084 0.0560 0.9260 Factor9 | 0.49570 0.24219 0.0451 0.9710 Factor10 | 0.25351 0.18823 0.0230 0.9941 Factor11 | 0.06528 . 0.0059 1.0000 -------------------------------------------------------------------------- LR test: independent vs. saturated: chi2(55) = 803.52 Prob>chi2 = 0.0000 Factor loadings (pattern matrix) and unique variances --------------------------------------------------------------------- Variable | Factor1 Factor2 Factor3 Factor4 | Uniqueness -------------+----------------------------------------+-------------- age | -0.1735 -0.1388 0.6514 -0.1286 | 0.5098 sex | -0.0903 0.3673 0.3773 0.5519 | 0.4100 attd | 0.9108 0.0247 -0.0332 0.1324 | 0.1512 dehy | 0.5868 -0.2763 -0.1118 -0.3154 | 0.4674 eye | 0.2381 0.7522 0.3406 0.1135 | 0.2486 jnts | 0.1609 0.7356 0.2074 -0.4493 | 0.1881 post | 0.9337 0.0509 0.0118 0.1315 | 0.1082 pulse | -0.1484 0.4350 -0.4353 -0.4343 | 0.4106 resp | 0.1703 0.2401 -0.6829 0.3307 | 0.3377 temp | -0.5054 0.4650 -0.3280 0.1913 | 0.3841 umb | 0.1074 0.5812 0.0315 -0.0895 | 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.45781 0.58988 0.2234 0.2234 Factor2 | 1.86793 0.33618 0.1698 0.3932 Factor3 | 1.53175 0.24642 0.1392 0.5325 Factor4 | 1.28533 . 0.1168 0.6493 -------------------------------------------------------------------------- LR test: independent vs. saturated: chi2(55) = 803.52 Prob>chi2 = 0.0000 Rotated factor loadings (pattern matrix) and unique variances --------------------------------------------------------------------- Variable | Factor1 Factor2 Factor3 Factor4 | Uniqueness -------------+----------------------------------------+-------------- age | -0.1513 0.0319 -0.6662 0.1500 | 0.5098 sex | -0.0318 0.1004 -0.0260 0.7604 | 0.4100 attd | 0.9138 0.0595 0.0995 0.0171 | 0.1512 dehy | 0.5562 -0.0335 -0.0885 -0.4629 | 0.4674 eye | 0.2078 0.6720 0.0067 0.5066 | 0.2486 jnts | 0.0565 0.8969 -0.0655 -0.0053 | 0.1881 post | 0.9362 0.0924 0.0694 0.0443 | 0.1082 pulse | -0.2509 0.4893 0.3920 -0.3651 | 0.4106 resp | 0.1649 -0.0482 0.7946 0.0374 | 0.3377 temp | -0.5230 0.1901 0.5028 0.2310 | 0.3841 umb | 0.0533 0.5566 0.1499 0.1525 | 0.6416 --------------------------------------------------------------------- Factor rotation matrix -------------------------------------------------- | Factor1 Factor2 Factor3 Factor4 -------------+------------------------------------ Factor1 | 0.9885 0.1181 0.0208 -0.0923 Factor2 | -0.0738 0.8527 0.3514 0.3794 Factor3 | 0.0401 0.1672 -0.8785 0.4457 Factor4 | 0.1259 -0.4806 0.3229 0.8056 -------------------------------------------------- . loadingplot . . * sparrow data revisited for factor analysis . import delimited sparrow.csv, clear (encoding automatically selected: ISO-8859-1) (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 ------------------------------------------------- . rotate, varimax normalize Factor analysis/correlation Number of obs = 49 Method: principal-component factors Retained factors = 2 Rotation: orthogonal varimax (Kaiser on) Number of params = 9 -------------------------------------------------------------------------- Factor | Variance Difference Proportion Cumulative -------------+------------------------------------------------------------ Factor1 | 2.76996 1.39243 0.5540 0.5540 Factor2 | 1.37753 . 0.2755 0.8295 -------------------------------------------------------------------------- LR test: independent vs. saturated: chi2(10) = 153.49 Prob>chi2 = 0.0000 Rotated factor loadings (pattern matrix) and unique variances ------------------------------------------------- Variable | Factor1 Factor2 | Uniqueness -------------+--------------------+-------------- total_length | 0.7125 0.4814 | 0.2605 alar_extent | 0.8623 0.2737 | 0.1816 l_beak_head | 0.8538 0.2471 | 0.2100 l_humerous | 0.8331 0.3541 | 0.1806 l_keel_ste~m | 0.3095 0.9404 | 0.0198 ------------------------------------------------- Factor rotation matrix -------------------------------- | Factor1 Factor2 -------------+------------------ Factor1 | 0.8519 0.5237 Factor2 | -0.5237 0.8519 -------------------------------- . * normalize option to include Kaiser normalization (default in Minitab) . . * added illustration of eigenvalue and eigenvector concepts . clear . matrix input a=(9 6\6 16) . matrix list a symmetric a[2,2] c1 c2 r1 9 r2 6 16 . pcamat a, n(1) names(v1 v2) Principal components/correlation Number of obs = 1 Number of comp. = 2 Trace = 2 Rotation: (unrotated = principal) Rho = 1.0000 -------------------------------------------------------------------------- Component | Eigenvalue Difference Proportion Cumulative -------------+------------------------------------------------------------ Comp1 | 1.5 1 0.7500 0.7500 Comp2 | .5 . 0.2500 1.0000 -------------------------------------------------------------------------- Principal components (eigenvectors) ------------------------------------------------ Variable | Comp1 Comp2 | Unexplained -------------+--------------------+------------- v1 | 0.7071 0.7071 | 0 v2 | 0.7071 -0.7071 | 0 ------------------------------------------------ . pcamat a, cov n(1) names(v1 v2) Principal components/covariance Number of obs = 1 Number of comp. = 2 Trace = 25 Rotation: (unrotated = principal) Rho = 1.0000 -------------------------------------------------------------------------- Component | Eigenvalue Difference Proportion Cumulative -------------+------------------------------------------------------------ Comp1 | 19.4462 13.8924 0.7778 0.7778 Comp2 | 5.55378 . 0.2222 1.0000 -------------------------------------------------------------------------- Principal components (eigenvectors) ------------------------------------------------ Variable | Comp1 Comp2 | Unexplained -------------+--------------------+------------- v1 | 0.4981 0.8671 | 0 v2 | 0.8671 -0.4981 | 0 ------------------------------------------------ . matrix symeigen evect eval = a . matrix list eval eval[1,2] e1 e2 r1 19.446222 5.553778 . matrix list evect symmetric evect[2,2] e1 e2 r1 .49806073 r2 .86714215 -.49806073 . matrix define c=a*evect . matrix define d=c-eval[1,1]*evect . matrix list d /* first column=0 */ d[2,2] e1 e2 r1 -1.776e-15 -12.046724 r2 0 6.9192807 . matrix define d=c-eval[1,2]*evect . matrix list d /* second column=0 */ d[2,2] e1 e2 r1 6.9192807 0 r2 12.046724 -8.882e-16 . end of do-file . exit, clear