. * do-file for lecture 3a (part) of VHM 802/812, Winter 2016 . version 14 /* works also with version 13 */ . set more off . cd "h:\vhm\vhm802\data_stata" h:\vhm\vhm802\data_stata . use daisy2red, clear . . * 1a) . regress wpc i.herd Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(6, 1567) = 15.11 Model | 228992.526 6 38165.421 Prob > F = 0.0000 Residual | 3959098.03 1,567 2526.54629 R-squared = 0.0547 -------------+---------------------------------- Adj R-squared = 0.0511 Total | 4188090.56 1,573 2662.48605 Root MSE = 50.265 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- herd | 2 | -8.637779 4.518731 -1.91 0.056 -17.50118 .2256182 3 | 11.08273 4.139467 2.68 0.007 2.963254 19.20221 4 | -21.3346 4.662061 -4.58 0.000 -30.47913 -12.19006 5 | -22.04426 5.373491 -4.10 0.000 -32.58425 -11.50427 106 | -16.29361 4.390344 -3.71 0.000 -24.90518 -7.682041 119 | -17.54149 4.932316 -3.56 0.000 -27.21613 -7.866858 | _cons | 76.82721 3.047749 25.21 0.000 70.84911 82.8053 ------------------------------------------------------------------------------ . margins herd Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- herd | 1 | 76.82721 3.047749 25.21 0.000 70.84911 82.8053 2 | 68.18943 3.336189 20.44 0.000 61.64556 74.73329 3 | 87.90994 2.801146 31.38 0.000 82.41555 93.40433 4 | 55.49261 3.527895 15.73 0.000 48.57272 62.4125 5 | 54.78295 4.425566 12.38 0.000 46.10229 63.4636 106 | 60.5336 3.160119 19.16 0.000 54.33509 66.7321 119 | 59.28571 3.878011 15.29 0.000 51.67908 66.89235 ------------------------------------------------------------------------------ . lincom _cons+2.herd ( 1) 2.herd + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 68.18943 3.336189 20.44 0.000 61.64556 74.73329 ------------------------------------------------------------------------------ . tabstat wpc, statistics(mean sd semean count) by(herd) Summary for variables: wpc by categories of: herd (Herd Number) herd | mean sd se(mean) N ---------+---------------------------------------- 1 | 76.82721 54.25425 3.289647 272 2 | 68.18943 51.42065 3.412909 227 3 | 87.90994 56.03043 3.122454 322 4 | 55.49261 46.33257 3.251909 203 5 | 54.78295 43.38904 3.820192 129 106 | 60.5336 43.14395 2.712437 253 119 | 59.28571 49.69417 3.833989 168 ---------+---------------------------------------- Total | 68.79924 51.59928 1.300593 1574 -------------------------------------------------- . . * 1b) . regress wpc milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 1.50 Model | 3998.19335 1 3998.19335 Prob > F = 0.2215 Residual | 4100366.46 1,534 2672.98987 R-squared = 0.0010 -------------+---------------------------------- Adj R-squared = 0.0003 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.701 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- milk120 | -.0023117 .0018902 -1.22 0.222 -.0060194 .0013959 _cons | 76.41752 6.218695 12.29 0.000 64.21947 88.61556 ------------------------------------------------------------------------------ . margins , at( milk120=(1200(1000)5600) ) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4200 5._at : milk120 = 5200 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 73.64342 4.030901 18.27 0.000 65.73676 81.55008 2 | 71.33167 2.328467 30.63 0.000 66.76436 75.89898 3 | 69.01992 1.319485 52.31 0.000 66.43174 71.60811 4 | 66.70818 2.28167 29.24 0.000 62.23265 71.1837 5 | 64.39643 3.97702 16.19 0.000 56.59546 72.1974 ------------------------------------------------------------------------------ . marginsplot Variables that uniquely identify margins: milk120 . lincom _cons+milk120*3200 ( 1) 3200*milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 69.01992 1.319485 52.31 0.000 66.43174 71.60811 ------------------------------------------------------------------------------ . sum milk120, d Milk volume (l) in first 120 days of lactation ------------------------------------------------------------- Percentiles Smallest 1% 1698.5 1110.2 5% 2077.2 1397.7 10% 2298.2 1461.5 Obs 1,536 25% 2731.95 1467 Sum of Wgt. 1,536 50% 3215.25 Mean 3215.096 Largest Std. Dev. 698.1316 75% 3682.1 5181.8 90% 4080.7 5278 Variance 487387.7 95% 4403.3 5399.9 Skewness .1101838 99% 4904.4 5630.3 Kurtosis 2.845637 . . * 1c) . regress wpc c.milk120##c.milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(2, 1533) = 2.84 Model | 15168.437 2 7584.21849 Prob > F = 0.0585 Residual | 4089196.22 1,533 2667.44698 R-squared = 0.0037 -------------+---------------------------------- Adj R-squared = 0.0024 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.647 ------------------------------------------------------------------------------------- wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] --------------------+---------------------------------------------------------------- milk120 | -.0289184 .0131383 -2.20 0.028 -.0546894 -.0031475 | c.milk120#c.milk120 | 4.09e-06 2.00e-06 2.05 0.041 1.70e-07 8.01e-06 | _cons | 117.7029 21.10975 5.58 0.000 76.29586 159.1099 ------------------------------------------------------------------------------------- . margins , at( milk120=(1200(1000)5600) ) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4200 5._at : milk120 = 5200 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 88.88877 8.468555 10.50 0.000 72.2776 105.5 2 | 73.87253 2.636701 28.02 0.000 68.70061 79.04445 3 | 67.03403 1.636826 40.95 0.000 63.82338 70.24469 4 | 68.37329 2.42019 28.25 0.000 63.62605 73.12052 5 | 77.89029 7.698409 10.12 0.000 62.78976 92.99082 ------------------------------------------------------------------------------ . marginsplot Variables that uniquely identify margins: milk120 . lincom _cons+milk120*3200+c.milk120#c.milk120*10240000 ( 1) 3200*milk120 + 1.02e+07*c.milk120#c.milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 67.03403 1.636826 40.95 0.000 63.82338 70.24469 ------------------------------------------------------------------------------ . . * 1d) . generate lnwpc=ln(wpc) . regress lnwpc milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 2.51 Model | 1.45963987 1 1.45963987 Prob > F = 0.1130 Residual | 890.377121 1,534 .580428371 R-squared = 0.0016 -------------+---------------------------------- Adj R-squared = 0.0010 Total | 891.836761 1,535 .581001147 Root MSE = .76186 ------------------------------------------------------------------------------ lnwpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- milk120 | -.0000442 .0000279 -1.59 0.113 -.0000988 .0000105 _cons | 4.103887 .0916379 44.78 0.000 3.924139 4.283636 ------------------------------------------------------------------------------ . margins , at( milk120=(1200(1000)5600)) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4200 5._at : milk120 = 5200 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 4.050883 .0593988 68.20 0.000 3.934371 4.167394 2 | 4.006712 .034312 116.77 0.000 3.939409 4.074016 3 | 3.962542 .0194438 203.80 0.000 3.924403 4.000681 4 | 3.918372 .0336224 116.54 0.000 3.852421 3.984322 5 | 3.874201 .0586048 66.11 0.000 3.759247 3.989155 ------------------------------------------------------------------------------ . margins , at( milk120=(1200(1000)5600)) expression(exp(predict(xb))) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : exp(predict(xb)) 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4200 5._at : milk120 = 5200 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 57.44816 3.412352 16.84 0.000 50.76007 64.13624 2 | 54.96587 1.885987 29.14 0.000 51.2694 58.66234 3 | 52.59085 1.022564 51.43 0.000 50.58666 54.59503 4 | 50.31844 1.691826 29.74 0.000 47.00252 53.63436 5 | 48.14423 2.821485 17.06 0.000 42.61422 53.67424 ------------------------------------------------------------------------------ . marginsplot Variables that uniquely identify margins: milk120 . di exp(3.934371) " , " exp(4.167394) /* correct CI for 1200 */ 51.129979 , 64.547023 . . * 2a) . regress wpc i.rp i.vag_disch Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(2, 1571) = 4.65 Model | 24663.1482 2 12331.5741 Prob > F = 0.0097 Residual | 4163427.41 1,571 2650.17658 R-squared = 0.0059 -------------+---------------------------------- Adj R-squared = 0.0046 Total | 4188090.56 1,573 2662.48605 Root MSE = 51.48 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | yes | 10.2397 4.540774 2.26 0.024 1.333087 19.14632 | vag_disch | yes | 9.066942 5.9819 1.52 0.130 -2.666406 20.80029 _cons | 67.35756 1.381095 48.77 0.000 64.64857 70.06654 ------------------------------------------------------------------------------ . margins rp vag_disch Predictive margins Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | no | 67.82991 1.366926 49.62 0.000 65.14872 70.51111 yes | 78.06962 4.310854 18.11 0.000 69.61398 86.52525 | vag_disch | no | 68.32688 1.33448 51.20 0.000 65.70933 70.94443 yes | 77.39382 5.816838 13.31 0.000 65.98424 88.80341 ------------------------------------------------------------------------------ . table rp vag_disch, row col ------------------------------- Retained | placenta | Vaginal discharge at | observed calving | no yes Total ----------+-------------------- no | 1,373 52 1,425 yes | 119 30 149 | Total | 1,492 82 1,574 ------------------------------- . lincom _cons+1.rp+1.vag_disch*82/1574 /* rp=1 */ ( 1) 1.rp + .0520966*1.vag_disch + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 78.06962 4.310854 18.11 0.000 69.61398 86.52525 ------------------------------------------------------------------------------ . margins rp vag_disch, asbalanced Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() at : rp (asbalanced) vag_disch (asbalanced) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | no | 71.89103 3.089892 23.27 0.000 65.83028 77.95177 yes | 82.13073 4.580191 17.93 0.000 73.1468 91.11466 | vag_disch | no | 72.47741 2.327566 31.14 0.000 67.91195 77.04287 yes | 81.54435 5.71754 14.26 0.000 70.32954 92.75916 ------------------------------------------------------------------------------ . lincom _cons+1.rp+1.vag_disch*0.5 /* rp=1 */ ( 1) 1.rp + .5*1.vag_disch + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 82.13073 4.580191 17.93 0.000 73.1468 91.11466 ------------------------------------------------------------------------------ . margins rp, over(vag_disch) /* same as: at(vag_disch=(0 1)) */ Predictive margins Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() over : vag_disch ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- vag_disch#rp | no#no | 67.35756 1.381095 48.77 0.000 64.64857 70.06654 no#yes | 77.59726 4.386003 17.69 0.000 68.99422 86.2003 yes#no | 76.4245 5.922753 12.90 0.000 64.80717 88.04183 yes#yes | 86.6642 6.372663 13.60 0.000 74.16438 99.16402 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: rp vag_disch . lincom _cons+1.rp+1.vag_disch /* rp=1, vag_disch=1 */ ( 1) 1.rp + 1.vag_disch + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 86.6642 6.372663 13.60 0.000 74.16438 99.16402 ------------------------------------------------------------------------------ . . * 2b) . regress wpc rp##vag_disch Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(3, 1570) = 4.53 Model | 35915.9774 3 11971.9925 Prob > F = 0.0036 Residual | 4152174.58 1,570 2644.69719 R-squared = 0.0086 -------------+---------------------------------- Adj R-squared = 0.0067 Total | 4188090.56 1,573 2662.48605 Root MSE = 51.427 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | yes | 6.339794 4.914322 1.29 0.197 -3.299531 15.97912 | vag_disch | yes | .5429296 7.265382 0.07 0.940 -13.70794 14.7938 | rp#vag_disch | yes#yes | 26.34867 12.77367 2.06 0.039 1.293414 51.40392 | _cons | 67.66861 1.387883 48.76 0.000 64.94631 70.39091 ------------------------------------------------------------------------------ . margins rp#vag_disch Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp#vag_disch | no#no | 67.66861 1.387883 48.76 0.000 64.94631 70.39091 no#yes | 68.21154 7.131589 9.56 0.000 54.2231 82.19998 yes#no | 74.0084 4.71427 15.70 0.000 64.76147 83.25533 yes#yes | 100.9 9.389173 10.75 0.000 82.48336 119.3166 ------------------------------------------------------------------------------ . marginsplot, noci /* this is the interaction plot! */ Variables that uniquely identify margins: rp vag_disch . marginsplot, noci x(vag_disch) /* controlling variable on x */ Variables that uniquely identify margins: rp vag_disch . marginsplot, noci x(rp) /* same as default */ Variables that uniquely identify margins: rp vag_disch . table rp vag_disch, contents(mean wpc) row col ---------------------------------------- Retained | placenta | at | Vaginal discharge observed calving | no yes Total ----------+----------------------------- no | 67.66861 68.21154 67.68842 yes | 74.0084 100.9 79.42282 | Total | 68.17426 80.17073 68.79924 ---------------------------------------- . margins rp Predictive margins Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | no | 67.69689 1.367034 49.52 0.000 65.01549 70.3783 yes | 75.40936 4.495364 16.77 0.000 66.59181 84.22691 ------------------------------------------------------------------------------ . lincom _cons+1.rp+(1.vag_disch+1.rp#1.vag_disch)*82/1574 /* rp=1 */ ( 1) 1.rp + .0520966*1.vag_disch + .0520966*1.rp#1.vag_disch + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 75.40936 4.495364 16.77 0.000 66.59181 84.22691 ------------------------------------------------------------------------------ . margins rp, asbalanced Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() at : rp (asbalanced) vag_disch (asbalanced) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- rp | no | 67.94007 3.632691 18.70 0.000 60.81464 75.06551 yes | 87.4542 5.253116 16.65 0.000 77.15034 97.75806 ------------------------------------------------------------------------------ . lincom _cons+1.rp+(1.vag_disch+1.rp#1.vag_disch)*0.5 /* rp=1 */ ( 1) 1.rp + .5*1.vag_disch + .5*1.rp#1.vag_disch + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 87.4542 5.253116 16.65 0.000 77.15034 97.75806 ------------------------------------------------------------------------------ . . * 2c) . regress wpc i.dyst milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(2, 1533) = 1.01 Model | 5380.7883 2 2690.39415 Prob > F = 0.3658 Residual | 4098983.87 1,533 2673.83162 R-squared = 0.0013 -------------+---------------------------------- Adj R-squared = 0.0000 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.709 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- dyst | yes | 4.004176 5.568429 0.72 0.472 -6.918368 14.92672 milk120 | -.0022375 .0018933 -1.18 0.237 -.0059512 .0014763 _cons | 75.93882 6.255198 12.14 0.000 63.66917 88.20847 ------------------------------------------------------------------------------ . margins dyst, at( milk120=(1200 2200 3200 4300 5500)) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4300 5._at : milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#dyst | 1#no | 73.25388 4.067768 18.01 0.000 65.2749 81.23286 1#yes | 77.25805 6.443687 11.99 0.000 64.61868 89.89743 2#no | 71.01642 2.369738 29.97 0.000 66.36815 75.66469 2#yes | 75.0206 5.633884 13.32 0.000 63.96966 86.07153 3#no | 68.77897 1.36157 50.51 0.000 66.10823 71.4497 3#yes | 72.78314 5.397173 13.49 0.000 62.19652 83.36977 4#no | 66.31777 2.448762 27.08 0.000 61.51449 71.12105 4#yes | 70.32194 5.876881 11.97 0.000 58.79437 81.84952 5#no | 63.63282 4.517657 14.09 0.000 54.77138 72.49426 5#yes | 67.637 7.094453 9.53 0.000 53.72114 81.55286 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: milk120 dyst . lincom _cons+1.dyst+milk120*3200 /* dyst=1, milk120=3200 */ ( 1) 1.dyst + 3200*milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 72.78314 5.397173 13.49 0.000 62.19652 83.36977 ------------------------------------------------------------------------------ . margin dyst, atmeans Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() at : 0.dyst = .9401042 (mean) 1.dyst = .0598958 (mean) milk120 = 3215.096 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- dyst | no | 68.74519 1.360888 50.51 0.000 66.07579 71.41459 yes | 72.74937 5.39861 13.48 0.000 62.15993 83.33881 ------------------------------------------------------------------------------ . lincom _cons+1.dyst+milk120*3215.096 ( 1) 1.dyst + 3215.096*milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 72.74937 5.39861 13.48 0.000 62.15993 83.33881 ------------------------------------------------------------------------------ . * interaction model . regress wpc dyst##c.milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(3, 1532) = 3.83 Model | 30572.8757 3 10190.9586 Prob > F = 0.0095 Residual | 4073791.78 1,532 2659.13302 R-squared = 0.0074 -------------+---------------------------------- Adj R-squared = 0.0055 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.567 -------------------------------------------------------------------------------- wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---------------+---------------------------------------------------------------- dyst | yes | -85.48838 29.60089 -2.89 0.004 -143.5509 -27.42583 milk120 | -.0034465 .0019285 -1.79 0.074 -.0072294 .0003363 | dyst#c.milk120 | yes | .0291424 .0094681 3.08 0.002 .0105706 .0477142 | _cons | 79.83774 6.365297 12.54 0.000 67.35213 92.32336 -------------------------------------------------------------------------------- . margins dyst, at( milk120=(1200 2200 3200 4300 5500)) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : milk120 = 1200 2._at : milk120 = 2200 3._at : milk120 = 3200 4._at : milk120 = 4300 5._at : milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#dyst | 1#no | 75.70191 4.133806 18.31 0.000 67.59339 83.81042 1#yes | 25.18437 18.09754 1.39 0.164 -10.3142 60.68295 2#no | 72.25537 2.397252 30.14 0.000 67.55313 76.95762 2#yes | 50.88022 9.647734 5.27 0.000 31.95606 69.80438 3#no | 68.80884 1.357857 50.67 0.000 66.14539 71.4723 3#yes | 76.57606 5.521583 13.87 0.000 65.7454 87.40672 4#no | 65.01766 2.478284 26.23 0.000 60.15647 69.87885 4#yes | 104.8415 12.6541 8.29 0.000 80.0203 129.6627 5#no | 60.88182 4.593023 13.26 0.000 51.87254 69.8911 5#yes | 135.6765 23.21002 5.85 0.000 90.14974 181.2033 ------------------------------------------------------------------------------ . marginsplot, noci /* this is the interaction plot! */ Variables that uniquely identify margins: milk120 dyst . lincom _cons+1.dyst+(c.milk120+1.dyst#c.milk120)*3200 /* dyst=1, milk120=3200 */ ( 1) 1.dyst + 3200*milk120 + 3200*1.dyst#c.milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 76.57606 5.521583 13.87 0.000 65.7454 87.40672 ------------------------------------------------------------------------------ . . * 2d) . regress wpc parity milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(2, 1533) = 3.18 Model | 16982.1525 2 8491.07626 Prob > F = 0.0417 Residual | 4087382.5 1,533 2666.26386 R-squared = 0.0041 -------------+---------------------------------- Adj R-squared = 0.0028 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.636 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- parity | 2.104084 .9534787 2.21 0.027 .2338231 3.974344 milk120 | -.0040343 .0020428 -1.97 0.048 -.0080413 -.0000273 _cons | 76.19823 6.211661 12.27 0.000 64.01398 88.38248 ------------------------------------------------------------------------------ . tabulate parity Lactation | number | Freq. Percent Cum. ------------+----------------------------------- 1 | 417 26.49 26.49 2 | 374 23.76 50.25 3 | 319 20.27 70.52 4 | 222 14.10 84.63 5 | 169 10.74 95.36 6 | 69 4.38 99.75 7 | 4 0.25 100.00 ------------+----------------------------------- Total | 1,574 100.00 . margins , at( parity=(1(1)6) milk120=(1200 2200 3200 4300 5500)) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : parity = 1 milk120 = 1200 2._at : parity = 1 milk120 = 2200 3._at : parity = 1 milk120 = 3200 4._at : parity = 1 milk120 = 4300 5._at : parity = 1 milk120 = 5500 6._at : parity = 2 milk120 = 1200 7._at : parity = 2 milk120 = 2200 8._at : parity = 2 milk120 = 3200 9._at : parity = 2 milk120 = 4300 10._at : parity = 2 milk120 = 5500 11._at : parity = 3 milk120 = 1200 12._at : parity = 3 milk120 = 2200 13._at : parity = 3 milk120 = 3200 14._at : parity = 3 milk120 = 4300 15._at : parity = 3 milk120 = 5500 16._at : parity = 4 milk120 = 1200 17._at : parity = 4 milk120 = 2200 18._at : parity = 4 milk120 = 3200 19._at : parity = 4 milk120 = 4300 20._at : parity = 4 milk120 = 5500 21._at : parity = 5 milk120 = 1200 22._at : parity = 5 milk120 = 2200 23._at : parity = 5 milk120 = 3200 24._at : parity = 5 milk120 = 4300 25._at : parity = 5 milk120 = 5500 26._at : parity = 6 milk120 = 1200 27._at : parity = 6 milk120 = 2200 28._at : parity = 6 milk120 = 3200 29._at : parity = 6 milk120 = 4300 30._at : parity = 6 milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 73.46115 4.026674 18.24 0.000 65.56278 81.35952 2 | 69.42685 2.480564 27.99 0.000 64.56119 74.29251 3 | 65.39255 2.106807 31.04 0.000 61.26002 69.52508 4 | 60.95481 3.491797 17.46 0.000 54.10561 67.80402 5 | 56.11365 5.671817 9.89 0.000 44.98831 67.23899 6 | 75.56523 4.118946 18.35 0.000 67.48587 83.6446 7 | 71.53093 2.327288 30.74 0.000 66.96593 76.09594 8 | 67.49663 1.48767 45.37 0.000 64.57855 70.41471 9 | 63.0589 2.886134 21.85 0.000 57.39771 68.72009 10 | 58.21774 5.149795 11.30 0.000 48.11635 68.31912 11 | 77.66932 4.419907 17.57 0.000 68.99962 86.33902 12 | 73.63502 2.549035 28.89 0.000 68.63505 78.63498 13 | 69.60071 1.343849 51.79 0.000 66.96474 72.23669 14 | 65.16298 2.507018 25.99 0.000 60.24543 70.08053 15 | 60.32182 4.76335 12.66 0.000 50.97845 69.66519 16 | 79.7734 4.891183 16.31 0.000 70.17928 89.36752 17 | 75.7391 3.065475 24.71 0.000 69.72613 81.75207 18 | 71.7048 1.793583 39.98 0.000 68.18666 75.22293 19 | 67.26707 2.461453 27.33 0.000 62.43889 72.09524 20 | 62.4259 4.547181 13.73 0.000 53.50655 71.34526 21 | 81.87749 5.489082 14.92 0.000 71.11058 92.64439 22 | 77.84318 3.756985 20.72 0.000 70.47381 85.21256 23 | 73.80888 2.538936 29.07 0.000 68.82873 78.78904 24 | 69.37115 2.765973 25.08 0.000 63.94566 74.79664 25 | 64.52999 4.525755 14.26 0.000 55.65266 73.40731 26 | 83.98157 6.176942 13.60 0.000 71.86542 96.09772 27 | 79.94727 4.544335 17.59 0.000 71.0335 88.86104 28 | 75.91296 3.390235 22.39 0.000 69.26298 82.56295 29 | 71.47523 3.325764 21.49 0.000 64.9517 77.99876 30 | 66.63407 4.701734 14.17 0.000 57.41156 75.85658 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: parity milk120 . margins , at( milk120=(1200 2200 3200 4300 5500) parity=(1(1)6) ) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : parity = 1 milk120 = 1200 2._at : parity = 1 milk120 = 2200 3._at : parity = 1 milk120 = 3200 4._at : parity = 1 milk120 = 4300 5._at : parity = 1 milk120 = 5500 6._at : parity = 2 milk120 = 1200 7._at : parity = 2 milk120 = 2200 8._at : parity = 2 milk120 = 3200 9._at : parity = 2 milk120 = 4300 10._at : parity = 2 milk120 = 5500 11._at : parity = 3 milk120 = 1200 12._at : parity = 3 milk120 = 2200 13._at : parity = 3 milk120 = 3200 14._at : parity = 3 milk120 = 4300 15._at : parity = 3 milk120 = 5500 16._at : parity = 4 milk120 = 1200 17._at : parity = 4 milk120 = 2200 18._at : parity = 4 milk120 = 3200 19._at : parity = 4 milk120 = 4300 20._at : parity = 4 milk120 = 5500 21._at : parity = 5 milk120 = 1200 22._at : parity = 5 milk120 = 2200 23._at : parity = 5 milk120 = 3200 24._at : parity = 5 milk120 = 4300 25._at : parity = 5 milk120 = 5500 26._at : parity = 6 milk120 = 1200 27._at : parity = 6 milk120 = 2200 28._at : parity = 6 milk120 = 3200 29._at : parity = 6 milk120 = 4300 30._at : parity = 6 milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 73.46115 4.026674 18.24 0.000 65.56278 81.35952 2 | 69.42685 2.480564 27.99 0.000 64.56119 74.29251 3 | 65.39255 2.106807 31.04 0.000 61.26002 69.52508 4 | 60.95481 3.491797 17.46 0.000 54.10561 67.80402 5 | 56.11365 5.671817 9.89 0.000 44.98831 67.23899 6 | 75.56523 4.118946 18.35 0.000 67.48587 83.6446 7 | 71.53093 2.327288 30.74 0.000 66.96593 76.09594 8 | 67.49663 1.48767 45.37 0.000 64.57855 70.41471 9 | 63.0589 2.886134 21.85 0.000 57.39771 68.72009 10 | 58.21774 5.149795 11.30 0.000 48.11635 68.31912 11 | 77.66932 4.419907 17.57 0.000 68.99962 86.33902 12 | 73.63502 2.549035 28.89 0.000 68.63505 78.63498 13 | 69.60071 1.343849 51.79 0.000 66.96474 72.23669 14 | 65.16298 2.507018 25.99 0.000 60.24543 70.08053 15 | 60.32182 4.76335 12.66 0.000 50.97845 69.66519 16 | 79.7734 4.891183 16.31 0.000 70.17928 89.36752 17 | 75.7391 3.065475 24.71 0.000 69.72613 81.75207 18 | 71.7048 1.793583 39.98 0.000 68.18666 75.22293 19 | 67.26707 2.461453 27.33 0.000 62.43889 72.09524 20 | 62.4259 4.547181 13.73 0.000 53.50655 71.34526 21 | 81.87749 5.489082 14.92 0.000 71.11058 92.64439 22 | 77.84318 3.756985 20.72 0.000 70.47381 85.21256 23 | 73.80888 2.538936 29.07 0.000 68.82873 78.78904 24 | 69.37115 2.765973 25.08 0.000 63.94566 74.79664 25 | 64.52999 4.525755 14.26 0.000 55.65266 73.40731 26 | 83.98157 6.176942 13.60 0.000 71.86542 96.09772 27 | 79.94727 4.544335 17.59 0.000 71.0335 88.86104 28 | 75.91296 3.390235 22.39 0.000 69.26298 82.56295 29 | 71.47523 3.325764 21.49 0.000 64.9517 77.99876 30 | 66.63407 4.701734 14.17 0.000 57.41156 75.85658 ------------------------------------------------------------------------------ . marginsplot, noci /* changing roles in plot */ Variables that uniquely identify margins: milk120 parity . margins , at( milk120=(1200 2200 3200 4300 5500) (median)parity) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : parity = 2 (median) milk120 = 1200 2._at : parity = 2 (median) milk120 = 2200 3._at : parity = 2 (median) milk120 = 3200 4._at : parity = 2 (median) milk120 = 4300 5._at : parity = 2 (median) milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 75.56523 4.118946 18.35 0.000 67.48587 83.6446 2 | 71.53093 2.327288 30.74 0.000 66.96593 76.09594 3 | 67.49663 1.48767 45.37 0.000 64.57855 70.41471 4 | 63.0589 2.886134 21.85 0.000 57.39771 68.72009 5 | 58.21774 5.149795 11.30 0.000 48.11635 68.31912 ------------------------------------------------------------------------------ . marginsplot Variables that uniquely identify margins: milk120 . lincom _cons+milk120*1200+parity*2 /* milk120=1200, parity=2 */ ( 1) 2*parity + 1200*milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 75.56523 4.118946 18.35 0.000 67.48587 83.6446 ------------------------------------------------------------------------------ . margins, atmeans Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() at : parity = 2.736328 (mean) milk120 = 3215.096 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | 68.98503 1.317516 52.36 0.000 66.4007 71.56935 ------------------------------------------------------------------------------ . lincom _cons+milk120*3215.096+parity*2.73628 /* both at means */ ( 1) 2.73628*parity + 3215.096*milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 68.98492 1.317516 52.36 0.000 66.4006 71.56925 ------------------------------------------------------------------------------ . * interaction model . regress wpc c.parity##c.milk120 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(3, 1532) = 2.26 Model | 18084.1915 3 6028.06382 Prob > F = 0.0797 Residual | 4086280.46 1,532 2667.2849 R-squared = 0.0044 -------------+---------------------------------- Adj R-squared = 0.0025 Total | 4104364.66 1,535 2673.8532 Root MSE = 51.646 ------------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------------+---------------------------------------------------------------- parity | 4.88999 4.437817 1.10 0.271 -3.814849 13.59483 milk120 | -.0016664 .0042125 -0.40 0.692 -.0099293 .0065965 | c.parity#c.milk120 | -.0008764 .0013635 -0.64 0.520 -.003551 .0017981 | _cons | 69.02201 12.77659 5.40 0.000 43.96056 94.08347 ------------------------------------------------------------------------------------ . margins , at( parity=(1(1)6) milk120=(1200 2200 3200 4300 5500)) Adjusted predictions Number of obs = 1,536 Model VCE : OLS Expression : Linear prediction, predict() 1._at : parity = 1 milk120 = 1200 2._at : parity = 1 milk120 = 2200 3._at : parity = 1 milk120 = 3200 4._at : parity = 1 milk120 = 4300 5._at : parity = 1 milk120 = 5500 6._at : parity = 2 milk120 = 1200 7._at : parity = 2 milk120 = 2200 8._at : parity = 2 milk120 = 3200 9._at : parity = 2 milk120 = 4300 10._at : parity = 2 milk120 = 5500 11._at : parity = 3 milk120 = 1200 12._at : parity = 3 milk120 = 2200 13._at : parity = 3 milk120 = 3200 14._at : parity = 3 milk120 = 4300 15._at : parity = 3 milk120 = 5500 16._at : parity = 4 milk120 = 1200 17._at : parity = 4 milk120 = 2200 18._at : parity = 4 milk120 = 3200 19._at : parity = 4 milk120 = 4300 20._at : parity = 4 milk120 = 5500 21._at : parity = 5 milk120 = 1200 22._at : parity = 5 milk120 = 2200 23._at : parity = 5 milk120 = 3200 24._at : parity = 5 milk120 = 4300 25._at : parity = 5 milk120 = 5500 26._at : parity = 6 milk120 = 1200 27._at : parity = 6 milk120 = 2200 28._at : parity = 6 milk120 = 3200 29._at : parity = 6 milk120 = 4300 30._at : parity = 6 milk120 = 5500 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 70.8606 5.708639 12.41 0.000 59.66303 82.05818 2 | 68.31777 3.022034 22.61 0.000 62.39001 74.24553 3 | 65.77493 2.189574 30.04 0.000 61.48005 70.06981 4 | 62.97782 4.701336 13.40 0.000 53.75608 72.19955 5 | 59.92642 8.207704 7.30 0.000 43.82689 76.02594 6 | 74.69887 4.334614 17.23 0.000 66.19647 83.20127 7 | 71.2796 2.360345 30.20 0.000 66.64975 75.90945 8 | 67.86033 1.591905 42.63 0.000 64.73779 70.98287 9 | 64.09913 3.309373 19.37 0.000 57.60775 70.59051 10 | 59.99601 5.846725 10.26 0.000 48.52758 71.46444 11 | 78.53714 4.622317 16.99 0.000 69.4704 87.60387 12 | 74.24143 2.718476 27.31 0.000 68.9091 79.57376 13 | 69.94572 1.447313 48.33 0.000 67.1068 72.78465 14 | 65.22045 2.509091 25.99 0.000 60.29883 70.14206 15 | 60.0656 4.780908 12.56 0.000 50.68778 69.44341 16 | 82.3754 6.349754 12.97 0.000 69.92027 94.83053 17 | 77.20326 3.819598 20.21 0.000 69.71107 84.69545 18 | 72.03112 1.864377 38.64 0.000 68.37412 75.68812 19 | 66.34176 2.851897 23.26 0.000 60.74773 71.9358 20 | 60.13519 5.777981 10.41 0.000 48.8016 71.46878 21 | 86.21367 8.697676 9.91 0.000 69.15306 103.2743 22 | 80.16509 5.212379 15.38 0.000 69.94094 90.38924 23 | 74.11651 2.584128 28.68 0.000 69.04771 79.18531 24 | 67.46308 4.057744 16.63 0.000 59.50376 75.4224 25 | 60.20478 8.109756 7.42 0.000 44.29739 76.11218 26 | 90.05194 11.28523 7.98 0.000 67.91581 112.1881 27 | 83.12692 6.717797 12.37 0.000 69.94987 96.30397 28 | 76.20191 3.42055 22.28 0.000 69.49245 82.91136 29 | 68.58439 5.593876 12.26 0.000 57.61193 79.55686 30 | 60.27437 10.95474 5.50 0.000 38.7865 81.76224 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: parity milk120 . lincom _cons+milk120*1200+parity*2+milk120#c.parity*2400 /* milk120=1200, parity=2 */ ( 1) 2*parity + 1200*milk120 + 2400*c.parity#c.milk120 + _cons = 0 ------------------------------------------------------------------------------ wpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 74.69887 4.334614 17.23 0.000 66.19647 83.20127 ------------------------------------------------------------------------------ . . * VER Ex. 14.16: estimates on sqrt-scale and backtransformed . gen calv_mth=month(calv_dt) . gen aut_calv=(calv_mth>=2 & calv_mth<=7) if !missing(calv_mth) . gen rootwpc=sqrt(wpc) . regress rootwpc aut_calv c.herd_size##c.herd_size parity twin dyst rp##vag_disch Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(9, 1564) = 16.19 Model | 1133.93223 9 125.99247 Prob > F = 0.0000 Residual | 12172.3346 1,564 7.78282264 R-squared = 0.0852 -------------+---------------------------------- Adj R-squared = 0.0800 Total | 13306.2668 1,573 8.45916519 Root MSE = 2.7898 ----------------------------------------------------------------------------------------- rootwpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] ------------------------+---------------------------------------------------------------- aut_calv | -.5136529 .1419214 -3.62 0.000 -.7920293 -.2352766 herd_size | -.0232678 .0084168 -2.76 0.006 -.0397771 -.0067585 | c.herd_size#c.herd_size | .0000709 .0000174 4.07 0.000 .0000367 .000105 | parity | .058304 .0480002 1.21 0.225 -.0358476 .1524556 twin | 1.385453 .5505819 2.52 0.012 .3054964 2.465409 dyst | .5422828 .3054896 1.78 0.076 -.0569296 1.141495 | rp | yes | .3894596 .2691054 1.45 0.148 -.1383858 .917305 | vag_disch | yes | -.0132839 .4004945 -0.03 0.974 -.7988467 .7722788 | rp#vag_disch | yes#yes | 1.491019 .6999486 2.13 0.033 .1180826 2.863956 | _cons | 8.834599 .9921073 8.90 0.000 6.888598 10.7806 ----------------------------------------------------------------------------------------- . *1) correct estimate and CI for rp=1, vag_disch=0, dyst=1 . lincom _cons+aut_calv*0+herd_size*251+c.herd_size#c.herd_size*63001+parity*1+twin*0+dyst*1+1.r > p+0.vag_disch+1.rp#0.vag_disch ( 1) 251*herd_size + 63001*c.herd_size#c.herd_size + parity + dyst + 1.rp + 0b.vag_disch + 1o.rp#0b.vag_disch + _cons = 0 ------------------------------------------------------------------------------ rootwpc | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 8.448395 .3770661 22.41 0.000 7.708787 9.188003 ------------------------------------------------------------------------------ . *1) correct estimate and SE using margins command . margins , over(rp vag_disch dyst) at(parity=1 aut_calv=0 herd_size=251 twin=0) Predictive margins Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() over : rp vag_disch dyst at : 0.rp#0.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#0.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#1.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#1.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#0.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#0.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#1.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#1.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 ----------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] ------------------+---------------------------------------------------------------- rp#vag_disch#dyst | no#no#no | 7.516653 .1473104 51.03 0.000 7.227706 7.805599 no#no#yes | 8.058936 .310164 25.98 0.000 7.450554 8.667317 no#yes#no | 7.503369 .4023829 18.65 0.000 6.714102 8.292636 no#yes#yes | 8.045652 .4553635 17.67 0.000 7.152464 8.938839 yes#no#no | 7.906112 .2801134 28.22 0.000 7.356675 8.45555 yes#no#yes | 8.448395 .3770661 22.41 0.000 7.708787 9.188003 yes#yes#no | 9.383847 .5287705 17.75 0.000 8.346674 10.42102 yes#yes#yes | 9.92613 .5925179 16.75 0.000 8.763917 11.08834 ----------------------------------------------------------------------------------- . *1) correct backtransformed estimate, but inappropriate CI . margins , over(rp vag_disch dyst) at(parity=1 aut_calv=0 herd_size=251 twin=0) expr(predict(xb > )^2) Predictive margins Number of obs = 1,574 Model VCE : OLS Expression : predict(xb)^2 over : rp vag_disch dyst at : 0.rp#0.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#0.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#1.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 0.rp#1.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#0.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#0.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#1.vag_disch#0.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 1.rp#1.vag_disch#1.dyst aut_calv = 0 herd_size = 251 parity = 1 twin = 0 ----------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] ------------------+---------------------------------------------------------------- rp#vag_disch#dyst | no#no#no | 56.50007 2.214563 25.51 0.000 52.1596 60.84053 no#no#yes | 64.94644 4.999184 12.99 0.000 55.14822 74.74466 no#yes#no | 56.30054 6.038455 9.32 0.000 44.46539 68.1357 no#yes#yes | 64.73251 7.327391 8.83 0.000 50.37109 79.09393 yes#no#no | 62.50661 4.429216 14.11 0.000 53.82551 71.18771 yes#no#yes | 71.37538 6.371206 11.20 0.000 58.88805 83.86271 yes#yes#no | 88.05659 9.923803 8.87 0.000 68.6063 107.5069 yes#yes#yes | 98.52806 11.76282 8.38 0.000 75.47336 121.5828 ----------------------------------------------------------------------------------- . table rp dyst vag_disch, contents(count wpc ) ---------------------------------------- Retained | Vaginal discharge observed placenta | and Dystocia at calving at | ---- no ---- ---- yes --- calving | no yes no yes ----------+----------------------------- no | 1,307 66 40 12 yes | 105 14 28 2 ---------------------------------------- . table parity ---------------------- Lactation | number | Freq. ----------+----------- 1 | 417 2 | 374 3 | 319 4 | 222 5 | 169 6 | 69 7 | 4 ---------------------- . table twin ---------------------- Twins | born | Freq. ----------+----------- no | 1,547 yes | 27 ---------------------- . sum herd_size Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- herd_size | 1,574 251.0076 62.01692 125 333 . table aut_calv ---------------------- aut_calv | Freq. ----------+----------- 0 | 831 1 | 743 ---------------------- . *3) correct estimate and SE using margins command . margins , at(parity=1 aut_calv=0 herd_size=(125 185 201 235 263 294 333) twin=0 rp=0 dyst=0 va > g_disch=0) Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : Linear prediction, predict() 1._at : aut_calv = 0 herd_size = 125 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 2._at : aut_calv = 0 herd_size = 185 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 3._at : aut_calv = 0 herd_size = 201 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 4._at : aut_calv = 0 herd_size = 235 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 5._at : aut_calv = 0 herd_size = 263 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 6._at : aut_calv = 0 herd_size = 294 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 7._at : aut_calv = 0 herd_size = 333 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 7.091544 .2559118 27.71 0.000 6.589578 7.59351 2 | 7.013389 .1550613 45.23 0.000 6.709239 7.317539 3 | 7.078708 .1514358 46.74 0.000 6.781669 7.375746 4 | 7.337965 .1497933 48.99 0.000 7.044148 7.631782 5 | 7.674476 .1445034 53.11 0.000 7.391035 7.957917 6 | 8.176637 .1404317 58.23 0.000 7.901183 8.452091 7 | 9.001823 .1805099 49.87 0.000 8.647756 9.35589 ------------------------------------------------------------------------------ . table herd_size ---------------------- Herd size | Freq. ----------+----------- 125 | 129 185 | 168 201 | 203 235 | 227 263 | 253 294 | 272 333 | 322 ---------------------- . *3) correct backtransformed estimate, but inappropriate CI . margins , at(parity=1 aut_calv=0 herd_size=(125 185 201 235 263 294 333) twin=0 rp=0 dyst=0 va > g_disch=0) expr(predict(xb)^2) Adjusted predictions Number of obs = 1,574 Model VCE : OLS Expression : predict(xb)^2 1._at : aut_calv = 0 herd_size = 125 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 2._at : aut_calv = 0 herd_size = 185 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 3._at : aut_calv = 0 herd_size = 201 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 4._at : aut_calv = 0 herd_size = 235 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 5._at : aut_calv = 0 herd_size = 263 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 6._at : aut_calv = 0 herd_size = 294 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 7._at : aut_calv = 0 herd_size = 333 parity = 1 twin = 0 dyst = 0 rp = 0 vag_disch = 0 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | 50.29 3.629619 13.86 0.000 43.17607 57.40392 2 | 49.18762 2.17501 22.61 0.000 44.92468 53.45056 3 | 50.1081 2.143939 23.37 0.000 45.90606 54.31015 4 | 53.84573 2.198356 24.49 0.000 49.53703 58.15443 5 | 58.89758 2.217976 26.55 0.000 54.55043 63.24473 6 | 66.85739 2.296517 29.11 0.000 62.3563 71.35848 7 | 81.03282 3.249837 24.93 0.000 74.66326 87.40238 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: herd_size . . . * logistic regression for Nocardia data . use nocardia.dta, clear . * effects on probability scale . logit casecont i.dneo i.dclox dcpct Iteration 0: log likelihood = -74.859896 Iteration 1: log likelihood = -54.156164 Iteration 2: log likelihood = -53.993934 Iteration 3: log likelihood = -53.993656 Iteration 4: log likelihood = -53.993656 Logistic regression Number of obs = 108 LR chi2(3) = 41.73 Prob > chi2 = 0.0000 Log likelihood = -53.993656 Pseudo R2 = 0.2787 ------------------------------------------------------------------------------ casecont | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- dneo | yes | 2.212564 .5780423 3.83 0.000 1.079622 3.345506 | dclox | yes | -1.412516 .5572076 -2.53 0.011 -2.504623 -.3204093 dcpct | .0226682 .0071871 3.15 0.002 .0085817 .0367547 _cons | -2.984272 .7722467 -3.86 0.000 -4.497848 -1.470697 ------------------------------------------------------------------------------ . predict phat (option pr assumed; Pr(casecont)) . predict logitphat, xb . * plots of predicted values - for demonstration only (not valid in case-control study) . twoway (connected logitphat dcpct if dneo==1 & dclox==0, sort) (connected logitphat dcpct if d > neo==0 & dclox==0, sort) . twoway (connected phat dcpct if dneo==1 & dclox==0, sort) (connected phat dcpct if dneo==0 & d > clox==0, sort) . * incorrect plots (next 6 lines) . twoway (connected logitphat dcpct, sort) . twoway (lfit logitphat dcpct) . twoway (lowess logitphat dcpct) . twoway (connected phat dcpct, sort) . twoway (lfit phat dcpct) . twoway (lowess phat dcpct) . * manually created prediction values and plots . set obs 119 number of observations (_N) was 108, now 119 . replace dneo=0 in 109/119 (11 real changes made) . replace dclox=0 in 109/119 (11 real changes made) . replace dcpct=0+(_n-109)*10 in 109/119 (11 real changes made) . capture drop phat logitphat . predict phat (option pr assumed; Pr(casecont)) . predict logitphat, xb . twoway (connected logitphat dcpct in 109/119, sort) . twoway (connected phat dcpct in 109/119, sort) . . * estimation and plots by margins and marginsplot commands . margins, at(dcpct=(0(10)100) dneo=1 dclox=0) at(dcpct=(0(10)100) dneo=0 dclox=0) predict(xb) Adjusted predictions Number of obs = 108 Model VCE : OIM Expression : Linear prediction (log odds), predict(xb) 1._at : dneo = 1 dclox = 0 dcpct = 0 2._at : dneo = 1 dclox = 0 dcpct = 10 3._at : dneo = 1 dclox = 0 dcpct = 20 4._at : dneo = 1 dclox = 0 dcpct = 30 5._at : dneo = 1 dclox = 0 dcpct = 40 6._at : dneo = 1 dclox = 0 dcpct = 50 7._at : dneo = 1 dclox = 0 dcpct = 60 8._at : dneo = 1 dclox = 0 dcpct = 70 9._at : dneo = 1 dclox = 0 dcpct = 80 10._at : dneo = 1 dclox = 0 dcpct = 90 11._at : dneo = 1 dclox = 0 dcpct = 100 12._at : dneo = 0 dclox = 0 dcpct = 0 13._at : dneo = 0 dclox = 0 dcpct = 10 14._at : dneo = 0 dclox = 0 dcpct = 20 15._at : dneo = 0 dclox = 0 dcpct = 30 16._at : dneo = 0 dclox = 0 dcpct = 40 17._at : dneo = 0 dclox = 0 dcpct = 50 18._at : dneo = 0 dclox = 0 dcpct = 60 19._at : dneo = 0 dclox = 0 dcpct = 70 20._at : dneo = 0 dclox = 0 dcpct = 80 21._at : dneo = 0 dclox = 0 dcpct = 90 22._at : dneo = 0 dclox = 0 dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | -.7717085 .5987154 -1.29 0.197 -1.945169 .4017521 2 | -.545026 .5378343 -1.01 0.311 -1.599162 .5091099 3 | -.3183436 .4800024 -0.66 0.507 -1.259131 .6224439 4 | -.0916611 .426462 -0.21 0.830 -.9275113 .744189 5 | .1350213 .379036 0.36 0.722 -.6078756 .8779183 6 | .3617038 .3402906 1.06 0.288 -.3052536 1.028661 7 | .5883862 .3134615 1.88 0.061 -.0259869 1.202759 8 | .8150687 .3017439 2.70 0.007 .2236615 1.406476 9 | 1.041751 .306874 3.39 0.001 .4402891 1.643213 10 | 1.268434 .3280623 3.87 0.000 .6254433 1.911424 11 | 1.495116 .3625038 4.12 0.000 .7846216 2.205611 12 | -2.984272 .7722467 -3.86 0.000 -4.497848 -1.470697 13 | -2.75759 .7219825 -3.82 0.000 -4.17265 -1.34253 14 | -2.530907 .6756357 -3.75 0.000 -3.855129 -1.206686 15 | -2.304225 .6340656 -3.63 0.000 -3.546971 -1.061479 16 | -2.077543 .5982691 -3.47 0.001 -3.250128 -.9049568 17 | -1.85086 .569336 -3.25 0.001 -2.966738 -.7349821 18 | -1.624178 .5483539 -2.96 0.003 -2.698932 -.5494237 19 | -1.397495 .5362569 -2.61 0.009 -2.448539 -.3464509 20 | -1.170813 .5336496 -2.19 0.028 -2.216747 -.1248787 21 | -.9441303 .5406693 -1.75 0.081 -2.003823 .1155621 22 | -.7174478 .5569521 -1.29 0.198 -1.809054 .3741583 ------------------------------------------------------------------------------ . marginsplot Variables that uniquely identify margins: dcpct _atopt Multiple at() options specified: _atoption=1: dcpct=(0(10)100) dneo=1 dclox=0 _atoption=2: dcpct=(0(10)100) dneo=0 dclox=0 . margins, at(dcpct=(0(10)100) dneo=1 dclox=0) at(dcpct=(0(10)100) dneo=0 dclox=0) expression(1/ > (1+exp(-predict(xb)))) Adjusted predictions Number of obs = 108 Model VCE : OIM Expression : 1/(1+exp(-predict(xb))) 1._at : dneo = 1 dclox = 0 dcpct = 0 2._at : dneo = 1 dclox = 0 dcpct = 10 3._at : dneo = 1 dclox = 0 dcpct = 20 4._at : dneo = 1 dclox = 0 dcpct = 30 5._at : dneo = 1 dclox = 0 dcpct = 40 6._at : dneo = 1 dclox = 0 dcpct = 50 7._at : dneo = 1 dclox = 0 dcpct = 60 8._at : dneo = 1 dclox = 0 dcpct = 70 9._at : dneo = 1 dclox = 0 dcpct = 80 10._at : dneo = 1 dclox = 0 dcpct = 90 11._at : dneo = 1 dclox = 0 dcpct = 100 12._at : dneo = 0 dclox = 0 dcpct = 0 13._at : dneo = 0 dclox = 0 dcpct = 10 14._at : dneo = 0 dclox = 0 dcpct = 20 15._at : dneo = 0 dclox = 0 dcpct = 30 16._at : dneo = 0 dclox = 0 dcpct = 40 17._at : dneo = 0 dclox = 0 dcpct = 50 18._at : dneo = 0 dclox = 0 dcpct = 60 19._at : dneo = 0 dclox = 0 dcpct = 70 20._at : dneo = 0 dclox = 0 dcpct = 80 21._at : dneo = 0 dclox = 0 dcpct = 90 22._at : dneo = 0 dclox = 0 dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | .3161096 .1294329 2.44 0.015 .0624258 .5697934 2 | .3670192 .1249476 2.94 0.003 .1221264 .6119119 3 | .4210795 .1170109 3.60 0.000 .1917423 .6504167 4 | .4771007 .1063919 4.48 0.000 .2685765 .685625 5 | .5337041 .0943284 5.66 0.000 .3488238 .7185845 6 | .5894528 .0823497 7.16 0.000 .4280503 .7508553 7 | .6429948 .0719559 8.94 0.000 .5019639 .7840257 8 | .6931886 .0641743 10.80 0.000 .5674091 .818968 9 | .7391878 .059162 12.49 0.000 .6232324 .8551431 10 | .7804745 .0562082 13.89 0.000 .6703084 .8906406 11 | .8168449 .0542339 15.06 0.000 .7105483 .9231415 12 | .0481415 .0353873 1.36 0.174 -.0212164 .1174994 13 | .0596594 .0405034 1.47 0.141 -.0197257 .1390445 14 | .0737197 .0461358 1.60 0.110 -.0167049 .1641442 15 | .0907736 .0523318 1.73 0.083 -.0117949 .1933422 16 | .1112988 .0591756 1.88 0.060 -.0046833 .2272809 17 | .1357719 .0668047 2.03 0.042 .0048371 .2667067 18 | .1646295 .0754133 2.18 0.029 .0168222 .3124368 19 | .1982139 .0852247 2.33 0.020 .0311765 .3652512 20 | .2367081 .0964184 2.46 0.014 .0477315 .4256847 21 | .2800668 .1090148 2.57 0.010 .0664017 .4937319 22 | .3279552 .1227526 2.67 0.008 .0873646 .5685459 ------------------------------------------------------------------------------ . marginsplot, noci /* CIs incorrect */ Variables that uniquely identify margins: dcpct _atopt Multiple at() options specified: _atoption=1: dcpct=(0(10)100) dneo=1 dclox=0 _atoption=2: dcpct=(0(10)100) dneo=0 dclox=0 . margins, over(dcpct) at(dneo=1 dclox=0) at(dneo=0 dclox=0) expression(1/(1+exp(-predict(xb)))) Predictive margins Number of obs = 108 Model VCE : OIM Expression : 1/(1+exp(-predict(xb))) over : dcpct 1._at : 0.dcpct dneo = 1 dclox = 0 1.dcpct dneo = 1 dclox = 0 3.dcpct dneo = 1 dclox = 0 5.dcpct dneo = 1 dclox = 0 7.dcpct dneo = 1 dclox = 0 10.dcpct dneo = 1 dclox = 0 14.dcpct dneo = 1 dclox = 0 20.dcpct dneo = 1 dclox = 0 25.dcpct dneo = 1 dclox = 0 30.dcpct dneo = 1 dclox = 0 40.dcpct dneo = 1 dclox = 0 50.dcpct dneo = 1 dclox = 0 75.dcpct dneo = 1 dclox = 0 80.dcpct dneo = 1 dclox = 0 83.dcpct dneo = 1 dclox = 0 90.dcpct dneo = 1 dclox = 0 95.dcpct dneo = 1 dclox = 0 99.dcpct dneo = 1 dclox = 0 100.dcpct dneo = 1 dclox = 0 2._at : 0.dcpct dneo = 0 dclox = 0 1.dcpct dneo = 0 dclox = 0 3.dcpct dneo = 0 dclox = 0 5.dcpct dneo = 0 dclox = 0 7.dcpct dneo = 0 dclox = 0 10.dcpct dneo = 0 dclox = 0 14.dcpct dneo = 0 dclox = 0 20.dcpct dneo = 0 dclox = 0 25.dcpct dneo = 0 dclox = 0 30.dcpct dneo = 0 dclox = 0 40.dcpct dneo = 0 dclox = 0 50.dcpct dneo = 0 dclox = 0 75.dcpct dneo = 0 dclox = 0 80.dcpct dneo = 0 dclox = 0 83.dcpct dneo = 0 dclox = 0 90.dcpct dneo = 0 dclox = 0 95.dcpct dneo = 0 dclox = 0 99.dcpct dneo = 0 dclox = 0 100.dcpct dneo = 0 dclox = 0 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#dcpct | 1 0 | .3161096 .1294329 2.44 0.015 .0624258 .5697934 1 1 | .3210305 .1291508 2.49 0.013 .0678996 .5741613 1 3 | .3309916 .1284744 2.58 0.010 .0791864 .5827968 1 5 | .3411065 .1276492 2.67 0.008 .0909186 .5912944 1 7 | .3513681 .1266768 2.77 0.006 .1030861 .5996502 1 10 | .3670192 .1249476 2.94 0.003 .1221264 .6119119 1 14 | .3883263 .1221557 3.18 0.001 .1489056 .627747 1 20 | .4210795 .1170109 3.60 0.000 .1917423 .6504167 1 25 | .4489281 .1119689 4.01 0.000 .2294731 .6683832 1 30 | .4771007 .1063919 4.48 0.000 .2685765 .685625 1 40 | .5337041 .0943284 5.66 0.000 .3488238 .7185845 1 50 | .5894528 .0823497 7.16 0.000 .4280503 .7508553 1 75 | .7167526 .0613502 11.68 0.000 .5965083 .8369968 1 80 | .7391878 .059162 12.49 0.000 .6232324 .8551431 1 83 | .7520836 .0581075 12.94 0.000 .638195 .8659722 1 90 | .7804745 .0562082 13.89 0.000 .6703084 .8906406 1 95 | .7992759 .0551635 14.49 0.000 .6911574 .9073944 1 99 | .8134292 .0544159 14.95 0.000 .7067759 .9200824 1 100 | .8168449 .0542339 15.06 0.000 .7105483 .9231415 2 0 | .0481415 .0353873 1.36 0.174 -.0212164 .1174994 2 1 | .0491909 .0358766 1.37 0.170 -.0211258 .1195077 2 3 | .0513552 .0368698 1.39 0.164 -.0209082 .1236186 2 5 | .0536094 .0378828 1.42 0.157 -.0206395 .1278583 2 7 | .0559567 .0389158 1.44 0.150 -.0203169 .1322302 2 10 | .0596594 .0405034 1.47 0.141 -.0197257 .1390445 2 14 | .064954 .0426923 1.52 0.128 -.0187215 .1486294 2 20 | .0737197 .0461358 1.60 0.110 -.0167049 .1641442 2 25 | .081843 .0491592 1.66 0.096 -.0145073 .1781932 2 30 | .0907736 .0523318 1.73 0.083 -.0117949 .1933422 2 40 | .1112988 .0591756 1.88 0.060 -.0046833 .2272809 2 50 | .1357719 .0668047 2.03 0.042 .0048371 .2667067 2 75 | .216844 .0906423 2.39 0.017 .0391884 .3944995 2 80 | .2367081 .0964184 2.46 0.014 .0477315 .4256847 2 83 | .2492141 .1000555 2.49 0.013 .0531089 .4453194 2 90 | .2800668 .1090148 2.57 0.010 .0664017 .4937319 2 95 | .3034783 .115771 2.62 0.009 .0765712 .5303853 2 99 | .3229788 .1213422 2.66 0.008 .0851524 .5608051 2 100 | .3279552 .1227526 2.67 0.008 .0873646 .5685459 ------------------------------------------------------------------------------ . marginsplot, noci /* CIs incorrect */ Variables that uniquely identify margins: dcpct _atopt Multiple at() options specified: _atoption=1: dneo=1 dclox=0 _atoption=2: dneo=0 dclox=0 . * figure in lecture 4a . margins, over(dcpct) at(dneo=0 dclox=0) at(dneo=1 dclox=0) at(dneo=0 dclox=1) at(dneo=1 dclox= > 1) expression(1/(1+exp(-predict(xb)))) Predictive margins Number of obs = 108 Model VCE : OIM Expression : 1/(1+exp(-predict(xb))) over : dcpct 1._at : 0.dcpct dneo = 0 dclox = 0 1.dcpct dneo = 0 dclox = 0 3.dcpct dneo = 0 dclox = 0 5.dcpct dneo = 0 dclox = 0 7.dcpct dneo = 0 dclox = 0 10.dcpct dneo = 0 dclox = 0 14.dcpct dneo = 0 dclox = 0 20.dcpct dneo = 0 dclox = 0 25.dcpct dneo = 0 dclox = 0 30.dcpct dneo = 0 dclox = 0 40.dcpct dneo = 0 dclox = 0 50.dcpct dneo = 0 dclox = 0 75.dcpct dneo = 0 dclox = 0 80.dcpct dneo = 0 dclox = 0 83.dcpct dneo = 0 dclox = 0 90.dcpct dneo = 0 dclox = 0 95.dcpct dneo = 0 dclox = 0 99.dcpct dneo = 0 dclox = 0 100.dcpct dneo = 0 dclox = 0 2._at : 0.dcpct dneo = 1 dclox = 0 1.dcpct dneo = 1 dclox = 0 3.dcpct dneo = 1 dclox = 0 5.dcpct dneo = 1 dclox = 0 7.dcpct dneo = 1 dclox = 0 10.dcpct dneo = 1 dclox = 0 14.dcpct dneo = 1 dclox = 0 20.dcpct dneo = 1 dclox = 0 25.dcpct dneo = 1 dclox = 0 30.dcpct dneo = 1 dclox = 0 40.dcpct dneo = 1 dclox = 0 50.dcpct dneo = 1 dclox = 0 75.dcpct dneo = 1 dclox = 0 80.dcpct dneo = 1 dclox = 0 83.dcpct dneo = 1 dclox = 0 90.dcpct dneo = 1 dclox = 0 95.dcpct dneo = 1 dclox = 0 99.dcpct dneo = 1 dclox = 0 100.dcpct dneo = 1 dclox = 0 3._at : 0.dcpct dneo = 0 dclox = 1 1.dcpct dneo = 0 dclox = 1 3.dcpct dneo = 0 dclox = 1 5.dcpct dneo = 0 dclox = 1 7.dcpct dneo = 0 dclox = 1 10.dcpct dneo = 0 dclox = 1 14.dcpct dneo = 0 dclox = 1 20.dcpct dneo = 0 dclox = 1 25.dcpct dneo = 0 dclox = 1 30.dcpct dneo = 0 dclox = 1 40.dcpct dneo = 0 dclox = 1 50.dcpct dneo = 0 dclox = 1 75.dcpct dneo = 0 dclox = 1 80.dcpct dneo = 0 dclox = 1 83.dcpct dneo = 0 dclox = 1 90.dcpct dneo = 0 dclox = 1 95.dcpct dneo = 0 dclox = 1 99.dcpct dneo = 0 dclox = 1 100.dcpct dneo = 0 dclox = 1 4._at : 0.dcpct dneo = 1 dclox = 1 1.dcpct dneo = 1 dclox = 1 3.dcpct dneo = 1 dclox = 1 5.dcpct dneo = 1 dclox = 1 7.dcpct dneo = 1 dclox = 1 10.dcpct dneo = 1 dclox = 1 14.dcpct dneo = 1 dclox = 1 20.dcpct dneo = 1 dclox = 1 25.dcpct dneo = 1 dclox = 1 30.dcpct dneo = 1 dclox = 1 40.dcpct dneo = 1 dclox = 1 50.dcpct dneo = 1 dclox = 1 75.dcpct dneo = 1 dclox = 1 80.dcpct dneo = 1 dclox = 1 83.dcpct dneo = 1 dclox = 1 90.dcpct dneo = 1 dclox = 1 95.dcpct dneo = 1 dclox = 1 99.dcpct dneo = 1 dclox = 1 100.dcpct dneo = 1 dclox = 1 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#dcpct | 1 0 | .0481415 .0353873 1.36 0.174 -.0212164 .1174994 1 1 | .0491909 .0358766 1.37 0.170 -.0211258 .1195077 1 3 | .0513552 .0368698 1.39 0.164 -.0209082 .1236186 1 5 | .0536094 .0378828 1.42 0.157 -.0206395 .1278583 1 7 | .0559567 .0389158 1.44 0.150 -.0203169 .1322302 1 10 | .0596594 .0405034 1.47 0.141 -.0197257 .1390445 1 14 | .064954 .0426923 1.52 0.128 -.0187215 .1486294 1 20 | .0737197 .0461358 1.60 0.110 -.0167049 .1641442 1 25 | .081843 .0491592 1.66 0.096 -.0145073 .1781932 1 30 | .0907736 .0523318 1.73 0.083 -.0117949 .1933422 1 40 | .1112988 .0591756 1.88 0.060 -.0046833 .2272809 1 50 | .1357719 .0668047 2.03 0.042 .0048371 .2667067 1 75 | .216844 .0906423 2.39 0.017 .0391884 .3944995 1 80 | .2367081 .0964184 2.46 0.014 .0477315 .4256847 1 83 | .2492141 .1000555 2.49 0.013 .0531089 .4453194 1 90 | .2800668 .1090148 2.57 0.010 .0664017 .4937319 1 95 | .3034783 .115771 2.62 0.009 .0765712 .5303853 1 99 | .3229788 .1213422 2.66 0.008 .0851524 .5608051 1 100 | .3279552 .1227526 2.67 0.008 .0873646 .5685459 2 0 | .3161096 .1294329 2.44 0.015 .0624258 .5697934 2 1 | .3210305 .1291508 2.49 0.013 .0678996 .5741613 2 3 | .3309916 .1284744 2.58 0.010 .0791864 .5827968 2 5 | .3411065 .1276492 2.67 0.008 .0909186 .5912944 2 7 | .3513681 .1266768 2.77 0.006 .1030861 .5996502 2 10 | .3670192 .1249476 2.94 0.003 .1221264 .6119119 2 14 | .3883263 .1221557 3.18 0.001 .1489056 .627747 2 20 | .4210795 .1170109 3.60 0.000 .1917423 .6504167 2 25 | .4489281 .1119689 4.01 0.000 .2294731 .6683832 2 30 | .4771007 .1063919 4.48 0.000 .2685765 .685625 2 40 | .5337041 .0943284 5.66 0.000 .3488238 .7185845 2 50 | .5894528 .0823497 7.16 0.000 .4280503 .7508553 2 75 | .7167526 .0613502 11.68 0.000 .5965083 .8369968 2 80 | .7391878 .059162 12.49 0.000 .6232324 .8551431 2 83 | .7520836 .0581075 12.94 0.000 .638195 .8659722 2 90 | .7804745 .0562082 13.89 0.000 .6703084 .8906406 2 95 | .7992759 .0551635 14.49 0.000 .6911574 .9073944 2 99 | .8134292 .0544159 14.95 0.000 .7067759 .9200824 2 100 | .8168449 .0542339 15.06 0.000 .7105483 .9231415 3 0 | .012167 .0113038 1.08 0.282 -.009988 .0343219 3 1 | .0124425 .0114918 1.08 0.279 -.0100811 .034966 3 3 | .013012 .0118767 1.10 0.273 -.010266 .03629 3 5 | .0136073 .0122738 1.11 0.268 -.0104489 .0376635 3 7 | .0142294 .0126833 1.12 0.262 -.0106294 .0390883 3 10 | .0152155 .013322 1.14 0.253 -.0108951 .0413261 3 14 | .0166356 .0142212 1.17 0.242 -.0112374 .0445086 3 20 | .0190132 .0156799 1.21 0.225 -.0117188 .0497453 3 25 | .0212466 .0170054 1.25 0.212 -.0120834 .0545766 3 30 | .023736 .018441 1.29 0.198 -.0124077 .0598796 3 40 | .0295964 .021688 1.36 0.172 -.0129112 .0721041 3 50 | .0368492 .0255313 1.44 0.149 -.0131913 .0868897 3 75 | .0631701 .0388438 1.63 0.104 -.0129622 .1393025 3 80 | .0702191 .0423739 1.66 0.097 -.0128323 .1532704 3 83 | .0747909 .0446697 1.67 0.094 -.0127601 .1623419 3 90 | .0865389 .0506051 1.71 0.087 -.0126453 .1857232 3 95 | .0959285 .0553947 1.73 0.083 -.012643 .2045001 3 99 | .1040855 .0595911 1.75 0.081 -.012711 .220882 3 100 | .1062184 .0606939 1.75 0.080 -.0127395 .2251763 4 0 | .1011761 .0737216 1.37 0.170 -.0433155 .2456678 4 1 | .1032563 .0745313 1.39 0.166 -.0428223 .2493348 4 3 | .1075303 .0761506 1.41 0.158 -.041722 .2567827 4 5 | .1119592 .077768 1.44 0.150 -.0404632 .2643816 4 7 | .1165467 .0793811 1.47 0.142 -.0390374 .2721307 4 10 | .1237333 .0817875 1.51 0.130 -.0365673 .2840339 4 14 | .1339044 .0849584 1.58 0.115 -.0326111 .3004199 4 20 | .1504777 .0895928 1.68 0.093 -.0251211 .3260764 4 25 | .1655474 .0932996 1.77 0.076 -.0173165 .3484113 4 30 | .1818033 .096825 1.88 0.060 -.0079701 .3715768 4 40 | .217977 .1032015 2.11 0.035 .0157058 .4202482 4 50 | .2590692 .1085332 2.39 0.017 .0463479 .4717904 4 75 | .381283 .117435 3.25 0.001 .1511146 .6114514 4 80 | .4083562 .1186504 3.44 0.001 .1758057 .6409068 4 83 | .4248829 .1193208 3.56 0.000 .1910185 .6587473 4 90 | .4640416 .1207365 3.84 0.000 .2274024 .7006808 4 95 | .4923153 .1216232 4.05 0.000 .2539383 .7306923 4 99 | .5149785 .1222476 4.21 0.000 .2753775 .7545794 4 100 | .5206383 .1223902 4.25 0.000 .280758 .7605186 ------------------------------------------------------------------------------ . marginsplot, noci Variables that uniquely identify margins: dcpct _atopt Multiple at() options specified: _atoption=1: dneo=0 dclox=0 _atoption=2: dneo=1 dclox=0 _atoption=3: dneo=0 dclox=1 _atoption=4: dneo=1 dclox=1 . * illustration of weighting . margins, at(dcpct=(0(10)100)) predict(xb) Predictive margins Number of obs = 108 Model VCE : OIM Expression : Linear prediction (log odds), predict(xb) 1._at : dcpct = 0 2._at : dcpct = 10 3._at : dcpct = 20 4._at : dcpct = 30 5._at : dcpct = 40 6._at : dcpct = 50 7._at : dcpct = 60 8._at : dcpct = 70 9._at : dcpct = 80 10._at : dcpct = 90 11._at : dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | -1.821385 .6139347 -2.97 0.003 -3.024675 -.6180956 2 | -1.594703 .5487433 -2.91 0.004 -2.67022 -.5191858 3 | -1.36802 .4854417 -2.82 0.005 -2.319469 -.4165722 4 | -1.141338 .4248753 -2.69 0.007 -1.974078 -.3085977 5 | -.9146556 .3683957 -2.48 0.013 -1.636698 -.1926133 6 | -.6879731 .3181865 -2.16 0.031 -1.311607 -.064339 7 | -.4612907 .2776705 -1.66 0.097 -1.005515 .0829335 8 | -.2346082 .2515752 -0.93 0.351 -.7276865 .2584701 9 | -.0079257 .2445612 -0.03 0.974 -.487257 .4714055 10 | .2187567 .2581885 0.85 0.397 -.2872834 .7247968 11 | .4454392 .2895571 1.54 0.124 -.1220823 1.012961 ------------------------------------------------------------------------------ . table dneo dclox, row col ------------------------------- Neomycin | Cloxacillin used on used on | farm farm | no yes Total ----------+-------------------- no | 33 12 45 yes | 59 15 74 | Total | 92 27 119 ------------------------------- . lincom _cons+0*dcpct+1.dclox*27/108+1.dneo*74/108 /* dcpct=0 */ ( 1) .6851852*[casecont]1.dneo + .25*[casecont]1.dclox + [casecont]_cons = 0 ------------------------------------------------------------------------------ casecont | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -1.821385 .6139347 -2.97 0.003 -3.024675 -.6180956 ------------------------------------------------------------------------------ . margins, at(dcpct=(0(10)100)) predict(xb) atmeans /* same as above */ Adjusted predictions Number of obs = 108 Model VCE : OIM Expression : Linear prediction (log odds), predict(xb) 1._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 0 2._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 10 3._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 20 4._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 30 5._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 40 6._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 50 7._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 60 8._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 70 9._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 80 10._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 90 11._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | -1.821385 .6139347 -2.97 0.003 -3.024675 -.6180956 2 | -1.594703 .5487433 -2.91 0.004 -2.67022 -.5191858 3 | -1.36802 .4854417 -2.82 0.005 -2.319469 -.4165722 4 | -1.141338 .4248753 -2.69 0.007 -1.974078 -.3085976 5 | -.9146556 .3683957 -2.48 0.013 -1.636698 -.1926133 6 | -.6879731 .3181865 -2.16 0.031 -1.311607 -.064339 7 | -.4612906 .2776705 -1.66 0.097 -1.005515 .0829335 8 | -.2346082 .2515752 -0.93 0.351 -.7276865 .2584701 9 | -.0079257 .2445612 -0.03 0.974 -.487257 .4714055 10 | .2187567 .2581885 0.85 0.397 -.2872834 .7247968 11 | .4454392 .2895571 1.54 0.124 -.1220823 1.012961 ------------------------------------------------------------------------------ . margins, at(dcpct=(0(10)100)) predict(xb) over(dneo dclox) Predictive margins Number of obs = 108 Model VCE : OIM Expression : Linear prediction (log odds), predict(xb) over : dneo dclox 1._at : 0.dneo#0.dclox dcpct = 0 0.dneo#1.dclox dcpct = 0 1.dneo#0.dclox dcpct = 0 1.dneo#1.dclox dcpct = 0 2._at : 0.dneo#0.dclox dcpct = 10 0.dneo#1.dclox dcpct = 10 1.dneo#0.dclox dcpct = 10 1.dneo#1.dclox dcpct = 10 3._at : 0.dneo#0.dclox dcpct = 20 0.dneo#1.dclox dcpct = 20 1.dneo#0.dclox dcpct = 20 1.dneo#1.dclox dcpct = 20 4._at : 0.dneo#0.dclox dcpct = 30 0.dneo#1.dclox dcpct = 30 1.dneo#0.dclox dcpct = 30 1.dneo#1.dclox dcpct = 30 5._at : 0.dneo#0.dclox dcpct = 40 0.dneo#1.dclox dcpct = 40 1.dneo#0.dclox dcpct = 40 1.dneo#1.dclox dcpct = 40 6._at : 0.dneo#0.dclox dcpct = 50 0.dneo#1.dclox dcpct = 50 1.dneo#0.dclox dcpct = 50 1.dneo#1.dclox dcpct = 50 7._at : 0.dneo#0.dclox dcpct = 60 0.dneo#1.dclox dcpct = 60 1.dneo#0.dclox dcpct = 60 1.dneo#1.dclox dcpct = 60 8._at : 0.dneo#0.dclox dcpct = 70 0.dneo#1.dclox dcpct = 70 1.dneo#0.dclox dcpct = 70 1.dneo#1.dclox dcpct = 70 9._at : 0.dneo#0.dclox dcpct = 80 0.dneo#1.dclox dcpct = 80 1.dneo#0.dclox dcpct = 80 1.dneo#1.dclox dcpct = 80 10._at : 0.dneo#0.dclox dcpct = 90 0.dneo#1.dclox dcpct = 90 1.dneo#0.dclox dcpct = 90 1.dneo#1.dclox dcpct = 90 11._at : 0.dneo#0.dclox dcpct = 100 0.dneo#1.dclox dcpct = 100 1.dneo#0.dclox dcpct = 100 1.dneo#1.dclox dcpct = 100 -------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] ---------------+---------------------------------------------------------------- _at#dneo#dclox | 1#no#no | -2.984272 .7722467 -3.86 0.000 -4.497848 -1.470697 1#no#yes | -4.396788 .9404953 -4.67 0.000 -6.240125 -2.553452 1#yes#no | -.7717085 .5987154 -1.29 0.197 -1.945169 .4017521 1#yes#yes | -2.184225 .8106662 -2.69 0.007 -3.773101 -.5953479 2#no#no | -2.75759 .7219825 -3.82 0.000 -4.17265 -1.34253 2#no#yes | -4.170106 .8890788 -4.69 0.000 -5.912668 -2.427544 2#yes#no | -.545026 .5378343 -1.01 0.311 -1.599162 .5091099 2#yes#yes | -1.957542 .754335 -2.60 0.009 -3.436012 -.4790726 3#no#no | -2.530907 .6756357 -3.75 0.000 -3.855129 -1.206686 3#no#yes | -3.943424 .8406675 -4.69 0.000 -5.591102 -2.295745 3#yes#no | -.3183436 .4800024 -0.66 0.507 -1.259131 .6224439 3#yes#yes | -1.73086 .7008523 -2.47 0.014 -3.104505 -.3572144 4#no#no | -2.304225 .6340656 -3.63 0.000 -3.546971 -1.061479 4#no#yes | -3.716741 .79581 -4.67 0.000 -5.2765 -2.156982 4#yes#no | -.0916611 .426462 -0.21 0.830 -.9275113 .744189 4#yes#yes | -1.504177 .6509204 -2.31 0.021 -2.779958 -.2283966 5#no#no | -2.077543 .5982691 -3.47 0.001 -3.250128 -.9049568 5#no#yes | -3.490059 .7551398 -4.62 0.000 -4.970105 -2.010012 5#yes#no | .1350213 .379036 0.36 0.722 -.6078756 .8779183 5#yes#yes | -1.277495 .6054187 -2.11 0.035 -2.464094 -.0908958 6#no#no | -1.85086 .569336 -3.25 0.001 -2.966738 -.7349821 6#no#yes | -3.263376 .7193676 -4.54 0.000 -4.673311 -1.853442 6#yes#no | .3617038 .3402906 1.06 0.288 -.3052536 1.028661 6#yes#yes | -1.050812 .5654177 -1.86 0.063 -2.159011 .0573861 7#no#no | -1.624178 .5483539 -2.96 0.003 -2.698932 -.5494237 7#no#yes | -3.036694 .6892563 -4.41 0.000 -4.387611 -1.685776 7#yes#no | .5883862 .3134615 1.88 0.061 -.0259869 1.202759 7#yes#yes | -.8241298 .5321593 -1.55 0.121 -1.867143 .2188833 8#no#no | -1.397495 .5362569 -2.61 0.009 -2.448539 -.3464509 8#no#yes | -2.810011 .6655747 -4.22 0.000 -4.114514 -1.505509 8#yes#no | .8150687 .3017439 2.70 0.007 .2236615 1.406476 8#yes#yes | -.5974473 .5069722 -1.18 0.239 -1.591095 .3962 9#no#no | -1.170813 .5336496 -2.19 0.028 -2.216747 -.1248787 9#no#yes | -2.583329 .649027 -3.98 0.000 -3.855398 -1.311259 9#yes#no | 1.041751 .306874 3.39 0.001 .4402891 1.643213 9#yes#yes | -.3707649 .4910999 -0.75 0.450 -1.333303 .5917732 10#no#no | -.9441303 .5406693 -1.75 0.081 -2.003823 .1155621 10#no#yes | -2.356646 .6401668 -3.68 0.000 -3.61135 -1.101943 10#yes#no | 1.268434 .3280623 3.87 0.000 .6254433 1.911424 10#yes#yes | -.1440824 .4854568 -0.30 0.767 -1.09556 .8073953 11#no#no | -.7174478 .5569521 -1.29 0.198 -1.809054 .3741583 11#no#yes | -2.129964 .6393135 -3.33 0.001 -3.382995 -.8769324 11#yes#no | 1.495116 .3625038 4.12 0.000 .7846216 2.205611 11#yes#yes | .0826 .4903962 0.17 0.866 -.8785588 1.043759 -------------------------------------------------------------------------------- . di ((-2.984272)*22+(-4.396788)*12+(-.7717085)*59+(-2.184225)*15)/108 /* dcpct=0 again */ -1.8213853 . margins, at(dcpct=(0(10)100)) atmeans /* backtransformed */ Adjusted predictions Number of obs = 108 Model VCE : OIM Expression : Pr(casecont), predict() 1._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 0 2._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 10 3._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 20 4._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 30 5._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 40 6._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 50 7._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 60 8._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 70 9._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 80 10._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 90 11._at : 0.dneo = .3148148 (mean) 1.dneo = .6851852 (mean) 0.dclox = .75 (mean) 1.dclox = .25 (mean) dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | .1392677 .0735937 1.89 0.058 -.0049733 .2835087 2 | .1687233 .0769644 2.19 0.028 .0178758 .3195707 3 | .2029399 .0785228 2.58 0.010 .0490381 .3568416 4 | .2420748 .0779538 3.11 0.002 .0892881 .3948615 5 | .2860481 .0752355 3.80 0.000 .1385893 .4335069 6 | .3344841 .0708297 4.72 0.000 .1956604 .4733079 7 | .3866797 .0658519 5.87 0.000 .2576123 .5157471 8 | .4416155 .0620362 7.12 0.000 .3200267 .5632043 9 | .4980186 .0611394 8.15 0.000 .3781877 .6178495 10 | .5544721 .063781 8.69 0.000 .4294636 .6794806 11 | .6095543 .068914 8.85 0.000 .4744854 .7446232 ------------------------------------------------------------------------------ . di 1/(1+exp(1.821385)) /* dcpct=0, transformed to probability scale */ .13926777 . * weighting on probability scale . margins, at(dcpct=(0(10)100)) /* not the same! */ Predictive margins Number of obs = 108 Model VCE : OIM Expression : Pr(casecont), predict() 1._at : dcpct = 0 2._at : dcpct = 10 3._at : dcpct = 20 4._at : dcpct = 30 5._at : dcpct = 40 6._at : dcpct = 50 7._at : dcpct = 60 8._at : dcpct = 70 9._at : dcpct = 80 10._at : dcpct = 90 11._at : dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | .1979002 .0842364 2.35 0.019 .0328 .3630005 2 | .2315299 .0825239 2.81 0.005 .069786 .3932737 3 | .2680634 .0785496 3.41 0.001 .114109 .4220178 4 | .3070171 .0726128 4.23 0.000 .1646987 .4493355 5 | .3477956 .0653188 5.32 0.000 .2197731 .4758182 6 | .3897493 .0575728 6.77 0.000 .2769088 .5025898 7 | .4322352 .050553 8.55 0.000 .3331532 .5313172 8 | .4746683 .045601 10.41 0.000 .385292 .5640446 9 | .5165521 .0438292 11.79 0.000 .4306484 .6024558 10 | .5574866 .0454685 12.26 0.000 .4683699 .6466033 11 | .597158 .0497083 12.01 0.000 .4997316 .6945844 ------------------------------------------------------------------------------ . margins, at(dcpct=(0(10)100)) expression(1/(1+exp(-predict(xb)))) /* same as preceding line */ Predictive margins Number of obs = 108 Model VCE : OIM Expression : 1/(1+exp(-predict(xb))) 1._at : dcpct = 0 2._at : dcpct = 10 3._at : dcpct = 20 4._at : dcpct = 30 5._at : dcpct = 40 6._at : dcpct = 50 7._at : dcpct = 60 8._at : dcpct = 70 9._at : dcpct = 80 10._at : dcpct = 90 11._at : dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | .1979002 .0842364 2.35 0.019 .0328 .3630005 2 | .2315299 .0825239 2.81 0.005 .069786 .3932737 3 | .2680634 .0785496 3.41 0.001 .114109 .4220178 4 | .3070171 .0726128 4.23 0.000 .1646987 .4493355 5 | .3477956 .0653188 5.32 0.000 .2197731 .4758182 6 | .3897493 .0575728 6.77 0.000 .2769088 .5025898 7 | .4322352 .050553 8.55 0.000 .3331532 .5313172 8 | .4746683 .045601 10.41 0.000 .385292 .5640446 9 | .5165521 .0438292 11.79 0.000 .4306484 .6024558 10 | .5574866 .0454685 12.26 0.000 .4683699 .6466033 11 | .597158 .0497083 12.01 0.000 .4997316 .6945844 ------------------------------------------------------------------------------ . margins, at(dcpct=(0(10)100)) predict(pr) /* same as preceding line */ Predictive margins Number of obs = 108 Model VCE : OIM Expression : Pr(casecont), predict(pr) 1._at : dcpct = 0 2._at : dcpct = 10 3._at : dcpct = 20 4._at : dcpct = 30 5._at : dcpct = 40 6._at : dcpct = 50 7._at : dcpct = 60 8._at : dcpct = 70 9._at : dcpct = 80 10._at : dcpct = 90 11._at : dcpct = 100 ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at | 1 | .1979002 .0842364 2.35 0.019 .0328 .3630005 2 | .2315299 .0825239 2.81 0.005 .069786 .3932737 3 | .2680634 .0785496 3.41 0.001 .114109 .4220178 4 | .3070171 .0726128 4.23 0.000 .1646987 .4493355 5 | .3477956 .0653188 5.32 0.000 .2197731 .4758182 6 | .3897493 .0575728 6.77 0.000 .2769088 .5025898 7 | .4322352 .050553 8.55 0.000 .3331532 .5313172 8 | .4746683 .045601 10.41 0.000 .385292 .5640446 9 | .5165521 .0438292 11.79 0.000 .4306484 .6024558 10 | .5574866 .0454685 12.26 0.000 .4683699 .6466033 11 | .597158 .0497083 12.01 0.000 .4997316 .6945844 ------------------------------------------------------------------------------ . margins, at(dcpct=(0(10)100)) over(dneo dclox) Predictive margins Number of obs = 108 Model VCE : OIM Expression : Pr(casecont), predict() over : dneo dclox 1._at : 0.dneo#0.dclox dcpct = 0 0.dneo#1.dclox dcpct = 0 1.dneo#0.dclox dcpct = 0 1.dneo#1.dclox dcpct = 0 2._at : 0.dneo#0.dclox dcpct = 10 0.dneo#1.dclox dcpct = 10 1.dneo#0.dclox dcpct = 10 1.dneo#1.dclox dcpct = 10 3._at : 0.dneo#0.dclox dcpct = 20 0.dneo#1.dclox dcpct = 20 1.dneo#0.dclox dcpct = 20 1.dneo#1.dclox dcpct = 20 4._at : 0.dneo#0.dclox dcpct = 30 0.dneo#1.dclox dcpct = 30 1.dneo#0.dclox dcpct = 30 1.dneo#1.dclox dcpct = 30 5._at : 0.dneo#0.dclox dcpct = 40 0.dneo#1.dclox dcpct = 40 1.dneo#0.dclox dcpct = 40 1.dneo#1.dclox dcpct = 40 6._at : 0.dneo#0.dclox dcpct = 50 0.dneo#1.dclox dcpct = 50 1.dneo#0.dclox dcpct = 50 1.dneo#1.dclox dcpct = 50 7._at : 0.dneo#0.dclox dcpct = 60 0.dneo#1.dclox dcpct = 60 1.dneo#0.dclox dcpct = 60 1.dneo#1.dclox dcpct = 60 8._at : 0.dneo#0.dclox dcpct = 70 0.dneo#1.dclox dcpct = 70 1.dneo#0.dclox dcpct = 70 1.dneo#1.dclox dcpct = 70 9._at : 0.dneo#0.dclox dcpct = 80 0.dneo#1.dclox dcpct = 80 1.dneo#0.dclox dcpct = 80 1.dneo#1.dclox dcpct = 80 10._at : 0.dneo#0.dclox dcpct = 90 0.dneo#1.dclox dcpct = 90 1.dneo#0.dclox dcpct = 90 1.dneo#1.dclox dcpct = 90 11._at : 0.dneo#0.dclox dcpct = 100 0.dneo#1.dclox dcpct = 100 1.dneo#0.dclox dcpct = 100 1.dneo#1.dclox dcpct = 100 -------------------------------------------------------------------------------- | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] ---------------+---------------------------------------------------------------- _at#dneo#dclox | 1#no#no | .0481415 .0353873 1.36 0.174 -.0212164 .1174994 1#no#yes | .012167 .0113038 1.08 0.282 -.009988 .0343219 1#yes#no | .3161096 .1294329 2.44 0.015 .0624258 .5697934 1#yes#yes | .1011761 .0737216 1.37 0.170 -.0433155 .2456678 2#no#no | .0596594 .0405034 1.47 0.141 -.0197257 .1390445 2#no#yes | .0152155 .013322 1.14 0.253 -.0108951 .0413261 2#yes#no | .3670192 .1249476 2.94 0.003 .1221264 .6119119 2#yes#yes | .1237333 .0817875 1.51 0.130 -.0365673 .2840339 3#no#no | .0737197 .0461358 1.60 0.110 -.0167049 .1641442 3#no#yes | .0190132 .0156799 1.21 0.225 -.0117188 .0497453 3#yes#no | .4210795 .1170109 3.60 0.000 .1917423 .6504167 3#yes#yes | .1504777 .0895928 1.68 0.093 -.0251211 .3260764 4#no#no | .0907736 .0523318 1.73 0.083 -.0117949 .1933422 4#no#yes | .023736 .018441 1.29 0.198 -.0124077 .0598796 4#yes#no | .4771007 .1063919 4.48 0.000 .2685765 .685625 4#yes#yes | .1818033 .096825 1.88 0.060 -.0079701 .3715768 5#no#no | .1112988 .0591756 1.88 0.060 -.0046833 .2272809 5#no#yes | .0295964 .021688 1.36 0.172 -.0129112 .0721041 5#yes#no | .5337041 .0943284 5.66 0.000 .3488238 .7185845 5#yes#yes | .217977 .1032015 2.11 0.035 .0157058 .4202482 6#no#no | .1357719 .0668047 2.03 0.042 .0048371 .2667067 6#no#yes | .0368492 .0255313 1.44 0.149 -.0131913 .0868897 6#yes#no | .5894528 .0823497 7.16 0.000 .4280503 .7508553 6#yes#yes | .2590692 .1085332 2.39 0.017 .0463479 .4717904 7#no#no | .1646295 .0754133 2.18 0.029 .0168222 .3124368 7#no#yes | .0457954 .0301193 1.52 0.128 -.0132372 .1048281 7#yes#no | .6429948 .0719559 8.94 0.000 .5019639 .7840257 7#yes#yes | .3048877 .1127812 2.70 0.007 .0838407 .5259347 8#no#no | .1982139 .0852247 2.33 0.020 .0311765 .3652512 8#no#yes | .0567856 .0356488 1.59 0.111 -.0130848 .126656 8#yes#no | .6931886 .0641743 10.80 0.000 .5674091 .818968 8#yes#yes | .3549279 .1160734 3.06 0.002 .1274283 .5824275 9#no#no | .2367081 .0964184 2.46 0.014 .0477315 .4256847 9#no#yes | .0702191 .0423739 1.66 0.097 -.0128323 .1532704 9#yes#no | .7391878 .059162 12.49 0.000 .6232324 .8551431 9#yes#yes | .4083562 .1186504 3.44 0.001 .1758057 .6409068 10#no#no | .2800668 .1090148 2.57 0.010 .0664017 .4937319 10#no#yes | .0865389 .0506051 1.71 0.087 -.0126453 .1857232 10#yes#no | .7804745 .0562082 13.89 0.000 .6703084 .8906406 10#yes#yes | .4640416 .1207365 3.84 0.000 .2274024 .7006808 11#no#no | .3279552 .1227526 2.67 0.008 .0873646 .5685459 11#no#yes | .1062184 .0606939 1.75 0.080 -.0127395 .2251763 11#yes#no | .8168449 .0542339 15.06 0.000 .7105483 .9231415 11#yes#yes | .5206383 .1223902 4.25 0.000 .280758 .7605186 -------------------------------------------------------------------------------- . di (.0481415*22+.012167*12+.3161096*59+.1011761*15)/108 /* dcpct=0, weighted at probability scale */ .19790023