. do "C:\Users\DEFAUL~1.SID\AppData\Local\Temp\STD00000000.tmp"

. * do-file for lecture 3a (part) of VHM 802/812, Winter 2014
. 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 = 1574

+
F( 6, 1567) = 15.11
Model | 228992.526 6 38165.421 Prob > F = 0.0000
Residual | 3959098.03 1567 2526.54629 R-squared = 0.0547

+
Adj R-squared = 0.0511
Total | 4188090.56 1573 2662.48605 Root MSE = 50.265

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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% Con f. 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 = 1536

+
F( 1, 1534) = 1.50
Model | 3998.19335 1 3998.19335 Prob > F = 0.2215
Residual | 4100366.46 1534 2672.98987 R-squared = 0.0010

+
Adj R-squared = 0.0003
Total | 4104364.66 1535 2673.8532 Root MSE = 51.701

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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% Con f. 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 1536
25% 2731.95 1467 Sum of Wgt. 1536

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 = 1536

+
F( 2, 1533) = 2.84
Model | 15168.437 2 7584.21849 Prob > F = 0.0585
Residual | 4089196.22 1533 2667.44698 R-squared = 0.0037

+
Adj R-squared = 0.0024
Total | 4104364.66 1535 2673.8532 Root MSE = 51.647

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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% Con f. 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 = 1536

+
F( 1, 1534) = 2.51
Model | 1.45963987 1 1.45963987 Prob > F = 0.1130
Residual | 890.377121 1534 .580428371 R-squared = 0.0016

+
Adj R-squared = 0.0010
Total | 891.836761 1535 .581001147 Root MSE = .76186

+

--------

lnwpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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 = 1536
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% Con f. 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 = 1574

+
F( 2, 1571) = 4.65
Model | 24663.1482 2 12331.5741 Prob > F = 0.0097
Residual | 4163427.41 1571 2650.17658 R-squared = 0.0059

+
Adj R-squared = 0.0046
Total | 4188090.56 1573 2662.48605 Root MSE = 51.48

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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% Con f. Interval]

+

--------

(1) | 78.06962 4.310854 18.11 0.000 69.61398 86.52525

+

--------

. margins rp vag_disch, asbalanced

Adjusted predictions Number of obs = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

at : rp (asbalanced)

vag_disch (asbalanced)

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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% Con f. 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 = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

over : vag_disch

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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

+

--------

. 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% Con f. 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 = 1574

+
F( 3, 1570) = 4.53
Model | 35915.9774 3 11971.9925 Prob > F = 0.0036
Residual | 4152174.58 1570 2644.69719 R-squared = 0.0086

+
Adj R-squared = 0.0067
Total | 4188090.56 1573 2662.48605 Root MSE = 51.427

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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

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 = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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% Con f. Interval]

+

--------

(1) | 75.40936 4.495364 16.77 0.000 66.59181 84.22691

+

--------

. margins rp, asbalanced

Adjusted predictions Number of obs = 1574
Model VCE : OLS

Expression : Linear prediction, predict()

at : rp (asbalanced)

vag_disch (asbalanced)

+

--------

| Delta-method
| Margin Std. Err. t P>|t| [95% Con f. 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% Con f. 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 = 1536

+
F( 2, 1533) = 1.01
Model | 5380.7883 2 2690.39415 Prob > F = 0.3658
Residual | 4098983.87 1533 2673.83162 R-squared = 0.0013

+
Adj R-squared = 0.0000
Total | 4104364.66 1535 2673.8532 Root MSE = 51.709

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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% Con f. Interval]

+

--------

(1) | 72.78314 5.397173 13.49 0.000 62.19652 83.36977

+

--------

. margin dyst, atmeans

Adjusted predictions Number of obs = 1536
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% Con f. 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% Con f. 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 = 1536

+
F( 3, 1532) = 3.83
Model | 30572.8757 3 10190.9586 Prob > F = 0.0095
Residual | 4073791.78 1532 2659.13302 R-squared = 0.0074

+
Adj R-squared = 0.0055
Total | 4104364.66 1535 2673.8532 Root MSE = 51.567

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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

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% Con f. 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 = 1536

+
F( 2, 1533) = 3.18
Model | 16982.1525 2 8491.07626 Prob > F = 0.0417
Residual | 4087382.5 1533 2666.26386 R-squared = 0.0041

+
Adj R-squared = 0.0028
Total | 4104364.66 1535 2673.8532 Root MSE = 51.636

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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 = 1536
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% Con f. 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 = 1536
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% Con f. 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% Con f. Interval]

+

--------

(1) | 75.56523 4.118946 18.35 0.000 67.48587 83.6446

+

--------

. margins, atmeans

Adjusted predictions Number of obs = 1536
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% Con f. 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% Con f. 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 = 1536

+
F( 3, 1532) = 2.26
Model | 18084.1915 3 6028.06382 Prob > F = 0.0797
Residual | 4086280.46 1532 2667.2849 R-squared = 0.0044

+
Adj R-squared = 0.0025
Total | 4104364.66 1535 2673.8532 Root MSE = 51.646

+

--------

wpc | Coef. Std. Err. t P>|t| [95% Con f. 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 = 1536
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% Con f. 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+c.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% Con f. 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 = 1574

+
F( 9, 1564) = 16.19
Model | 1133.93223 9 125.99247 Prob > F = 0.0000
Residual | 12172.3346 1564 7.78282264 R-squared = 0.0852

+
Adj R-squared = 0.0800
Total | 13306.2668 1573 8.45916519 Root MSE = 2.7898

+

--------

rootwpc | Coef. Std. Err. t P>|t| [95% Con f. 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.rp+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% Con f. 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 = 1574
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% Con f. 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) exp(predict(xb)^2)

Predictive margins Number of obs = 1574
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% Con f. 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

+

. sum herd_size

Variable | Obs Mean Std. Dev. Min Max

+

herd_size | 1574 251.0076 62.01692 125 333

. table aut_calv

+

aut_calv | Freq.

+

0 | 831
1 | 743

+

. table twin

+

Twins |
born | Freq.

+

no | 1,547
yes | 27

+

. table herd_size

+

Herd size | Freq.

+

125 | 129
185 | 168
201 | 203
235 | 227
263 | 253
294 | 272
333 | 322

+

. *2) 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 vag_disch=0)

Adjusted predictions Number of obs = 1574
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% Con f. 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

+

--------

. margins , at(parity=1 aut_calv=0 herd_size=(125 185 201 235 263 294 333) twin=0 rp=0 dyst=0 vag_disch=0) exp(predict(xb)^2)

Adjusted predictions Number of obs = 1574
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% Con f. 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

.
end of do-file

. exit, clear