------------------------------------------------------------------------------------------------------------------------------------------- name: log: C:\vhm812-data\l2a_mdl_build_I.txt log type: text opened on: 11 Jan 2023, 10:34:13 . set more off . . * open the DAISY dataset . use daisy2red.dta, clear . . **# INDICATOR VARIABLES . * parity as indicator variable . * regress -milk120- on parity . reg milk120 i.parity Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(6, 1529) = 83.50 Model | 184637128 6 30772854.7 Prob > F = 0.0000 Residual | 563503064 1,529 368543.534 R-squared = 0.2468 -------------+---------------------------------- Adj R-squared = 0.2438 Total | 748140192 1,535 487387.748 Root MSE = 607.08 ------------------------------------------------------------------------------ milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- parity | 2 | 708.2134 43.74086 16.19 0.000 622.4149 794.0118 3 | 789.8435 45.94638 17.19 0.000 699.7189 879.9681 4 | 848.5137 50.96418 16.65 0.000 748.5467 948.4808 5 | 787.6091 56.22915 14.01 0.000 677.3147 897.9035 6 | 878.1606 79.09305 11.10 0.000 723.0183 1033.303 7 | 925.9548 305.0416 3.04 0.002 327.6106 1524.299 | _cons | 2639.645 30.2407 87.29 0.000 2580.328 2698.963 ------------------------------------------------------------------------------ . * testing a group of categorical predictors . testparm i.parity ( 1) 2.parity = 0 ( 2) 3.parity = 0 ( 3) 4.parity = 0 ( 4) 5.parity = 0 ( 5) 6.parity = 0 ( 6) 7.parity = 0 F( 6, 1529) = 83.50 Prob > F = 0.0000 . . * determine the average milk120 in each age group . format milk120 %4.2f . tab parity, sum(milk120) | Summary of Milk volume (l) in first Lactation | 120 days of lactation number | Mean Std. dev. Freq. ------------+------------------------------------ 1 | 2639.65 486.40 403 2 | 3347.86 626.47 369 3 | 3429.49 655.11 308 4 | 3488.16 656.41 219 5 | 3427.25 692.78 164 6 | 3517.81 542.56 69 7 | 3565.60 103.82 4 ------------+------------------------------------ Total | 3215.10 698.13 1,536 . . . **# SCALING X VARIABLES . * substract min value . reg milk120 parity Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 262.27 Model | 109234227 1 109234227 Prob > F = 0.0000 Residual | 638905966 1,534 416496.718 R-squared = 0.1460 -------------+---------------------------------- Adj R-squared = 0.1455 Total | 748140192 1,535 487387.748 Root MSE = 645.37 ------------------------------------------------------------------------------ milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- parity | 178.347 11.01266 16.19 0.000 156.7455 199.9484 _cons | 2727.08 34.33991 79.41 0.000 2659.722 2794.438 ------------------------------------------------------------------------------ . gen parity_1=parity-1 . reg milk120 parity_1 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 262.27 Model | 109234227 1 109234227 Prob > F = 0.0000 Residual | 638905966 1,534 416496.718 R-squared = 0.1460 -------------+---------------------------------- Adj R-squared = 0.1455 Total | 748140192 1,535 487387.748 Root MSE = 645.37 ------------------------------------------------------------------------------ milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- parity_1 | 178.347 11.01266 16.19 0.000 156.7455 199.9484 _cons | 2905.427 25.23474 115.14 0.000 2855.928 2954.925 ------------------------------------------------------------------------------ . . * centring . reg milk120 c.herd_size##c.herd_size, vsquish Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(2, 1533) = 111.15 Model | 94747175.1 2 47373587.5 Prob > F = 0.0000 Residual | 653393017 1,533 426218.537 R-squared = 0.1266 -------------+---------------------------------- Adj R-squared = 0.1255 Total | 748140192 1,535 487387.748 Root MSE = 652.85 ----------------------------------------------------------------------------------------- milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- herd_size | 28.73126 1.993023 14.42 0.000 24.82192 32.6406 c.herd_size#c.herd_size | -.0608255 .0041101 -14.80 0.000 -.0688875 -.0527634 _cons | 66.06488 231.8877 0.28 0.776 -388.7858 520.9155 ----------------------------------------------------------------------------------------- . estat vce, corr Correlation matrix of coefficients of regress model | c.herd~e# e(V) | herd_s~e c.herd~e _cons -------------+------------------------------ herd_size | 1.0000 c.herd_size#| c.herd_size | -0.9907 1.0000 _cons | -0.9844 0.9535 1.0000 . . summ herd_size Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- herd_size | 1,574 251.0076 62.01692 125 333 . gen hrdsz_ctr=herd_size - 235 . reg milk120 c.hrdsz_ctr##c.hrdsz_ctr, vsquish Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(2, 1533) = 111.15 Model | 94747175.1 2 47373587.5 Prob > F = 0.0000 Residual | 653393017 1,533 426218.537 R-squared = 0.1266 -------------+---------------------------------- Adj R-squared = 0.1255 Total | 748140192 1,535 487387.748 Root MSE = 652.85 ----------------------------------------------------------------------------------------- milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- hrdsz_ctr | .1432984 .273907 0.52 0.601 -.3939736 .6805705 c.hrdsz_ctr#c.hrdsz_ctr | -.0608255 .0041101 -14.80 0.000 -.0688875 -.0527634 _cons | 3458.826 23.45567 147.46 0.000 3412.817 3504.834 ----------------------------------------------------------------------------------------- . estat vce, corr Correlation matrix of coefficients of regress model | c.hrds~r# e(V) | hrdsz_~r c.hrds~r _cons -------------+------------------------------ hrdsz_ctr | 1.0000 c.hrdsz_ctr#| c.hrdsz_ctr | -0.1564 1.0000 _cons | -0.0750 -0.6797 1.0000 . . * scale of measurement . reg milk120 herd_size Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 2.88 Model | 1400932.73 1 1400932.73 Prob > F = 0.0900 Residual | 746739260 1,534 486792.216 R-squared = 0.0019 -------------+---------------------------------- Adj R-squared = 0.0012 Total | 748140192 1,535 487387.748 Root MSE = 697.7 ------------------------------------------------------------------------------ milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- herd_size | -.49048 .2891242 -1.70 0.090 -1.057601 .0766405 _cons | 3338.164 74.69789 44.69 0.000 3191.643 3484.685 ------------------------------------------------------------------------------ . gen herdsz_100=herd_size/100 /*rescale herd_size so coef are larger*/ . reg milk120 herdsz_100 Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(1, 1534) = 2.88 Model | 1400930.12 1 1400930.12 Prob > F = 0.0900 Residual | 746739262 1,534 486792.218 R-squared = 0.0019 -------------+---------------------------------- Adj R-squared = 0.0012 Total | 748140192 1,535 487387.748 Root MSE = 697.7 ------------------------------------------------------------------------------ milk120 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- herdsz_100 | -49.04796 28.91242 -1.70 0.090 -105.76 7.664098 _cons | 3338.164 74.69789 44.69 0.000 3191.643 3484.685 ------------------------------------------------------------------------------ . . **# DETECTING CONFOUNDING . reg wpc i.vag_disch /* vag_disch adds ~12 days, P=0.04 */ Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(1, 1572) = 4.21 Model | 11186.2576 1 11186.2576 Prob > F = 0.0404 Residual | 4176904.3 1,572 2657.0638 R-squared = 0.0027 -------------+---------------------------------- Adj R-squared = 0.0020 Total | 4188090.56 1,573 2662.48605 Root MSE = 51.547 ------------------------------------------------------------------------------ wpc | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- vag_disch | yes | 11.99647 5.846716 2.05 0.040 .5282858 23.46465 _cons | 68.17426 1.334494 51.09 0.000 65.55669 70.79184 ------------------------------------------------------------------------------ . reg wpc i.herd if vag_disch==0 Source | SS df MS Number of obs = 1,492 -------------+---------------------------------- F(6, 1485) = 14.92 Model | 223706.812 6 37284.4686 Prob > F = 0.0000 Residual | 3711781.88 1,485 2499.51642 R-squared = 0.0568 -------------+---------------------------------- Adj R-squared = 0.0530 Total | 3935488.69 1,491 2639.4961 Root MSE = 49.995 ------------------------------------------------------------------------------ wpc | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- herd | 2 | -7.455598 4.572715 -1.63 0.103 -16.42527 1.51407 3 | 12.30396 4.184586 2.94 0.003 4.095636 20.51229 4 | -20.0733 4.70619 -4.27 0.000 -29.30479 -10.84181 5 | -21.78125 5.489853 -3.97 0.000 -32.54994 -11.01256 106 | -15.40129 4.618509 -3.33 0.001 -24.46079 -6.341796 119 | -17.26021 5.05679 -3.41 0.001 -27.17942 -7.341 | _cons | 75.1583 3.106548 24.19 0.000 69.06461 81.25199 ------------------------------------------------------------------------------ . testparm i.herd /* herd is sig. associated with wpc*/ ( 1) 2.herd = 0 ( 2) 3.herd = 0 ( 3) 4.herd = 0 ( 4) 5.herd = 0 ( 5) 106.herd = 0 ( 6) 119.herd = 0 F( 6, 1485) = 14.92 Prob > F = 0.0000 . tab herd vag_disch, chi row /* herd is associated with vag_disc*/ +----------------+ | Key | |----------------| | frequency | | row percentage | +----------------+ | Vaginal discharge Herd | observed Number | no yes | Total -----------+----------------------+---------- 1 | 259 13 | 272 | 95.22 4.78 | 100.00 -----------+----------------------+---------- 2 | 222 5 | 227 | 97.80 2.20 | 100.00 -----------+----------------------+---------- 3 | 318 4 | 322 | 98.76 1.24 | 100.00 -----------+----------------------+---------- 4 | 200 3 | 203 | 98.52 1.48 | 100.00 -----------+----------------------+---------- 5 | 122 7 | 129 | 94.57 5.43 | 100.00 -----------+----------------------+---------- 106 | 214 39 | 253 | 84.58 15.42 | 100.00 -----------+----------------------+---------- 119 | 157 11 | 168 | 93.45 6.55 | 100.00 -----------+----------------------+---------- Total | 1,492 82 | 1,574 | 94.79 5.21 | 100.00 Pearson chi2(6) = 74.2267 Pr = 0.000 . reg wpc i.vag_disch i.herd Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(7, 1566) = 14.35 Model | 252509.59 7 36072.7985 Prob > F = 0.0000 Residual | 3935580.97 1,566 2513.14238 R-squared = 0.0603 -------------+---------------------------------- Adj R-squared = 0.0561 Total | 4188090.56 1,573 2662.48605 Root MSE = 50.131 ------------------------------------------------------------------------------ wpc | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- vag_disch | yes | 17.81936 5.825177 3.06 0.002 6.393393 29.24533 | herd | 2 | -8.178615 4.509228 -1.81 0.070 -17.02338 .6661455 3 | 11.71303 4.133611 2.83 0.005 3.605039 19.82103 4 | -20.74627 4.653654 -4.46 0.000 -29.87432 -11.61823 5 | -22.15954 5.359351 -4.13 0.000 -32.6718 -11.64728 106 | -18.18881 4.422295 -4.11 0.000 -26.86305 -9.514562 119 | -17.85657 4.920293 -3.63 0.000 -27.50763 -8.205518 | _cons | 75.97555 3.052377 24.89 0.000 69.98837 81.96272 ------------------------------------------------------------------------------ . di "% change =" ((11.99-17.82)/11.99)*100 " -> vag_disch change by ~49% , herd is a confounder" % change =-48.623853 -> vag_disch change by ~49% , herd is a confounder . . **# CONFOUNDING AND COLLINEARITY . use bw5k.dta, clear . corr cig_2 cig_3 /*considering only cig_2 for the example*/ (obs=5,000) | cig_2 cig_3 -------------+------------------ cig_2 | 1.0000 cig_3 | 0.9451 1.0000 . . * Model for cig_3 as exposure of interest . * 1) relationship Z->E . corr cig_3 cig_2 (obs=5,000) | cig_3 cig_2 -------------+------------------ cig_3 | 1.0000 cig_2 | 0.9451 1.0000 . * 2) relationship Z-Y in E- . reg bwt cig_2 if cig_3==0 /*borderline sig* but not the best model*/ Source | SS df MS Number of obs = 4,656 -------------+---------------------------------- F(1, 4654) = 2.77 Model | 879610.363 1 879610.363 Prob > F = 0.0960 Residual | 1.4771e+09 4,654 317380.896 R-squared = 0.0006 -------------+---------------------------------- Adj R-squared = 0.0004 Total | 1.4780e+09 4,655 317501.676 Root MSE = 563.37 ------------------------------------------------------------------------------ bwt | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- cig_2 | -22.32463 13.41002 -1.66 0.096 -48.61462 3.965367 _cons | 3310.075 8.263501 400.57 0.000 3293.874 3326.275 ------------------------------------------------------------------------------ . * 3) not an int. variable . * 4) change in coef. . reg bwt cig_3 Source | SS df MS Number of obs = 5,000 -------------+---------------------------------- F(1, 4998) = 22.55 Model | 7189497.98 1 7189497.98 Prob > F = 0.0000 Residual | 1.5935e+09 4,998 318835.965 R-squared = 0.0045 -------------+---------------------------------- Adj R-squared = 0.0043 Total | 1.6007e+09 4,999 320210.372 Root MSE = 564.66 ------------------------------------------------------------------------------ bwt | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- cig_3 | -12.48752 2.629726 -4.75 0.000 -17.64293 -7.332101 _cons | 3303.448 8.177729 403.96 0.000 3287.416 3319.48 ------------------------------------------------------------------------------ . reg bwt cig_3 cig_2 Source | SS df MS Number of obs = 5,000 -------------+---------------------------------- F(2, 4997) = 12.61 Model | 8037757.94 2 4018878.97 Prob > F = 0.0000 Residual | 1.5927e+09 4,997 318730.017 R-squared = 0.0050 -------------+---------------------------------- Adj R-squared = 0.0046 Total | 1.6007e+09 4,999 320210.372 Root MSE = 564.56 ------------------------------------------------------------------------------ bwt | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- cig_3 | -.0859205 8.043799 -0.01 0.991 -15.8553 15.68346 cig_2 | -12.11372 7.425483 -1.63 0.103 -26.67093 2.44348 _cons | 3304.134 8.187191 403.57 0.000 3288.084 3320.185 ------------------------------------------------------------------------------ . di "%change = " ((12.49-0.09)/12.49)*100 %change = 99.279424 . estat vce, corr /*high correlation*/ Correlation matrix of coefficients of regress model e(V) | cig_3 cig_2 _cons -------------+------------------------------ cig_3 | 1.0000 cig_2 | -0.9451 1.0000 _cons | -0.0218 -0.0514 1.0000 . * try centring . summ cig_2 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- cig_2 | 5,000 .743 3.28979 0 45 . gen cig2_ctr=cig_2-r(mean) . summ cig_3 Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- cig_3 | 5,000 .6704 3.036908 0 45 . gen cig3_ctr=cig_3-r(mean) . reg bwt cig3_ctr cig2_ctr Source | SS df MS Number of obs = 5,000 -------------+---------------------------------- F(2, 4997) = 12.61 Model | 8037757.91 2 4018878.95 Prob > F = 0.0000 Residual | 1.5927e+09 4,997 318730.017 R-squared = 0.0050 -------------+---------------------------------- Adj R-squared = 0.0046 Total | 1.6007e+09 4,999 320210.372 Root MSE = 564.56 ------------------------------------------------------------------------------ bwt | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- cig3_ctr | -.0859208 8.043799 -0.01 0.991 -15.8553 15.68346 cig2_ctr | -12.11372 7.425483 -1.63 0.103 -26.67093 2.44348 _cons | 3295.076 7.984109 412.70 0.000 3279.424 3310.728 ------------------------------------------------------------------------------ . estat vce, corr Correlation matrix of coefficients of regress model e(V) | cig3_ctr cig2_ctr _cons -------------+------------------------------ cig3_ctr | 1.0000 cig2_ctr | -0.9451 1.0000 _cons | 0.0000 -0.0000 1.0000 . /*still high correlation since centring will not reduce correlation > on derived variables*/ . . **# DETECTING INTERACTION . * Interaction plots are made using margins command (explained later) . * 2 dichotomous variables . use daisy2red, clear . gen parity_1=parity-1 . . reg wpc i.vag_disch Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(1, 1572) = 4.21 Model | 11186.2576 1 11186.2576 Prob > F = 0.0404 Residual | 4176904.3 1,572 2657.0638 R-squared = 0.0027 -------------+---------------------------------- Adj R-squared = 0.0020 Total | 4188090.56 1,573 2662.48605 Root MSE = 51.547 ------------------------------------------------------------------------------ wpc | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- vag_disch | yes | 11.99647 5.846716 2.05 0.040 .5282858 23.46465 _cons | 68.17426 1.334494 51.09 0.000 65.55669 70.79184 ------------------------------------------------------------------------------ . reg wpc i.vag_disch##i.rp //same as above 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 | Coefficient Std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- vag_disch | yes | .5429296 7.265382 0.07 0.940 -13.70794 14.7938 | rp | yes | 6.339794 4.914322 1.29 0.197 -3.299531 15.97912 | vag_disch#rp | 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 ------------------------------------------------------------------------------ . table vag_disch rp, statistic(mean wpc) -------------------------------------------------------------- | Retained placenta at calving | no yes Total ---------------------------+---------------------------------- Vaginal discharge observed | no | 67.66861 74.0084 68.17426 yes | 68.21154 100.9 80.17073 Total | 67.68842 79.42282 68.79924 -------------------------------------------------------------- . *table vag_disch rp, c(mean wpc) // Version 16 or before - display wpc means by vag_dich and rp . . * dichotomous and continuous variable . gen milk120k=milk120/1000 (38 missing values generated) . summ milk120k Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- milk120k | 1,536 3.215096 .6981316 1.1102 5.6303 . gen milk120k_ctr=milk120k-r(mean) (38 missing values generated) . reg wpc i.dyst##c.milk120k_ctr Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(3, 1532) = 3.83 Model | 30572.8752 3 10190.9584 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 | Coefficient Std. err. t P>|t| [95% conf. interval] --------------------+---------------------------------------------------------------- dyst | yes | 8.20714 5.718528 1.44 0.151 -3.00983 19.42411 milk120k_ctr | -3.446531 1.928535 -1.79 0.074 -7.229379 .3363161 | dyst#c.milk120k_ctr | yes | 29.14238 9.468101 3.08 0.002 10.57057 47.71419 | _cons | 68.75682 1.357147 50.66 0.000 66.09475 71.41888 ------------------------------------------------------------------------------------- . . * two continuous variables . reg wpc c.parity_1##c.milk120k_ctr Source | SS df MS Number of obs = 1,536 -------------+---------------------------------- F(3, 1532) = 2.26 Model | 18084.1899 3 6028.06329 Prob > F = 0.0797 Residual | 4086280.47 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 | Coefficient Std. err. t P>|t| [95% conf. interval] --------------------------+---------------------------------------------------------------- parity_1 | 2.072164 .9549532 2.17 0.030 .1990103 3.945318 milk120k_ctr | -2.542834 3.091716 -0.82 0.411 -8.607278 3.521609 | c.parity_1#c.milk120k_ctr | -.8764358 1.363504 -0.64 0.520 -3.550968 1.798096 | _cons | 65.73655 2.207989 29.77 0.000 61.40555 70.06755 ------------------------------------------------------------------------------------------- . . **# CAUSAL INTERPRETATION . use daisy2red.dta, clear . * model to evaluate effect of - rp and vag_disch . gen calv_mth=month(calv_dt) . tab calv_mth, summ(wpc) | Summary of Interval from wait | period to conception calv_mth | Mean Std. dev. Freq. ------------+------------------------------------ 1 | 77.00885 50.850533 113 2 | 60.009615 45.765017 104 3 | 69.402516 54.240687 159 4 | 60.385827 53.046258 127 5 | 63 49.882911 106 6 | 64.350365 51.665154 137 7 | 63.581818 45.047453 110 8 | 69.514019 54.277478 107 9 | 74.664773 52.827873 176 10 | 72.477011 49.332856 174 11 | 72.026846 54.231479 149 12 | 73.508929 53.222801 112 ------------+------------------------------------ Total | 68.799238 51.599283 1,574 . gen aut_calv=(calv_mth>=2 & calv_mth<=7) if !missing(calv_mth) . tab aut_calv, summ(wpc) | Summary of Interval from wait | period to conception aut_calv | Mean Std. dev. Freq. ------------+------------------------------------ 0 | 73.233454 52.236588 831 1 | 63.839838 50.451973 743 ------------+------------------------------------ Total | 68.799238 51.599283 1,574 . gen hs100_ctr=(herd_size-251)/100 . gen parity_1=parity-1 . . reg wpc c.hs100_ctr##c.hs100_ctr parity_1 i.aut_calv i.twin i.dyst i.rp##vag_disch, vsquish Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(9, 1564) = 13.22 Model | 296062.694 9 32895.8549 Prob > F = 0.0000 Residual | 3892027.86 1,564 2488.50886 R-squared = 0.0707 -------------+---------------------------------- Adj R-squared = 0.0653 Total | 4188090.56 1,573 2662.48605 Root MSE = 49.885 ----------------------------------------------------------------------------------------- wpc | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- hs100_ctr | 19.85708 2.163397 9.18 0.000 15.61361 24.10054 c.hs100_ctr#c.hs100_ctr | 11.13827 3.111145 3.58 0.000 5.035817 17.24073 parity_1 | 1.13721 .8583103 1.32 0.185 -.5463501 2.82077 1.aut_calv | -8.263839 2.537751 -3.26 0.001 -13.24159 -3.286086 twin | yes | 20.68314 9.845165 2.10 0.036 1.37203 39.99425 dyst | yes | 11.70041 5.462576 2.14 0.032 .985666 22.41516 rp | yes | 5.98687 4.811976 1.24 0.214 -3.451734 15.42547 vag_disch | yes | 1.228196 7.161395 0.17 0.864 -12.81875 15.27514 rp#vag_disch | yes#yes | 22.85194 12.51605 1.83 0.068 -1.698056 47.40194 _cons | 64.33029 2.634114 24.42 0.000 59.16352 69.49705 ----------------------------------------------------------------------------------------- . estat vce, corr Correlation matrix of coefficients of regress model | c.hs10~r# 1. 1. 1. 1. 1. 1.rp# e(V) | hs100_~r c.hs10~r parity_1 aut_calv twin dyst rp vag_di~h 1.vag_~h _cons -------------+---------------------------------------------------------------------------------------------------- hs100_ctr | 1.0000 c.hs100_ctr#| c.hs100_ctr | 0.3269 1.0000 parity_1 | -0.0415 -0.0468 1.0000 1.aut_calv | 0.0521 -0.0265 -0.0500 1.0000 1.twin | 0.0326 0.0464 -0.0666 -0.0487 1.0000 1.dyst | 0.1146 0.0717 0.1303 0.0023 -0.0214 1.0000 1.rp | 0.0230 0.0540 0.0318 0.0438 -0.0807 -0.0656 1.0000 1.vag_disch | 0.0304 0.0698 0.0649 0.0387 -0.0383 -0.1188 0.0742 1.0000 1.rp#| 1.vag_disch | -0.0184 -0.0571 -0.0644 -0.0024 -0.0429 0.0861 -0.3873 -0.5752 1.0000 _cons | -0.1716 -0.4415 -0.5404 -0.4246 0.0004 -0.2091 -0.1974 -0.1711 0.1133 1.0000 . *Plot to show herd size effect . margins i.rp, at(hs100_ctr=(-1.26 -0.66 -0.5 -0.16 0.12 0.43 0.82) vag_disch=0 twin=0 aut_calv=1) Predictive margins Number of obs = 1,574 Model VCE: OLS Expression: Linear prediction, predict() 1._at: hs100_ctr = -1.26 aut_calv = 1 twin = 0 vag_disch = 0 2._at: hs100_ctr = -.66 aut_calv = 1 twin = 0 vag_disch = 0 3._at: hs100_ctr = -.5 aut_calv = 1 twin = 0 vag_disch = 0 4._at: hs100_ctr = -.16 aut_calv = 1 twin = 0 vag_disch = 0 5._at: hs100_ctr = .12 aut_calv = 1 twin = 0 vag_disch = 0 6._at: hs100_ctr = .43 aut_calv = 1 twin = 0 vag_disch = 0 7._at: hs100_ctr = .82 aut_calv = 1 twin = 0 vag_disch = 0 ------------------------------------------------------------------------------ | Delta-method | Margin std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- _at#rp | 1#no | 51.39576 4.180262 12.29 0.000 43.19625 59.59527 1#yes | 57.38263 6.237479 9.20 0.000 45.14793 69.61733 2#no | 50.47872 2.305235 21.90 0.000 45.95704 55.0004 2#yes | 56.46559 5.01705 11.25 0.000 46.62474 66.30644 3#no | 51.58859 2.272504 22.70 0.000 47.13111 56.04607 3#yes | 57.57546 4.979714 11.56 0.000 47.80784 67.34308 4#no | 55.84057 2.30714 24.20 0.000 51.31516 60.36598 4#yes | 61.82744 4.975563 12.43 0.000 52.06796 71.58692 5#no | 61.2758 2.227931 27.50 0.000 56.90576 65.64585 5#yes | 67.26267 4.951058 13.59 0.000 57.55126 76.97408 6#no | 69.33057 2.148771 32.27 0.000 65.1158 73.54535 6#yes | 75.31744 4.958886 15.19 0.000 65.59068 85.04421 7#no | 82.50474 2.92719 28.19 0.000 76.76311 88.24637 7#yes | 88.49161 5.432912 16.29 0.000 77.83505 99.14817 ------------------------------------------------------------------------------ . marginsplot, noci xlabel(-1.26 "125" -0.66 "185" -0.5 "201" -0.16 "235" 0.12 "263" 0.43 "294" 0.82 "333") xtitle("Herd Size") ytitle("Day > s") title("Preditive WPC by RP") Variables that uniquely identify margins: hs100_ctr rp . * dyst conf for rp . reg wpc c.hs100_ctr##c.hs100_ctr parity_1 i.aut_calv i.twin i.rp Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(6, 1567) = 18.07 Model | 270961.965 6 45160.3275 Prob > F = 0.0000 Residual | 3917128.59 1,567 2499.76298 R-squared = 0.0647 -------------+---------------------------------- Adj R-squared = 0.0611 Total | 4188090.56 1,573 2662.48605 Root MSE = 49.998 ----------------------------------------------------------------------------------------- wpc | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- hs100_ctr | 19.30362 2.151847 8.97 0.000 15.08282 23.52442 | c.hs100_ctr#c.hs100_ctr | 10.71722 3.099622 3.46 0.001 4.637371 16.79706 | parity_1 | .9394592 .8495005 1.11 0.269 -.7268183 2.605737 1.aut_calv | -8.459953 2.540778 -3.33 0.001 -13.44364 -3.476272 | twin | yes | 23.09719 9.826032 2.35 0.019 3.823631 42.37074 | rp | yes | 11.18504 4.35328 2.57 0.010 2.646174 19.72391 _cons | 65.59166 2.527849 25.95 0.000 60.63333 70.54998 ----------------------------------------------------------------------------------------- . reg wpc c.hs100_ctr##c.hs100_ctr parity_1 i.aut_calv i.twin i.rp i.dyst Source | SS df MS Number of obs = 1,574 -------------+---------------------------------- F(7, 1566) = 16.16 Model | 282216.68 7 40316.6686 Prob > F = 0.0000 Residual | 3905873.88 1,566 2494.17234 R-squared = 0.0674 -------------+---------------------------------- Adj R-squared = 0.0632 Total | 4188090.56 1,573 2662.48605 Root MSE = 49.942 ----------------------------------------------------------------------------------------- wpc | Coefficient Std. err. t P>|t| [95% conf. interval] ------------------------+---------------------------------------------------------------- hs100_ctr | 19.85139 2.164852 9.17 0.000 15.60508 24.09771 | c.hs100_ctr#c.hs100_ctr | 11.25323 3.106419 3.62 0.000 5.160046 17.34641 | parity_1 | 1.194524 .8570034 1.39 0.164 -.4864712 2.875519 1.aut_calv | -8.425575 2.537986 -3.32 0.001 -13.40378 -3.447365 | twin | yes | 22.58687 9.817977 2.30 0.022 3.329101 41.84463 | rp | yes | 10.69412 4.354546 2.46 0.014 2.152766 19.23548 | dyst | yes | 11.53206 5.428789 2.12 0.034 .8836016 22.18052 _cons | 64.29463 2.597795 24.75 0.000 59.19911 69.39015 ----------------------------------------------------------------------------------------- . . log close name: log: C:\vhm812-data\l2a_mdl_build_I.txt log type: text closed on: 11 Jan 2023, 10:34:15 -------------------------------------------------------------------------------------------------------------------------------------------