This page contains an output log for analysis. Please contact Sam Rowe (samrowe101@gmail.com) if you have questions. Analysis was conducted using R and STATA.
library(broom)
library(dplyr)
load(file="SDCTQTR.Rdata")
load(file="Baseline.Rdata")
head(Baseline, n=10) %>% kable()
FARMID | CowID | QTR | Tx | Spectramast | Age | Parity | IMIDO | DOSCC | DOMY | DODIM | PrevCM | PrevSCCHI | DPlength | PCSampDIM |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6 | 6 | LF | 2 | y | 36.08553 | 1 | 0 | 3.988984 | 32.65862 | 316 | 0 | 5.924256 | 55 | 6 |
6 | 6 | LR | 2 | y | 36.08553 | 1 | 0 | 3.988984 | 32.65862 | 316 | 0 | 5.924256 | 55 | 6 |
6 | 6 | RF | 2 | y | 36.08553 | 1 | 1 | 3.988984 | 32.65862 | 316 | 0 | 5.924256 | 55 | 6 |
6 | 6 | RR | 2 | y | 36.08553 | 1 | 0 | 3.988984 | 32.65862 | 316 | 0 | 5.924256 | 55 | 6 |
1 | 7 | LF | 2 | y | 61.05263 | 3 | 1 | 6.198479 | 34.01940 | 322 | 0 | 7.100852 | 46 | 1 |
1 | 7 | LR | 2 | y | 61.05263 | 3 | 0 | 6.198479 | 34.01940 | 322 | 0 | 7.100852 | 46 | 1 |
1 | 7 | RF | 2 | y | 61.05263 | 3 | 1 | 6.198479 | 34.01940 | 322 | 0 | 7.100852 | 46 | 1 |
1 | 7 | RR | 2 | y | 61.05263 | 3 | 0 | 6.198479 | 34.01940 | 322 | 0 | 7.100852 | 46 | 1 |
2 | 7 | LF | 0 | y | 57.82895 | 3 | 0 | 4.025352 | 30.84426 | 390 | 1 | 7.697575 | 49 | 2 |
2 | 7 | LR | 0 | y | 57.82895 | 3 | 1 | 4.025352 | 30.84426 | 390 | 1 | 7.697575 | 49 | 2 |
#summarytools::dfSummary(Baseline, style='grid')
print(summarytools::dfSummary(Baseline, valid.col=FALSE,graph.magnif=0.5,varnumbers=F,style="grid"))
## Data Frame Summary
##
## Dimensions: 4704 x 15
## Duplicates: 0
##
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | Variable | Stats / Values | Freqs (% of Valid) | Graph | Missing |
## +==============+============================+======================+============================+=========+
## | FARMID | Mean (sd) : 4 (1.5) | 1 : 296 ( 6.3%) | I | 0 |
## | [numeric] | min < med < max: | 2 : 324 ( 6.9%) | I | (0%) |
## | | 1 < 4 < 7 | 3 : 1044 (22.2%) | IIII | |
## | | IQR (CV) : 2 (0.4) | 4 : 1452 (30.9%) | IIIIII | |
## | | | 5 : 948 (20.2%) | IIII | |
## | | | 6 : 188 ( 4.0%) | | |
## | | | 7 : 452 ( 9.6%) | I | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | CowID | Mean (sd) : 4575.5 (3181) | 1116 distinct values | : | 0 |
## | [numeric] | min < med < max: | | : : : | (0%) |
## | | 6 < 4298 < 23096 | | : : : | |
## | | IQR (CV) : 4152.5 (0.7) | | : : : | |
## | | | | : : : : . . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | QTR | 1. LF | 1176 (25.0%) | IIIII | 0 |
## | [factor] | 2. LR | 1176 (25.0%) | IIIII | (0%) |
## | | 3. RF | 1176 (25.0%) | IIIII | |
## | | 4. RR | 1176 (25.0%) | IIIII | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | Tx | 1. 0 | 1568 (33.3%) | IIIIII | 0 |
## | [factor] | 2. 1 | 1592 (33.8%) | IIIIII | (0%) |
## | | 3. 2 | 1544 (32.8%) | IIIIII | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | Spectramast | 1. n | 1740 (37.0%) | IIIIIII | 0 |
## | [character] | 2. y | 2964 (63.0%) | IIIIIIIIIIII | (0%) |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | Age | Mean (sd) : 46.7 (15.2) | 663 distinct values | : | 0 |
## | [numeric] | min < med < max: | | : | (0%) |
## | | 30.4 < 44.4 < 122.3 | | : : | |
## | | IQR (CV) : 22.4 (0.3) | | : : . | |
## | | | | : : : : : . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | Parity | 1. 1 | 2008 (42.7%) | IIIIIIII | 0 |
## | [factor] | 2. 2 | 1420 (30.2%) | IIIIII | (0%) |
## | | 3. 3 | 1276 (27.1%) | IIIII | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | IMIDO | Min : 0 | 0 : 3164 (74.6%) | IIIIIIIIIIIIII | 462 |
## | [numeric] | Mean : 0.3 | 1 : 1078 (25.4%) | IIIII | (9.82%) |
## | | Max : 1 | | | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | DOSCC | Mean (sd) : 4.4 (1.2) | 395 distinct values | : | 0 |
## | [numeric] | min < med < max: | | . : : | (0%) |
## | | 1.6 < 4.3 < 8.6 | | : : : . | |
## | | IQR (CV) : 1.6 (0.3) | | : : : : : . | |
## | | | | . : : : : : : : . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | DOMY | Mean (sd) : 27.3 (8.7) | 87 distinct values | : | 0 |
## | [numeric] | min < med < max: | | : : | (0%) |
## | | 1.8 < 28.6 < 49.4 | | : : : . | |
## | | IQR (CV) : 10.9 (0.3) | | . : : : : | |
## | | | | . : : : : : : : . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | DODIM | Mean (sd) : 324.7 (45.6) | 179 distinct values | : | 0 |
## | [numeric] | min < med < max: | | : | (0%) |
## | | 252 < 305.5 < 584 | | : | |
## | | IQR (CV) : 49 (0.1) | | : . | |
## | | | | : : : . . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | PrevCM | 1. 0 | 4056 (86.2%) | IIIIIIIIIIIIIIIII | 0 |
## | [factor] | 2. 1 | 648 (13.8%) | II | (0%) |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | PrevSCCHI | Mean (sd) : 5.4 (1.3) | 611 distinct values | . : | 0 |
## | [numeric] | min < med < max: | | : : : . | (0%) |
## | | 2.9 < 5.3 < 9.2 | | : : : : : | |
## | | IQR (CV) : 1.8 (0.2) | | : : : : : : . | |
## | | | | : : : : : : : : . . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | DPlength | Mean (sd) : 55.8 (7.8) | 54 distinct values | : | 0 |
## | [numeric] | min < med < max: | | : | (0%) |
## | | 30 < 56 < 87 | | : : | |
## | | IQR (CV) : 8 (0.1) | | : : : | |
## | | | | . : : : : : . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
## | PCSampDIM | Mean (sd) : 5.8 (2.8) | 14 distinct values | : | 280 |
## | [numeric] | min < med < max: | | : : | (5.95%) |
## | | 0 < 6 < 13 | | . : . . : | |
## | | IQR (CV) : 4 (0.5) | | . : : : : : | |
## | | | | : : : : : : : : . . | |
## +--------------+----------------------------+----------------------+----------------------------+---------+
table1::table1(~ factor(FARMID) + Spectramast + Age + Parity + factor(IMIDO) + DOSCC + DOMY + DODIM + PrevCM + PrevSCCHI + DPlength + PCSampDIM | Tx, data=SDCTQTR,topclass="Rtable1-grid")
0 (n=1568) |
1 (n=1592) |
2 (n=1544) |
Overall (n=4704) |
|
---|---|---|---|---|
factor(FARMID) | ||||
1 | 112 (7.1%) | 100 (6.3%) | 84 (5.4%) | 296 (6.3%) |
2 | 108 (6.9%) | 92 (5.8%) | 124 (8.0%) | 324 (6.9%) |
3 | 368 (23.5%) | 348 (21.9%) | 328 (21.2%) | 1044 (22.2%) |
4 | 444 (28.3%) | 512 (32.2%) | 496 (32.1%) | 1452 (30.9%) |
5 | 312 (19.9%) | 332 (20.9%) | 304 (19.7%) | 948 (20.2%) |
6 | 64 (4.1%) | 64 (4.0%) | 60 (3.9%) | 188 (4.0%) |
7 | 160 (10.2%) | 144 (9.0%) | 148 (9.6%) | 452 (9.6%) |
Spectramast | ||||
y | 1568 (100%) | 708 (44.5%) | 688 (44.6%) | 2964 (63.0%) |
n | 0 (0%) | 884 (55.5%) | 856 (55.4%) | 1740 (37.0%) |
Age | ||||
Mean (SD) | 47.2 (14.6) | 46.9 (15.9) | 46.1 (15.0) | 46.7 (15.2) |
Median [Min, Max] | 44.7 [30.8, 104] | 44.1 [30.4, 111] | 44.5 [30.4, 122] | 44.4 [30.4, 122] |
Parity | ||||
1 | 616 (39.3%) | 732 (46.0%) | 660 (42.7%) | 2008 (42.7%) |
2 | 516 (32.9%) | 416 (26.1%) | 488 (31.6%) | 1420 (30.2%) |
3 | 436 (27.8%) | 444 (27.9%) | 396 (25.6%) | 1276 (27.1%) |
factor(IMIDO) | ||||
0 | 1046 (66.7%) | 1069 (67.1%) | 1049 (67.9%) | 3164 (67.3%) |
1 | 350 (22.3%) | 373 (23.4%) | 355 (23.0%) | 1078 (22.9%) |
Missing | 172 (11.0%) | 150 (9.4%) | 140 (9.1%) | 462 (9.8%) |
DOSCC | ||||
Mean (SD) | 4.45 (1.21) | 4.38 (1.23) | 4.45 (1.22) | 4.43 (1.22) |
Median [Min, Max] | 4.33 [1.61, 8.35] | 4.23 [1.61, 8.59] | 4.39 [1.61, 8.25] | 4.32 [1.61, 8.59] |
DOMY | ||||
Mean (SD) | 26.7 (8.87) | 27.9 (8.81) | 27.3 (8.38) | 27.3 (8.70) |
Median [Min, Max] | 27.7 [4.54, 49.4] | 29.0 [1.81, 49.4] | 29.0 [2.72, 49.4] | 28.6 [1.81, 49.4] |
DODIM | ||||
Mean (SD) | 323 (45.6) | 328 (46.7) | 323 (44.5) | 325 (45.6) |
Median [Min, Max] | 304 [252, 584] | 310 [258, 508] | 304 [258, 512] | 306 [252, 584] |
PrevCM | ||||
0 | 1344 (85.7%) | 1360 (85.4%) | 1352 (87.6%) | 4056 (86.2%) |
1 | 224 (14.3%) | 232 (14.6%) | 192 (12.4%) | 648 (13.8%) |
PrevSCCHI | ||||
Mean (SD) | 5.37 (1.30) | 5.49 (1.23) | 5.40 (1.29) | 5.42 (1.28) |
Median [Min, Max] | 5.23 [2.87, 9.21] | 5.37 [3.14, 9.21] | 5.30 [2.94, 9.21] | 5.30 [2.87, 9.21] |
DPlength | ||||
Mean (SD) | 55.4 (7.83) | 56.1 (7.37) | 56.0 (8.19) | 55.8 (7.80) |
Median [Min, Max] | 56.0 [33.0, 84.0] | 56.0 [33.0, 84.0] | 56.0 [30.0, 87.0] | 56.0 [30.0, 87.0] |
PCSampDIM | ||||
Mean (SD) | 5.81 (2.80) | 5.75 (2.77) | 5.75 (2.80) | 5.77 (2.79) |
Median [Min, Max] | 6.00 [0.00, 13.0] | 6.00 [0.00, 13.0] | 6.00 [0.00, 13.0] | 6.00 [0.00, 13.0] |
Missing | 84 (5.4%) | 84 (5.3%) | 112 (7.3%) | 280 (6.0%) |
table1::table1(~ Age + Parity + DOSCC + DOMY + DODIM + PrevCM + PrevSCCHI + DPlength + PCSampDIM + factor(IMIDO) + factor(IMIPC) + factor(Cure) + factor(NewIMI) | factor(FARMID), data=SDCTQTR,topclass="Rtable1-grid")
1 (n=296) |
2 (n=324) |
3 (n=1044) |
4 (n=1452) |
5 (n=948) |
6 (n=188) |
7 (n=452) |
Overall (n=4704) |
|
---|---|---|---|---|---|---|---|---|
Age | ||||||||
Mean (SD) | 48.4 (16.0) | 46.8 (14.3) | 46.8 (13.4) | 46.7 (16.1) | 46.9 (15.9) | 42.9 (11.1) | 46.6 (16.1) | 46.7 (15.2) |
Median [Min, Max] | 44.4 [30.6, 90.2] | 44.5 [30.7, 95.7] | 44.8 [30.4, 95.5] | 44.2 [31.7, 122] | 44.5 [30.4, 115] | 43.7 [31.0, 82.6] | 44.6 [31.0, 114] | 44.4 [30.4, 122] |
Parity | ||||||||
1 | 124 (41.9%) | 132 (40.7%) | 364 (34.9%) | 700 (48.2%) | 408 (43.0%) | 92 (48.9%) | 188 (41.6%) | 2008 (42.7%) |
2 | 60 (20.3%) | 108 (33.3%) | 380 (36.4%) | 376 (25.9%) | 288 (30.4%) | 68 (36.2%) | 140 (31.0%) | 1420 (30.2%) |
3 | 112 (37.8%) | 84 (25.9%) | 300 (28.7%) | 376 (25.9%) | 252 (26.6%) | 28 (14.9%) | 124 (27.4%) | 1276 (27.1%) |
DOSCC | ||||||||
Mean (SD) | 4.50 (1.00) | 4.07 (1.14) | 4.00 (0.909) | 4.48 (1.17) | 5.17 (1.39) | 4.34 (0.958) | 3.91 (1.08) | 4.43 (1.22) |
Median [Min, Max] | 4.54 [2.56, 7.59] | 3.95 [2.30, 8.17] | 3.98 [2.60, 6.68] | 4.47 [1.61, 8.59] | 5.13 [1.61, 8.35] | 4.47 [2.56, 6.61] | 3.78 [2.56, 7.38] | 4.32 [1.61, 8.59] |
DOMY | ||||||||
Mean (SD) | 22.9 (6.26) | 26.7 (9.65) | 29.5 (6.87) | 30.3 (7.72) | 19.6 (8.57) | 30.7 (4.77) | 30.6 (6.31) | 27.3 (8.70) |
Median [Min, Max] | 22.7 [9.07, 38.1] | 28.6 [2.72, 44.0] | 30.4 [8.62, 47.6] | 30.4 [2.72, 49.4] | 20.0 [1.81, 39.9] | 30.8 [16.8, 40.8] | 30.8 [15.4, 48.5] | 28.6 [1.81, 49.4] |
DODIM | ||||||||
Mean (SD) | 347 (51.7) | 334 (52.7) | 313 (37.6) | 325 (44.3) | 329 (50.6) | 328 (43.0) | 321 (39.0) | 325 (45.6) |
Median [Min, Max] | 326 [292, 584] | 304 [293, 512] | 293 [266, 475] | 296 [283, 468] | 308 [252, 512] | 314 [258, 444] | 307 [272, 476] | 306 [252, 584] |
PrevCM | ||||||||
0 | 244 (82.4%) | 320 (98.8%) | 904 (86.6%) | 1252 (86.2%) | 748 (78.9%) | 184 (97.9%) | 404 (89.4%) | 4056 (86.2%) |
1 | 52 (17.6%) | 4 (1.2%) | 140 (13.4%) | 200 (13.8%) | 200 (21.1%) | 4 (2.1%) | 48 (10.6%) | 648 (13.8%) |
PrevSCCHI | ||||||||
Mean (SD) | 5.46 (1.31) | 5.06 (1.31) | 4.77 (1.08) | 5.76 (1.20) | 6.13 (1.11) | 5.02 (0.920) | 4.73 (1.16) | 5.42 (1.28) |
Median [Min, Max] | 5.31 [3.43, 9.21] | 4.78 [3.33, 9.21] | 4.61 [2.87, 8.21] | 5.65 [3.00, 9.21] | 6.06 [3.40, 9.21] | 5.09 [3.09, 7.06] | 4.53 [2.94, 8.00] | 5.30 [2.87, 9.21] |
DPlength | ||||||||
Mean (SD) | 53.1 (11.7) | 52.6 (5.62) | 57.9 (6.38) | 56.1 (6.00) | 55.6 (8.19) | 60.3 (7.14) | 53.0 (10.6) | 55.8 (7.80) |
Median [Min, Max] | 52.0 [32.0, 85.0] | 53.0 [30.0, 63.0] | 58.0 [35.0, 87.0] | 56.0 [35.0, 74.0] | 55.0 [35.0, 85.0] | 60.0 [47.0, 84.0] | 55.0 [33.0, 77.0] | 56.0 [30.0, 87.0] |
PCSampDIM | ||||||||
Mean (SD) | 2.70 (1.84) | 2.48 (1.70) | 7.61 (2.67) | 6.31 (2.09) | 6.20 (2.14) | 4.02 (2.61) | 4.41 (2.79) | 5.77 (2.79) |
Median [Min, Max] | 2.00 [0.00, 7.00] | 2.00 [0.00, 7.00] | 8.00 [1.00, 13.0] | 6.00 [3.00, 13.0] | 6.00 [3.00, 13.0] | 4.00 [0.00, 10.0] | 5.00 [0.00, 13.0] | 6.00 [0.00, 13.0] |
Missing | 12 (4.1%) | 0 (0%) | 112 (10.7%) | 84 (5.8%) | 40 (4.2%) | 12 (6.4%) | 20 (4.4%) | 280 (6.0%) |
factor(IMIDO) | ||||||||
0 | 263 (88.9%) | 294 (90.7%) | 436 (41.8%) | 927 (63.8%) | 789 (83.2%) | 126 (67.0%) | 329 (72.8%) | 3164 (67.3%) |
1 | 29 (9.8%) | 29 (9.0%) | 255 (24.4%) | 492 (33.9%) | 136 (14.3%) | 47 (25.0%) | 90 (19.9%) | 1078 (22.9%) |
Missing | 4 (1.4%) | 1 (0.3%) | 353 (33.8%) | 33 (2.3%) | 23 (2.4%) | 15 (8.0%) | 33 (7.3%) | 462 (9.8%) |
factor(IMIPC) | ||||||||
0 | 277 (93.6%) | 308 (95.1%) | 638 (61.1%) | 839 (57.8%) | 656 (69.2%) | 147 (78.2%) | 347 (76.8%) | 3212 (68.3%) |
1 | 18 (6.1%) | 16 (4.9%) | 197 (18.9%) | 431 (29.7%) | 231 (24.4%) | 21 (11.2%) | 47 (10.4%) | 961 (20.4%) |
Missing | 1 (0.3%) | 0 (0%) | 209 (20.0%) | 182 (12.5%) | 61 (6.4%) | 20 (10.6%) | 58 (12.8%) | 531 (11.3%) |
factor(Cure) | ||||||||
0 | 1 (0.3%) | 3 (0.9%) | 21 (2.0%) | 73 (5.0%) | 14 (1.5%) | 2 (1.1%) | 3 (0.7%) | 117 (2.5%) |
1 | 28 (9.5%) | 26 (8.0%) | 176 (16.9%) | 359 (24.7%) | 114 (12.0%) | 44 (23.4%) | 71 (15.7%) | 818 (17.4%) |
Missing | 267 (90.2%) | 295 (91.0%) | 847 (81.1%) | 1020 (70.2%) | 820 (86.5%) | 142 (75.5%) | 378 (83.6%) | 3769 (80.1%) |
factor(NewIMI) | ||||||||
0 | 274 (92.6%) | 310 (95.7%) | 444 (42.5%) | 882 (60.7%) | 654 (69.0%) | 141 (75.0%) | 325 (71.9%) | 3030 (64.4%) |
1 | 17 (5.7%) | 13 (4.0%) | 107 (10.2%) | 360 (24.8%) | 213 (22.5%) | 15 (8.0%) | 39 (8.6%) | 764 (16.2%) |
Missing | 5 (1.7%) | 1 (0.3%) | 493 (47.2%) | 210 (14.5%) | 81 (8.5%) | 32 (17.0%) | 88 (19.5%) | 910 (19.3%) |
library(gmodels)
CrossTable(SDCTQTR$Tx,SDCTQTR$Cure,prop.c=FALSE,prop.t=FALSE,prop.chisq = FALSE)
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Row Total |
## |-------------------------|
##
##
## Total Observations in Table: 935
##
##
## | SDCTQTR$Cure
## SDCTQTR$Tx | 0 | 1 | Row Total |
## -------------|-----------|-----------|-----------|
## 0 | 40 | 263 | 303 |
## | 0.132 | 0.868 | 0.324 |
## -------------|-----------|-----------|-----------|
## 1 | 41 | 288 | 329 |
## | 0.125 | 0.875 | 0.352 |
## -------------|-----------|-----------|-----------|
## 2 | 36 | 267 | 303 |
## | 0.119 | 0.881 | 0.324 |
## -------------|-----------|-----------|-----------|
## Column Total | 117 | 818 | 935 |
## -------------|-----------|-----------|-----------|
##
##
Model type: Logistic regression with mixed effects (generalized linear mixed model with binomial family / logit link).
Step 1: Identify potential confouders using a directed acyclic graph (DAG)
Step 2: Identify correlated variables using pearson and kendalls correlation coefficients
Step 3: Create model with all potential confounders
Step 4: Investigate potential effect measure modification
Step 5: Remove unneccesary covariates in backwards stepwise fashion using 10% rule (i.e. if odds ratio for algorithm or culture changes by >10% after removing the covariate, the covariate is retained in the model)
Step 6: Report final model
This is used to identify variables that could be confounders if they are not balanced between treatment groups.
library(DiagrammeR)
mermaid("graph LR
T(Treatment)-->U(Cure)
A(Age)-->T
P(Parity)-->T
M(Yield at dry-off)-->T
S(SCC during prev lactation)-->T
C(CM in prev lact)-->T
D(DIM at dry off) --> T
K(DIM at post calving sample) --> T
D-->M
D-->S
D-->U
K-->U
A-->U
P-->U
M-->U
S-->U
C-->U
C-->M
P-->C
P-->S
P-->M
A-->P
A-->C
A-->S
A-->M
M-->S
C-->S
style D fill:#FFFFFF, stroke-width:0px
style K fill:#FFFFFF, stroke-width:0px
style A fill:#FFFFFF, stroke-width:0px
style T fill:#FFFFFF, stroke-width:2px
style P fill:#FFFFFF, stroke-width:0px
style M fill:#FFFFFF, stroke-width:0px
style S fill:#FFFFFF, stroke-width:0px
style C fill:#FFFFFF, stroke-width:0px
style I fill:#FFFFFF, stroke-width:0px
style U fill:#FFFFFF, stroke-width:2px
")
According to this DAG, I may need to control for the following variables.
Parity [“Parity”] or Age [“Age”] <- likely to correlated
Yield at most recent test before dry off [“DOMY”]
Somatic cell count at last herd test during previous lactation [“DOSCC” or “PrevSCCHi”] <- likely to be correlated
Clinical mastitis in previous lactation [“PrevCM”]
Days in milk at dry-off [“DODIM”]
Days in milk at post-calving sample [“PCSampDIM”]
----------------------------------------------------------------------------------------------------------------
name: <unnamed>
log: /Users/SamRowe1/Dropbox/R backup/SDCT - R/SDCT QTR LOG.smcl
log type: smcl
opened on: 2 Jul 2019, 12:21:05
. do "/var/folders/9d/jztlcdt119jcdw9bmltvxmd40000gp/T//SD17867.000000"
.
. *****************************
. * SDCT QTR outcomes
. * Sam Rowe
. * samrowe101@gmail.com
. * March 2019
. *****************************
.
. *Only marginal standardization will be conducted in Stata. All other analyses conducted in R.
. *Outcome 1: Cure
.
. *Step 3: Create full model with all potential covariates
. meglm Cure i.Tx Parity DOSCC DOMY i.PrevCM DODIM PCSampDIM || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -350.97942
Iteration 1: log likelihood = -349.4617
Iteration 2: log likelihood = -349.46025
Iteration 3: log likelihood = -349.46025
Refining starting values:
Grid node 0: log likelihood = -347.25869
Fitting full model:
Iteration 0: log likelihood = -347.25869 (not concave)
Iteration 1: log likelihood = -344.04076
Iteration 2: log likelihood = -343.72424 (backed up)
Iteration 3: log likelihood = -343.63129
Iteration 4: log likelihood = -343.53269
Iteration 5: log likelihood = -343.5297
Iteration 6: log likelihood = -343.5297
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(8) = 3.56
Log likelihood = -343.5297 Prob > chi2 = 0.8945
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0630215 .2953295 0.21 0.831 -.5158137 .6418567
2 | .1614251 .3036173 0.53 0.595 -.4336539 .7565042
|
Parity | -.0424908 .1577721 -0.27 0.788 -.3517183 .2667368
DOSCC | -.0979108 .1205049 -0.81 0.417 -.3340962 .1382745
DOMY | -.0053816 .0163535 -0.33 0.742 -.0374338 .0266707
|
PrevCM |
1 | .4836847 .3628774 1.33 0.183 -.227542 1.194911
DODIM | -.0025398 .0027663 -0.92 0.359 -.0079615 .002882
PCSampDIM | -.0267766 .05171 -0.52 0.605 -.1281264 .0745732
_cons | 4.197029 1.364847 3.08 0.002 1.521978 6.872081
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .1813986 .197816 .0213991 1.537706
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.197882 .6767427 .3958479 3.624932
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 11.86 Prob > chi2 = 0.0027
Note: LR test is conservative and provided only for reference.
.
. *Step 4: Effect measure modification
. *Will test Tx:Farm, Tx:Parity, Tx:PrevCM
.
. *Step 4a: Tx:Farm
. meglm Cure i.Tx##i.FARMID Parity DOSCC DOMY i.PrevCM DODIM PCSampDIM || CowID:, family(binomial) link(logit)
note: 1.Tx#2.FARMID != 0 predicts success perfectly
1.Tx#2.FARMID dropped and 10 obs not used
note: 1.Tx#6.FARMID != 0 predicts success perfectly
1.Tx#6.FARMID dropped and 8 obs not used
note: 2.Tx#1.FARMID != 0 predicts success perfectly
2.Tx#1.FARMID dropped and 11 obs not used
note: 2.Tx#6.FARMID != 0 predicts success perfectly
2.Tx#6.FARMID dropped and 18 obs not used
note: 2.Tx#7.FARMID != 0 predicts success perfectly
2.Tx#7.FARMID dropped and 31 obs not used
note: 3.Tx#1.FARMID != 0 predicts success perfectly
3.Tx#1.FARMID dropped and 10 obs not used
note: 3.Tx#7.FARMID != 0 predicts success perfectly
3.Tx#7.FARMID dropped and 22 obs not used
note: 2.Tx#5.FARMID omitted because of collinearity
note: 3.Tx#2.FARMID omitted because of collinearity
note: 3.Tx#5.FARMID omitted because of collinearity
note: 3.Tx#6.FARMID omitted because of collinearity
Fitting fixed-effects model:
Iteration 0: log likelihood = -332.17091
Iteration 1: log likelihood = -330.84226
Iteration 2: log likelihood = -330.83988
Iteration 3: log likelihood = -330.83988
Refining starting values:
Grid node 0: log likelihood = -332.42527
Fitting full model:
Iteration 0: log likelihood = -332.42527
Iteration 1: log likelihood = -329.44315
Iteration 2: log likelihood = -328.42039
Iteration 3: log likelihood = -328.40664
Iteration 4: log likelihood = -328.4066
Iteration 5: log likelihood = -328.4066
Mixed-effects GLM Number of obs = 824
Family: binomial
Link: logit
Group variable: CowID Number of groups = 505
Obs per group:
min = 1
avg = 1.6
max = 5
Integration method: mvaghermite Integration pts. = 7
Wald chi2(19) = 9.81
Log likelihood = -328.4066 Prob > chi2 = 0.9575
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | -.6153327 .7954483 -0.77 0.439 -2.174383 .9437174
2 | -.2061446 .8456079 -0.24 0.807 -1.863506 1.451216
|
FARMID |
2 | -.6432378 1.774609 -0.36 0.717 -4.121407 2.834931
3 | .0057473 1.385851 0.00 0.997 -2.710471 2.721966
4 | -.7228662 1.307936 -0.55 0.580 -3.286373 1.84064
5 | .2679399 1.398644 0.19 0.848 -2.473352 3.009231
6 | .131918 1.744342 0.08 0.940 -3.28693 3.550766
7 | -.3606119 1.478568 -0.24 0.807 -3.258552 2.537328
|
Tx#FARMID |
0#2 | 0 (empty)
0#6 | 0 (empty)
1#1 | 0 (empty)
1#2 | 1.377906 1.702017 0.81 0.418 -1.957987 4.713799
1#3 | .4657346 1.023289 0.46 0.649 -1.539874 2.471343
1#4 | .6913465 .8747548 0.79 0.429 -1.023141 2.405834
1#5 | 0 (omitted)
1#6 | 0 (empty)
1#7 | 0 (empty)
2#1 | 0 (empty)
2#2 | 0 (omitted)
2#3 | .0701329 1.068705 0.07 0.948 -2.02449 2.164755
2#4 | .538821 .9366071 0.58 0.565 -1.296895 2.374537
2#5 | 0 (omitted)
2#6 | 0 (omitted)
2#7 | 0 (empty)
|
Parity | -.0368471 .158912 -0.23 0.817 -.3483088 .2746146
DOSCC | -.0826244 .1211786 -0.68 0.495 -.3201301 .1548812
DOMY | -.0052291 .0165485 -0.32 0.752 -.0376636 .0272053
|
PrevCM |
1 | .4903174 .3604001 1.36 0.174 -.2160538 1.196688
DODIM | -.0029538 .0027678 -1.07 0.286 -.0083786 .002471
PCSampDIM | .0019829 .0541207 0.04 0.971 -.1040917 .1080575
_cons | 3.975348 1.857073 2.14 0.032 .3355525 7.615143
-------------+----------------------------------------------------------------
CowID |
var(_cons)| .993516 .6029097 .3024321 3.263787
------------------------------------------------------------------------------
LR test vs. logistic model: chibar2(01) = 4.87 Prob >= chibar2 = 0.0137
. testparm Tx#FARMID
( 1) [Cure]2.Tx#2.FARMID = 0
( 2) [Cure]2.Tx#3.FARMID = 0
( 3) [Cure]2.Tx#4.FARMID = 0
( 4) [Cure]3.Tx#3.FARMID = 0
( 5) [Cure]3.Tx#4.FARMID = 0
chi2( 5) = 1.51
Prob > chi2 = 0.9119
.
. *Step 4b: Tx: Parity
. meglm Cure i.Tx##i.Parity DOSCC DOMY i.PrevCM DODIM PCSampDIM|| FARMID:|| CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -347.41961
Iteration 1: log likelihood = -344.43194
Iteration 2: log likelihood = -344.41461
Iteration 3: log likelihood = -344.4146
Refining starting values:
Grid node 0: log likelihood = -342.46088
Fitting full model:
Iteration 0: log likelihood = -342.46088 (not concave)
Iteration 1: log likelihood = -340.47107 (not concave)
Iteration 2: log likelihood = -339.61852
Iteration 3: log likelihood = -339.03458
Iteration 4: log likelihood = -338.80358
Iteration 5: log likelihood = -338.78959
Iteration 6: log likelihood = -338.78946
Iteration 7: log likelihood = -338.78946
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(13) = 11.83
Log likelihood = -338.78946 Prob > chi2 = 0.5416
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .2315985 .4318339 0.54 0.592 -.6147805 1.077977
2 | .9625776 .4951733 1.94 0.052 -.0079444 1.933099
|
Parity |
2 | -.085348 .4599586 -0.19 0.853 -.9868504 .8161544
3 | 1.050123 .6226753 1.69 0.092 -.1702981 2.270544
|
Tx#Parity |
1#2 | .1208669 .6647355 0.18 0.856 -1.181991 1.423725
1#3 | -1.028261 .7797511 -1.32 0.187 -2.556545 .5000233
2#2 | -.8669613 .6811266 -1.27 0.203 -2.201945 .4680222
2#3 | -2.174915 .8420039 -2.58 0.010 -3.825213 -.524618
|
DOSCC | -.0806853 .1193036 -0.68 0.499 -.3145159 .1531454
DOMY | -.0064929 .0160087 -0.41 0.685 -.0378695 .0248836
|
PrevCM |
1 | .4329826 .3546984 1.22 0.222 -.2622136 1.128179
DODIM | -.0025959 .0027218 -0.95 0.340 -.0079304 .0027387
PCSampDIM | -.029054 .0509525 -0.57 0.569 -.1289191 .0708112
_cons | 3.886378 1.324212 2.93 0.003 1.29097 6.481786
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .195338 .1995793 .0263696 1.447006
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .9865625 .635185 .2793123 3.484651
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 11.25 Prob > chi2 = 0.0036
Note: LR test is conservative and provided only for reference.
. testparm Tx#Parity
( 1) [Cure]2.Tx#2.Parity = 0
( 2) [Cure]2.Tx#3.Parity = 0
( 3) [Cure]3.Tx#2.Parity = 0
( 4) [Cure]3.Tx#3.Parity = 0
chi2( 4) = 7.40
Prob > chi2 = 0.1161
.
. *Step 4c: Tx:PrevCM
. meglm Cure i.Tx##i.PrevCM DOSCC DOMY Parity DODIM PCSampDIM || FARMID:|| CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -350.05372
Iteration 1: log likelihood = -348.07459
Iteration 2: log likelihood = -348.05966
Iteration 3: log likelihood = -348.05964
Refining starting values:
Grid node 0: log likelihood = -345.90448
Fitting full model:
Iteration 0: log likelihood = -345.90448 (not concave)
Iteration 1: log likelihood = -342.64265
Iteration 2: log likelihood = -342.34071
Iteration 3: log likelihood = -342.17217
Iteration 4: log likelihood = -342.11636
Iteration 5: log likelihood = -342.11516
Iteration 6: log likelihood = -342.11516
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(10) = 5.81
Log likelihood = -342.11516 Prob > chi2 = 0.8306
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | -.0080293 .3219444 -0.02 0.980 -.6390287 .6229702
2 | .2728611 .3326607 0.82 0.412 -.3791418 .924864
|
PrevCM |
1 | .5365124 .5541259 0.97 0.333 -.5495545 1.622579
|
Tx#PrevCM |
1#1 | .6937262 .9030079 0.77 0.442 -1.076137 2.463589
2#1 | -.8972941 .8471407 -1.06 0.290 -2.557659 .7630713
|
DOSCC | -.1194005 .1215808 -0.98 0.326 -.3576945 .1188934
DOMY | -.0067386 .0164079 -0.41 0.681 -.0388975 .0254203
Parity | -.0394723 .1592814 -0.25 0.804 -.3516581 .2727134
DODIM | -.0026349 .0027981 -0.94 0.346 -.0081191 .0028494
PCSampDIM | -.0233892 .0521212 -0.45 0.654 -.1255449 .0787664
_cons | 4.337472 1.37205 3.16 0.002 1.648304 7.02664
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .1782429 .1966366 .0205103 1.549006
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.236526 .6840638 .418125 3.656791
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 11.89 Prob > chi2 = 0.0026
Note: LR test is conservative and provided only for reference.
. testparm Tx#PrevCM
( 1) [Cure]2.Tx#2.PrevCM = 0
( 2) [Cure]3.Tx#2.PrevCM = 0
chi2( 2) = 2.73
Prob > chi2 = 0.2550
.
. *Step 5: Removing unnecessary covariates using 10% rule. Will do so in this order:
.
. *DOMY DODIM PCSampDIM PrevCM DOSCC Parity
. *Step 5a: full model
. meglm Cure i.Tx i.Parity DOSCC DOMY i.PrevCM DODIM PCSampDIM || FARMID: || CowID:, or family(binomial) link(lo
> git)
Fitting fixed-effects model:
Iteration 0: log likelihood = -350.437
Iteration 1: log likelihood = -348.7516
Iteration 2: log likelihood = -348.75047
Iteration 3: log likelihood = -348.75047
Refining starting values:
Grid node 0: log likelihood = -346.52437
Fitting full model:
Iteration 0: log likelihood = -346.52437 (not concave)
Iteration 1: log likelihood = -344.48269 (not concave)
Iteration 2: log likelihood = -343.61991
Iteration 3: log likelihood = -343.24243
Iteration 4: log likelihood = -342.85845
Iteration 5: log likelihood = -342.81198
Iteration 6: log likelihood = -342.81116
Iteration 7: log likelihood = -342.81116
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(9) = 5.02
Log likelihood = -342.81116 Prob > chi2 = 0.8326
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.032489 .3042975 0.11 0.914 .5794515 1.839727
2 | 1.166573 .3512019 0.51 0.609 .6466272 2.104601
|
Parity |
2 | .7214776 .2044126 -1.15 0.249 .4140533 1.257157
3 | .9705136 .3133323 -0.09 0.926 .5154535 1.827316
|
DOSCC | .9140688 .1095001 -0.75 0.453 .7227862 1.155974
DOMY | .995246 .0161419 -0.29 0.769 .9641061 1.027392
|
PrevCM |
1 | 1.616928 .580557 1.34 0.181 .7999583 3.268241
DODIM | .9974022 .0027395 -0.95 0.344 .9920474 1.002786
PCSampDIM | .9718037 .0496944 -0.56 0.576 .8791263 1.074251
_cons | 67.6825 90.70151 3.15 0.002 4.895295 935.7804
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .1867491 .1969007 .0236475 1.474793
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.129688 .6638476 .3570754 3.574019
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 11.88 Prob > chi2 = 0.0026
Note: LR test is conservative and provided only for reference.
.
. *Step 5b: remove DOMY
. meglm Cure i.Tx i.Parity DOSCC i.PrevCM DODIM PCSampDIM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -350.70242
Iteration 1: log likelihood = -349.1285
Iteration 2: log likelihood = -349.12719
Iteration 3: log likelihood = -349.12719
Refining starting values:
Grid node 0: log likelihood = -346.51542
Fitting full model:
Iteration 0: log likelihood = -346.51542 (not concave)
Iteration 1: log likelihood = -344.49734 (not concave)
Iteration 2: log likelihood = -343.63925
Iteration 3: log likelihood = -343.07358
Iteration 4: log likelihood = -342.86189
Iteration 5: log likelihood = -342.85457
Iteration 6: log likelihood = -342.85452
Iteration 7: log likelihood = -342.85452
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(8) = 4.96
Log likelihood = -342.85452 Prob > chi2 = 0.7614
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.031242 .3033449 0.10 0.917 .5793958 1.835463
2 | 1.164983 .3499961 0.51 0.611 .6465361 2.099163
|
Parity |
2 | .7214105 .2040092 -1.15 0.248 .4144474 1.255728
3 | .9736742 .3137365 -0.08 0.934 .5177739 1.830995
|
DOSCC | .922068 .1067162 -0.70 0.483 .7349344 1.156851
|
PrevCM |
1 | 1.617348 .5799091 1.34 0.180 .8009407 3.265927
DODIM | .9975546 .0026854 -0.91 0.363 .9923052 1.002832
PCSampDIM | .9729236 .0495517 -0.54 0.590 .8804941 1.075056
_cons | 53.9168 58.53637 3.67 0.000 6.420844 452.7476
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .1926407 .1981272 .0256628 1.44608
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.117709 .6609648 .3507235 3.561989
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 12.55 Prob > chi2 = 0.0019
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOMY stays out
.
. *Step 5c: remove DODIM
. meglm Cure i.Tx i.Parity DOSCC i.PrevCM PCSampDIM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -351.14402
Iteration 1: log likelihood = -349.68869
Iteration 2: log likelihood = -349.68729
Iteration 3: log likelihood = -349.68729
Refining starting values:
Grid node 0: log likelihood = -346.90934
Fitting full model:
Iteration 0: log likelihood = -346.90934 (not concave)
Iteration 1: log likelihood = -344.88803 (not concave)
Iteration 2: log likelihood = -344.04224
Iteration 3: log likelihood = -343.73234
Iteration 4: log likelihood = -343.31664
Iteration 5: log likelihood = -343.26138
Iteration 6: log likelihood = -343.26029
Iteration 7: log likelihood = -343.26029
Mixed-effects GLM Number of obs = 934
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.4 432
CowID | 598 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(7) = 4.13
Log likelihood = -343.26029 Prob > chi2 = 0.7651
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.006052 .2956315 0.02 0.984 .5655774 1.789569
2 | 1.153325 .3473712 0.47 0.636 .6391123 2.081258
|
Parity |
2 | .728767 .2065633 -1.12 0.264 .4181405 1.27015
3 | .9826146 .3174885 -0.05 0.957 .5216209 1.851021
|
DOSCC | .9096542 .1047471 -0.82 0.411 .725872 1.139968
|
PrevCM |
1 | 1.600664 .5753971 1.31 0.191 .7912532 3.238061
PCSampDIM | .9716917 .0495228 -0.56 0.573 .8793192 1.073768
_cons | 26.46978 19.30999 4.49 0.000 6.335623 110.5888
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .1919828 .1967903 .0257481 1.431459
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.147467 .666526 .3675407 3.58241
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 12.85 Prob > chi2 = 0.0016
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DODIM stays out
.
. *Step 5d: remove PCSampDIM
. meglm Cure i.Tx i.Parity DOSCC i.PrevCM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -351.521
Iteration 1: log likelihood = -350.13479
Iteration 2: log likelihood = -350.13313
Iteration 3: log likelihood = -350.13313
Refining starting values:
Grid node 0: log likelihood = -347.11941
Fitting full model:
Iteration 0: log likelihood = -347.11941 (not concave)
Iteration 1: log likelihood = -345.14656 (not concave)
Iteration 2: log likelihood = -344.29259
Iteration 3: log likelihood = -343.89051
Iteration 4: log likelihood = -343.54933
Iteration 5: log likelihood = -343.51863
Iteration 6: log likelihood = -343.51817
Iteration 7: log likelihood = -343.51816
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(6) = 3.85
Log likelihood = -343.51816 Prob > chi2 = 0.6963
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.0172 .2969191 0.06 0.953 .57404 1.802482
2 | 1.159567 .3481599 0.49 0.622 .6437577 2.088666
|
Parity |
2 | .7331329 .2070609 -1.10 0.272 .4214784 1.275235
3 | .9872955 .3183056 -0.04 0.968 .5248298 1.857273
|
DOSCC | .9075697 .1044614 -0.84 0.399 .7242802 1.137243
|
PrevCM |
1 | 1.605251 .5762427 1.32 0.187 .7942988 3.244156
_cons | 22.79676 15.24329 4.68 0.000 6.14764 84.53525
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .212114 .2119145 .0299342 1.50304
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.133847 .6653042 .3590023 3.58106
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 13.23 Prob > chi2 = 0.0013
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PCSampDIM stays out
.
. *Step 5e: remove PrevCM
. meglm Cure i.Tx i.Parity DOSCC || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -352.35019
Iteration 1: log likelihood = -351.27832
Iteration 2: log likelihood = -351.27542
Iteration 3: log likelihood = -351.27542
Refining starting values:
Grid node 0: log likelihood = -348.04582
Fitting full model:
Iteration 0: log likelihood = -348.04582 (not concave)
Iteration 1: log likelihood = -346.05509 (not concave)
Iteration 2: log likelihood = -345.20918
Iteration 3: log likelihood = -344.62142
Iteration 4: log likelihood = -344.4343
Iteration 5: log likelihood = -344.42991
Iteration 6: log likelihood = -344.42989
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(5) = 2.11
Log likelihood = -344.42989 Prob > chi2 = 0.8341
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .9905228 .2902217 -0.03 0.974 .5577809 1.758998
2 | 1.11603 .3356713 0.36 0.715 .6189533 2.012306
|
Parity |
2 | .7635097 .2157108 -0.96 0.340 .4388626 1.328313
3 | 1.068914 .3413763 0.21 0.835 .571606 1.99889
|
DOSCC | .9225645 .1055088 -0.70 0.481 .7373086 1.154368
_cons | 22.68037 15.18691 4.66 0.000 6.104928 84.25968
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .2105352 .211072 .0295089 1.502092
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.184413 .6728698 .3889843 3.606403
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 13.69 Prob > chi2 = 0.0011
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PrevCM stays out
.
. *Step 5f: remove DOSCC
. meglm Cure i.Tx i.Parity || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -352.69991
Iteration 1: log likelihood = -351.74072
Iteration 2: log likelihood = -351.73754
Iteration 3: log likelihood = -351.73754
Refining starting values:
Grid node 0: log likelihood = -348.27189
Fitting full model:
Iteration 0: log likelihood = -348.27189 (not concave)
Iteration 1: log likelihood = -346.25817 (not concave)
Iteration 2: log likelihood = -345.43308
Iteration 3: log likelihood = -344.76925
Iteration 4: log likelihood = -344.68144
Iteration 5: log likelihood = -344.67848
Iteration 6: log likelihood = -344.67848
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(4) = 1.62
Log likelihood = -344.67848 Prob > chi2 = 0.8058
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .9944239 .2911706 -0.02 0.985 .560192 1.76525
2 | 1.113221 .3346209 0.36 0.721 .617619 2.006515
|
Parity |
2 | .7414364 .2071194 -1.07 0.284 .4288365 1.281905
3 | 1.024465 .321302 0.08 0.939 .5540325 1.894343
|
_cons | 15.99591 6.87199 6.45 0.000 6.891676 37.12727
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .2148922 .2129964 .0307984 1.499384
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.185891 .6733975 .3896705 3.609042
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 14.12 Prob > chi2 = 0.0009
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOSCC stays out
.
. *Step 5g: remove Parity
. meglm Cure i.Tx || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -353.20902
Iteration 1: log likelihood = -352.40395
Iteration 2: log likelihood = -352.40224
Iteration 3: log likelihood = -352.40224
Refining starting values:
Grid node 0: log likelihood = -349.0007
Fitting full model:
Iteration 0: log likelihood = -349.0007 (not concave)
Iteration 1: log likelihood = -346.96632 (not concave)
Iteration 2: log likelihood = -346.14666
Iteration 3: log likelihood = -345.4633
Iteration 4: log likelihood = -345.40105
Iteration 5: log likelihood = -345.39982
Iteration 6: log likelihood = -345.39982
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.15
Log likelihood = -345.39982 Prob > chi2 = 0.9260
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.026987 .3011334 0.09 0.928 .5780635 1.824545
2 | 1.120379 .3387493 0.38 0.707 .6194438 2.026412
|
_cons | 14.50972 5.793927 6.70 0.000 6.633808 31.73623
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .2096099 .2126392 .0287018 1.530788
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.24887 .6858433 .4256592 3.664144
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 14.00 Prob > chi2 = 0.0009
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. Parity stays out
. *Step 6: Report final model
. meglm Cure i.Tx || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -353.20902
Iteration 1: log likelihood = -352.40395
Iteration 2: log likelihood = -352.40224
Iteration 3: log likelihood = -352.40224
Refining starting values:
Grid node 0: log likelihood = -349.0007
Fitting full model:
Iteration 0: log likelihood = -349.0007 (not concave)
Iteration 1: log likelihood = -346.96632 (not concave)
Iteration 2: log likelihood = -346.14666
Iteration 3: log likelihood = -345.4633
Iteration 4: log likelihood = -345.40105
Iteration 5: log likelihood = -345.39982
Iteration 6: log likelihood = -345.39982
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.15
Log likelihood = -345.39982 Prob > chi2 = 0.9260
------------------------------------------------------------------------------
Cure | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.026987 .3011334 0.09 0.928 .5780635 1.824545
2 | 1.120379 .3387493 0.38 0.707 .6194438 2.026412
|
_cons | 14.50972 5.793927 6.70 0.000 6.633808 31.73623
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .2096099 .2126392 .0287018 1.530788
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.24887 .6858433 .4256592 3.664144
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 14.00 Prob > chi2 = 0.0009
Note: LR test is conservative and provided only for reference.
. meglm Cure i.Tx || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -353.20902
Iteration 1: log likelihood = -352.40395
Iteration 2: log likelihood = -352.40224
Iteration 3: log likelihood = -352.40224
Refining starting values:
Grid node 0: log likelihood = -349.0007
Fitting full model:
Iteration 0: log likelihood = -349.0007 (not concave)
Iteration 1: log likelihood = -346.96632 (not concave)
Iteration 2: log likelihood = -346.14666
Iteration 3: log likelihood = -345.4633
Iteration 4: log likelihood = -345.40105
Iteration 5: log likelihood = -345.39982
Iteration 6: log likelihood = -345.39982
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.15
Log likelihood = -345.39982 Prob > chi2 = 0.9260
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0266294 .2932202 0.09 0.928 -.5480716 .6013304
2 | .1136667 .3023525 0.38 0.707 -.4789333 .7062667
|
_cons | 2.674819 .3993134 6.70 0.000 1.892179 3.457459
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .2096099 .2126392 .0287018 1.530788
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.24887 .6858433 .4256592 3.664144
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 14.00 Prob > chi2 = 0.0009
Note: LR test is conservative and provided only for reference.
. margins Tx
Adjusted predictions Number of obs = 935
Model VCE : OIM
Expression : Marginal predicted mean, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
0 | .8968886 .0246228 36.43 0.000 .8486288 .9451485
1 | .8990069 .0236782 37.97 0.000 .8525985 .9454152
2 | .9056856 .0229709 39.43 0.000 .8606636 .9507077
------------------------------------------------------------------------------
. margins, dydx(Tx)
Conditional marginal effects Number of obs = 935
Model VCE : OIM
Expression : Marginal predicted mean, predict()
dy/dx w.r.t. : 2.Tx 3.Tx
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0021182 .0233467 0.09 0.928 -.0436405 .0478769
2 | .008797 .023463 0.37 0.708 -.0371896 .0547836
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.
.
. *Report ICC
. meglm Cure || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -353.30048
Iteration 1: log likelihood = -352.52467
Iteration 2: log likelihood = -352.52326
Iteration 3: log likelihood = -352.52326
Refining starting values:
Grid node 0: log likelihood = -349.06993
Fitting full model:
Iteration 0: log likelihood = -349.06993 (not concave)
Iteration 1: log likelihood = -347.04046 (not concave)
Iteration 2: log likelihood = -346.2167
Iteration 3: log likelihood = -345.54666
Iteration 4: log likelihood = -345.47877
Iteration 5: log likelihood = -345.47707
Iteration 6: log likelihood = -345.47707
Mixed-effects GLM Number of obs = 935
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 29 133.6 432
CowID | 599 1 1.6 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(0) = .
Log likelihood = -345.47707 Prob > chi2 = .
------------------------------------------------------------------------------
Cure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | 2.723899 .3540443 7.69 0.000 2.029985 3.417813
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .211154 .2139055 .0289938 1.537775
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| 1.254913 .6866821 .4293786 3.667641
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 14.09 Prob > chi2 = 0.0009
Note: LR test is conservative and provided only for reference.
. estat icc
Intraclass correlation
------------------------------------------------------------------------------
Level | ICC Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
FARMID | .044398 .042782 .0063969 .2510963
CowID|FARMID | .3082605 .1076934 .1420787 .5452763
------------------------------------------------------------------------------
CrossTable(SDCTQTR$Tx,SDCTQTR$IMIPC,prop.c=FALSE,prop.t=FALSE,prop.chisq = FALSE)
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Row Total |
## |-------------------------|
##
##
## Total Observations in Table: 4173
##
##
## | SDCTQTR$IMIPC
## SDCTQTR$Tx | 0 | 1 | Row Total |
## -------------|-----------|-----------|-----------|
## 0 | 1075 | 317 | 1392 |
## | 0.772 | 0.228 | 0.334 |
## -------------|-----------|-----------|-----------|
## 1 | 1085 | 341 | 1426 |
## | 0.761 | 0.239 | 0.342 |
## -------------|-----------|-----------|-----------|
## 2 | 1052 | 303 | 1355 |
## | 0.776 | 0.224 | 0.325 |
## -------------|-----------|-----------|-----------|
## Column Total | 3212 | 961 | 4173 |
## -------------|-----------|-----------|-----------|
##
##
Model type: Logistic regression with mixed effects (generalized linear mixed model with binomial family / logit link).
Step 1: Identify potential confouders using a directed acyclic graph (DAG)
Step 2: Create model with all potential confounders
Step 3: Investigate potential effect measure modification
Step 4: Remove unneccesary covariates in backwards stepwise fashion using 10% rule (i.e. if odds ratio for algorithm or culture changes by >10% after removing the covariate, the covariate is retained in the model)
Step 5: Report final model
This is used to identify variables that could be confounders if they are not balanced between treatment groups.
library(DiagrammeR)
mermaid("graph LR
T(Treatment)-->U(IMI at calving)
A(Age)-->T
P(Parity)-->T
M(Yield at dry-off)-->T
S(SCC during prev lactation)-->T
C(CM in prev lact)-->T
D(DIM at dry off) --> M
I(IMI at dry off) --> T
K(DIM at post calving sample) --> T
I-->U
P-->I
A-->I
C-->I
I-->S
I-->M
D-->S
D-->U
K-->U
A-->U
P-->U
M-->U
S-->U
C-->U
C-->M
P-->C
P-->S
P-->M
A-->P
A-->C
A-->S
A-->M
M-->S
C-->S
style D fill:#FFFFFF, stroke-width:0px
style K fill:#FFFFFF, stroke-width:0px
style A fill:#FFFFFF, stroke-width:0px
style T fill:#FFFFFF, stroke-width:2px
style P fill:#FFFFFF, stroke-width:0px
style M fill:#FFFFFF, stroke-width:0px
style S fill:#FFFFFF, stroke-width:0px
style C fill:#FFFFFF, stroke-width:0px
style I fill:#FFFFFF, stroke-width:0px
style U fill:#FFFFFF, stroke-width:2px
")
According to this DAG, I may need to control for the following variables.
Parity [“Parity”] or Age [“Age”] <- will use Parity
Yield at most recent test before dry off [“DOMY”]
Somatic cell count at last herd test during previous lactation [“DOSCC” or “PrevSCCHi”] <- will use DOSCC
Clinical mastitis in previous lactation [“PrevCM”]
IMI at dry-off [“DOIMI”]
Days in milk at dry-off [“DODIM”]
Days in milk at post-calving sample [“PCSampDIM”]
.
. *Outcome 2: IMI at calving
. *Step 2: Create full model with all potential confounders
. meglm IMIPC i.Tx Parity DOMY DOSCC PrevCM IMIDO DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(
> logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1972.9477
Iteration 1: log likelihood = -1969.9397
Iteration 2: log likelihood = -1969.9381
Iteration 3: log likelihood = -1969.9381
Refining starting values:
Grid node 0: log likelihood = -1880.0448
Fitting full model:
Iteration 0: log likelihood = -1880.0448 (not concave)
Iteration 1: log likelihood = -1875.7902
Iteration 2: log likelihood = -1873.2827
Iteration 3: log likelihood = -1871.0224
Iteration 4: log likelihood = -1870.9691
Iteration 5: log likelihood = -1870.969
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(9) = 29.28
Log likelihood = -1870.969 Prob > chi2 = 0.0006
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.064306 .1348285 0.49 0.623 .8302987 1.364264
2 | 1.00599 .1294595 0.05 0.963 .7817247 1.294594
|
Parity | 1.139873 .0763847 1.95 0.051 .9995769 1.299861
DOMY | 1.003524 .0073828 0.48 0.632 .9891581 1.018099
DOSCC | 1.067242 .0535843 1.30 0.195 .9672202 1.177606
PrevCM | 1.063003 .1592066 0.41 0.683 .7925916 1.425671
IMIDO | 1.468733 .1509537 3.74 0.000 1.200765 1.796503
DODIM | 1.001932 .0011586 1.67 0.095 .9996633 1.004205
PCSampDIM | 1.04424 .0241874 1.87 0.062 .9978939 1.09274
_cons | .0254663 .0162636 -5.75 0.000 .0072838 .0890373
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5790281 .337259 .1848891 1.813376
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7491731 .1480878 .5085416 1.103666
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 197.94 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
.
. *Step 3: Explore effect measure modification
. *Will test Tx:Farm, Tx:Parity, Tx:IMIDO
.
. *Tx: Farm
. meglm IMIPC i.Tx##i.FARMID i.Parity DOMY DOSCC i.PrevCM i.IMIDO DODIM PCSampDIM|| CowID:, or family(binomial)
> link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1885.34
Iteration 1: log likelihood = -1870.7527
Iteration 2: log likelihood = -1870.018
Iteration 3: log likelihood = -1870.0046
Iteration 4: log likelihood = -1870.0046
Refining starting values:
Grid node 0: log likelihood = -1861.3111
Fitting full model:
Iteration 0: log likelihood = -1861.3111
Iteration 1: log likelihood = -1860.7842
Iteration 2: log likelihood = -1850.7289
Iteration 3: log likelihood = -1850.3284
Iteration 4: log likelihood = -1850.3279
Iteration 5: log likelihood = -1850.3279
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
Group variable: CowID Number of groups = 1,020
Obs per group:
min = 1
avg = 3.7
max = 14
Integration method: mvaghermite Integration pts. = 7
Wald chi2(28) = 198.85
Log likelihood = -1850.3279 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.563937 .948898 0.74 0.461 .4761725 5.136585
2 | .5807539 .4425017 -0.71 0.476 .1304442 2.58559
|
FARMID |
2 | .2885552 .2477606 -1.45 0.148 .0536249 1.552714
3 | 3.649367 1.869004 2.53 0.011 1.337454 9.95763
4 | 9.951948 4.678565 4.89 0.000 3.960455 25.00755
5 | 3.992145 1.917637 2.88 0.004 1.557147 10.23489
6 | 1.899263 1.32687 0.92 0.359 .4829647 7.468866
7 | 2.0054 1.086091 1.28 0.199 .6937521 5.796923
|
Tx#FARMID |
1#2 | 2.400507 2.560048 0.82 0.412 .2968449 19.41228
1#3 | .6087728 .4151604 -0.73 0.467 .1599438 2.317091
1#4 | .4746733 .301876 -1.17 0.241 .1364771 1.650934
1#5 | 1.148546 .7504808 0.21 0.832 .319123 4.133699
1#6 | .5654 .5392353 -0.60 0.550 .0872057 3.665783
1#7 | .5433689 .4203369 -0.79 0.430 .1192961 2.474933
2#2 | 6.723449 7.646861 1.68 0.094 .7235771 62.47402
2#3 | 2.235757 1.839998 0.98 0.328 .4455508 11.21895
2#4 | 1.208298 .9491019 0.24 0.810 .259159 5.633542
2#5 | 2.313727 1.856495 1.05 0.296 .4800899 11.15069
2#6 | 1.765391 1.874891 0.54 0.593 .2202128 14.1527
2#7 | 1.953289 1.726443 0.76 0.449 .3454775 11.04367
|
Parity |
2 | 1.209252 .1501758 1.53 0.126 .947997 1.542505
3 | 1.314272 .1736397 2.07 0.039 1.014438 1.702726
|
DOMY | 1.003167 .0072287 0.44 0.661 .9890984 1.017435
DOSCC | 1.061709 .0520662 1.22 0.222 .9644122 1.168822
|
PrevCM |
1 | 1.018864 .1489532 0.13 0.898 .7650234 1.356932
1.IMIDO | 1.449771 .147576 3.65 0.000 1.187554 1.769887
DODIM | 1.002011 .0011344 1.77 0.076 .9997903 1.004237
PCSampDIM | 1.038967 .0233972 1.70 0.090 .9941066 1.085852
_cons | .0131376 .0090715 -6.27 0.000 .0033944 .0508473
-------------+----------------------------------------------------------------
CowID |
var(_cons)| .6415448 .1390202 .4195416 .9810226
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chibar2(01) = 39.35 Prob >= chibar2 = 0.0000
. testparm Tx#FARMID
( 1) [IMIPC]2.Tx#2.FARMID = 0
( 2) [IMIPC]2.Tx#3.FARMID = 0
( 3) [IMIPC]2.Tx#4.FARMID = 0
( 4) [IMIPC]2.Tx#5.FARMID = 0
( 5) [IMIPC]2.Tx#6.FARMID = 0
( 6) [IMIPC]2.Tx#7.FARMID = 0
( 7) [IMIPC]3.Tx#2.FARMID = 0
( 8) [IMIPC]3.Tx#3.FARMID = 0
( 9) [IMIPC]3.Tx#4.FARMID = 0
(10) [IMIPC]3.Tx#5.FARMID = 0
(11) [IMIPC]3.Tx#6.FARMID = 0
(12) [IMIPC]3.Tx#7.FARMID = 0
chi2( 12) = 15.80
Prob > chi2 = 0.2006
.
. *Tx:Parity
. meglm IMIPC i.Tx##i.Parity DOMY DOSCC i.PrevCM i.IMIDO DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial
> ) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1961.9816
Iteration 1: log likelihood = -1958.8838
Iteration 2: log likelihood = -1958.8824
Iteration 3: log likelihood = -1958.8824
Refining starting values:
Grid node 0: log likelihood = -1873.0968
Fitting full model:
Iteration 0: log likelihood = -1873.0968 (not concave)
Iteration 1: log likelihood = -1868.7914
Iteration 2: log likelihood = -1867.0414
Iteration 3: log likelihood = -1863.3268
Iteration 4: log likelihood = -1863.0241
Iteration 5: log likelihood = -1863.0203
Iteration 6: log likelihood = -1863.0203
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(14) = 45.25
Log likelihood = -1863.0203 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .9549044 .1816876 -0.24 0.808 .6576632 1.386488
2 | .8320818 .1655725 -0.92 0.356 .5633638 1.228975
|
Parity |
2 | 1.311768 .2787919 1.28 0.202 .8648685 1.989592
3 | .7827437 .1839262 -1.04 0.297 .4938641 1.2406
|
Tx#Parity |
1#2 | .9709453 .2871704 -0.10 0.921 .5438013 1.733601
1#3 | 1.62389 .505994 1.56 0.120 .8817132 2.990788
2#2 | .7912254 .2374283 -0.78 0.435 .4394146 1.424708
2#3 | 2.769359 .8868991 3.18 0.001 1.478354 5.187764
|
DOMY | 1.003261 .0072939 0.45 0.654 .9890666 1.017659
DOSCC | 1.060503 .0529514 1.18 0.239 .9616363 1.169533
|
PrevCM |
1 | 1.054289 .1560901 0.36 0.721 .7887456 1.40923
1.IMIDO | 1.475639 .1510596 3.80 0.000 1.207379 1.803503
DODIM | 1.001714 .0011489 1.49 0.135 .9994644 1.003968
PCSampDIM | 1.046403 .0239728 1.98 0.048 1.000456 1.094459
_cons | .0375454 .0236885 -5.20 0.000 .0109021 .1293017
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .558679 .3252641 .1784806 1.748774
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6882053 .1440497 .4566161 1.037253
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 191.72 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. testparm Tx#Parity
( 1) [IMIPC]2.Tx#2.Parity = 0
( 2) [IMIPC]2.Tx#3.Parity = 0
( 3) [IMIPC]3.Tx#2.Parity = 0
( 4) [IMIPC]3.Tx#3.Parity = 0
chi2( 4) = 15.63
Prob > chi2 = 0.0036
.
. *Significant interaction
. *Will explore this further
. margins Tx#Parity
Predictive margins Number of obs = 3,778
Model VCE : OIM
Expression : Marginal predicted mean, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx#Parity |
0#1 | .1630162 .0381247 4.28 0.000 .0882932 .2377393
0#2 | .1966229 .043449 4.53 0.000 .1114645 .2817813
0#3 | .1364337 .035299 3.87 0.000 .0672489 .2056185
1#1 | .1577389 .0363894 4.33 0.000 .086417 .2290608
1#2 | .1868145 .043116 4.33 0.000 .1023087 .2713203
1#3 | .1865577 .0431494 4.32 0.000 .1019864 .2711289
2#1 | .142739 .0344418 4.14 0.000 .0752343 .2102436
2#2 | .1466827 .0362533 4.05 0.000 .0756276 .2177378
2#3 | .2416321 .0509907 4.74 0.000 .1416921 .341572
------------------------------------------------------------------------------
. *It appears that within Algorithm cows, the IMIPC risk is higher in 3rd or greater lactation cows than early l
> actation cows. The opposite was observed in the blanket group, where lact 3 cows had the lowest IMIPC risk. Gi
> ven the wide confidence intervals around these estimates, I will not report a stratified model.
.
. *Decision: Use main effects model
.
. *Tx:Parity
. meglm IMIPC i.Tx##i.IMIDO i.Parity DOMY DOSCC i.PrevCM DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial
> ) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1971.8906
Iteration 1: log likelihood = -1968.8788
Iteration 2: log likelihood = -1968.8772
Iteration 3: log likelihood = -1968.8772
Refining starting values:
Grid node 0: log likelihood = -1879.4274
Fitting full model:
Iteration 0: log likelihood = -1879.4274 (not concave)
Iteration 1: log likelihood = -1875.1663
Iteration 2: log likelihood = -1872.5916
Iteration 3: log likelihood = -1870.2992
Iteration 4: log likelihood = -1870.242
Iteration 5: log likelihood = -1870.2418
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(12) = 30.76
Log likelihood = -1870.2418 Prob > chi2 = 0.0021
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.120922 .1640263 0.78 0.435 .8414291 1.493251
2 | 1.089189 .1609832 0.58 0.563 .8152577 1.455163
|
1.IMIDO | 1.691 .2989301 2.97 0.003 1.195833 2.391204
|
Tx#IMIDO |
1#1 | .8526381 .2073981 -0.66 0.512 .5293173 1.373452
2#1 | .7651783 .1907092 -1.07 0.283 .4694761 1.24713
|
Parity |
2 | 1.206506 .1526585 1.48 0.138 .9415154 1.546078
3 | 1.287884 .1736213 1.88 0.061 .9888379 1.677368
|
DOMY | 1.003458 .0073703 0.47 0.638 .9891158 1.018008
DOSCC | 1.066234 .0536436 1.27 0.202 .9661122 1.176732
|
PrevCM |
1 | 1.057345 .1582839 0.37 0.710 .7884829 1.417885
DODIM | 1.001948 .0011576 1.68 0.092 .9996815 1.004219
PCSampDIM | 1.04437 .0241635 1.88 0.061 .9980679 1.092819
_cons | .0291986 .0185135 -5.57 0.000 .0084266 .1011744
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5753079 .3351308 .183677 1.801963
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7431065 .1477216 .5033167 1.097137
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 197.27 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. testparm Tx#IMIDO
( 1) [IMIPC]2.Tx#1.IMIDO = 0
( 2) [IMIPC]3.Tx#1.IMIDO = 0
chi2( 2) = 1.17
Prob > chi2 = 0.5571
.
. *Step 4: Remove unnecessary covariates from the model using 10% rule
.
. *I will remove in this order: DODIM DOMY PCSampDIM Parity PrevCM DOSCC IMIDO
.
. *Step 4a: Full model
. meglm IMIPC i.Tx i.IMIDO i.Parity DOMY DOSCC i.PrevCM DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial)
> link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1972.9357
Iteration 1: log likelihood = -1969.9254
Iteration 2: log likelihood = -1969.9238
Iteration 3: log likelihood = -1969.9238
Refining starting values:
Grid node 0: log likelihood = -1879.9861
Fitting full model:
Iteration 0: log likelihood = -1879.9861 (not concave)
Iteration 1: log likelihood = -1875.724
Iteration 2: log likelihood = -1873.1668
Iteration 3: log likelihood = -1870.8826
Iteration 4: log likelihood = -1870.8268
Iteration 5: log likelihood = -1870.8266
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(10) = 29.56
Log likelihood = -1870.8266 Prob > chi2 = 0.0010
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.068751 .1355891 0.52 0.600 .8334644 1.370458
2 | 1.007114 .1295462 0.06 0.956 .7826865 1.295895
|
1.IMIDO | 1.466731 .1507505 3.73 0.000 1.199124 1.79406
|
Parity |
2 | 1.207196 .1528663 1.49 0.137 .9418695 1.547265
3 | 1.289672 .1739904 1.89 0.059 .9900183 1.680024
|
DOMY | 1.003475 .0073782 0.47 0.637 .9891178 1.018041
DOSCC | 1.064984 .0536091 1.25 0.211 .9649292 1.175414
|
PrevCM |
1 | 1.064525 .1593264 0.42 0.676 .7938848 1.427429
DODIM | 1.001927 .001158 1.67 0.096 .9996601 1.0042
PCSampDIM | 1.044657 .0241876 1.89 0.059 .9983099 1.093156
_cons | .0306514 .0193903 -5.51 0.000 .008871 .1059076
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5771543 .3361326 .1843127 1.807294
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7466678 .1479631 .5063484 1.101046
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 198.19 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
.
. *Step 4b: remove DODIM
. meglm IMIPC i.Tx i.IMIDO i.Parity DOMY DOSCC i.PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(
> logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1974.0498
Iteration 1: log likelihood = -1971.052
Iteration 2: log likelihood = -1971.0504
Iteration 3: log likelihood = -1971.0504
Refining starting values:
Grid node 0: log likelihood = -1881.0078
Fitting full model:
Iteration 0: log likelihood = -1881.0078 (not concave)
Iteration 1: log likelihood = -1876.7399
Iteration 2: log likelihood = -1874.3513
Iteration 3: log likelihood = -1872.2513
Iteration 4: log likelihood = -1872.2029
Iteration 5: log likelihood = -1872.2028
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(9) = 26.84
Log likelihood = -1872.2028 Prob > chi2 = 0.0015
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.081468 .1373188 0.62 0.537 .843204 1.387057
2 | 1.012999 .1304689 0.10 0.920 .7870074 1.303885
|
1.IMIDO | 1.465231 .1506413 3.72 0.000 1.197826 1.792333
|
Parity |
2 | 1.204918 .1528546 1.47 0.142 .939669 1.545041
3 | 1.281913 .1732054 1.84 0.066 .9836681 1.670585
|
DOMY | 1.001252 .0072509 0.17 0.863 .9871405 1.015564
DOSCC | 1.066214 .0537145 1.27 0.203 .9659663 1.176866
|
PrevCM |
1 | 1.089519 .1628479 0.57 0.566 .8128451 1.460367
PCSampDIM | 1.044139 .0242295 1.86 0.063 .9977137 1.092724
_cons | .0606924 .0288252 -5.90 0.000 .0239257 .1539582
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5609821 .3271093 .1789008 1.75908
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7554017 .1486741 .5136284 1.110982
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 197.70 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DODIM stays out
.
. *Step 4c: remove DOMY
. meglm IMIPC i.Tx i.IMIDO i.Parity DOSCC i.PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(logit
> )
Fitting fixed-effects model:
Iteration 0: log likelihood = -1975.4529
Iteration 1: log likelihood = -1972.4662
Iteration 2: log likelihood = -1972.4646
Iteration 3: log likelihood = -1972.4646
Refining starting values:
Grid node 0: log likelihood = -1880.696
Fitting full model:
Iteration 0: log likelihood = -1880.696 (not concave)
Iteration 1: log likelihood = -1876.4569
Iteration 2: log likelihood = -1875.1531
Iteration 3: log likelihood = -1872.8089
Iteration 4: log likelihood = -1872.2206
Iteration 5: log likelihood = -1872.2177
Iteration 6: log likelihood = -1872.2177
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(8) = 26.82
Log likelihood = -1872.2177 Prob > chi2 = 0.0008
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.082235 .1373363 0.62 0.533 .8439246 1.387841
2 | 1.013459 .1304933 0.10 0.917 .7874175 1.304389
|
1.IMIDO | 1.466433 .1506025 3.73 0.000 1.199068 1.793414
|
Parity |
2 | 1.204918 .1528411 1.47 0.142 .9396899 1.545007
3 | 1.281342 .1730855 1.84 0.066 .9832947 1.669731
|
DOSCC | 1.062972 .0501627 1.29 0.196 .9690651 1.16598
|
PrevCM |
1 | 1.09126 .1627884 0.59 0.558 .8146115 1.461861
PCSampDIM | 1.043941 .0241971 1.86 0.064 .9975763 1.09246
_cons | .0636529 .0246084 -7.12 0.000 .029836 .1357987
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5624046 .3278289 .1794232 1.762866
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7551785 .1486539 .513445 1.110722
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 200.49 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOMY stays out
.
. *Step 4d: remove PCSampDIM
. meglm IMIPC i.Tx i.IMIDO i.Parity DOSCC i.PrevCM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2006.6564
Iteration 1: log likelihood = -2003.9169
Iteration 2: log likelihood = -2003.9151
Iteration 3: log likelihood = -2003.9151
Refining starting values:
Grid node 0: log likelihood = -1881.5566
Fitting full model:
Iteration 0: log likelihood = -1881.5566
Iteration 1: log likelihood = -1880.152
Iteration 2: log likelihood = -1877.7157
Iteration 3: log likelihood = -1875.7699
Iteration 4: log likelihood = -1875.6956
Iteration 5: log likelihood = -1875.6945
Iteration 6: log likelihood = -1875.6945
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(7) = 23.74
Log likelihood = -1875.6945 Prob > chi2 = 0.0013
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.071557 .1356024 0.55 0.585 .8361772 1.373196
2 | 1.011112 .1299895 0.09 0.931 .7859015 1.30086
|
1.IMIDO | 1.457562 .1495204 3.67 0.000 1.192088 1.782154
|
Parity |
2 | 1.195244 .1513462 1.41 0.159 .9325549 1.53193
3 | 1.265434 .1706125 1.75 0.081 .9715739 1.648173
|
DOSCC | 1.065019 .0502522 1.34 0.182 .9709433 1.168209
|
PrevCM |
1 | 1.09649 .1635346 0.62 0.537 .8185657 1.468778
_cons | .0779274 .0303872 -6.54 0.000 .0362887 .1673437
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6821897 .3879751 .2237739 2.0797
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7545164 .1487097 .5127469 1.110285
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 256.44 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PCSampdim stays out
.
. *Step 4e: remove Parity
. meglm IMIPC i.Tx i.IMIDO DOSCC i.PrevCM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2007.0395
Iteration 1: log likelihood = -2004.3244
Iteration 2: log likelihood = -2004.3226
Iteration 3: log likelihood = -2004.3226
Refining starting values:
Grid node 0: log likelihood = -1882.4385
Fitting full model:
Iteration 0: log likelihood = -1882.4385
Iteration 1: log likelihood = -1881.1409
Iteration 2: log likelihood = -1879.1052
Iteration 3: log likelihood = -1877.531
Iteration 4: log likelihood = -1877.4714
Iteration 5: log likelihood = -1877.4705
Iteration 6: log likelihood = -1877.4705
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(5) = 20.23
Log likelihood = -1877.4705 Prob > chi2 = 0.0011
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.060385 .1344509 0.46 0.644 .8270582 1.359538
2 | 1.004622 .1296456 0.04 0.971 .7801103 1.293748
|
1.IMIDO | 1.458653 .1497232 3.68 0.000 1.192836 1.783707
DOSCC | 1.091994 .0495907 1.94 0.053 .9989984 1.193647
|
PrevCM |
1 | 1.135848 .1686784 0.86 0.391 .8490106 1.519593
_cons | .0784321 .0304172 -6.56 0.000 .0366763 .1677269
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6709123 .382098 .21973 2.048529
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7729361 .149883 .5285473 1.130325
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 253.70 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. Parity stays out.
.
. *Step 4f: remove PrevCM
. meglm IMIPC i.Tx i.IMIDO DOSCC || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2008.051
Iteration 1: log likelihood = -2005.3031
Iteration 2: log likelihood = -2005.3013
Iteration 3: log likelihood = -2005.3013
Refining starting values:
Grid node 0: log likelihood = -1882.8382
Fitting full model:
Iteration 0: log likelihood = -1882.8382
Iteration 1: log likelihood = -1881.5595
Iteration 2: log likelihood = -1879.4886
Iteration 3: log likelihood = -1877.8979
Iteration 4: log likelihood = -1877.8379
Iteration 5: log likelihood = -1877.837
Iteration 6: log likelihood = -1877.837
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(4) = 19.52
Log likelihood = -1877.837 Prob > chi2 = 0.0006
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.059386 .1342875 0.46 0.649 .8263352 1.358164
2 | 1.001371 .1291303 0.01 0.992 .7777318 1.28932
|
1.IMIDO | 1.462474 .1500249 3.71 0.000 1.196106 1.788163
DOSCC | 1.099267 .0491942 2.11 0.034 1.006955 1.20004
_cons | .0774261 .0300822 -6.58 0.000 .0361553 .1658069
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6759702 .384812 .2214935 2.062976
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7725109 .1498084 .5282461 1.129726
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 254.93 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PrevCM stays out
.
. *Step 4g: DOSCC
. meglm IMIPC i.Tx i.IMIDO || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2017.9657
Iteration 1: log likelihood = -2015.129
Iteration 2: log likelihood = -2015.1271
Iteration 3: log likelihood = -2015.1271
Refining starting values:
Grid node 0: log likelihood = -1884.5227
Fitting full model:
Iteration 0: log likelihood = -1884.5227
Iteration 1: log likelihood = -1883.4111
Iteration 2: log likelihood = -1881.4923
Iteration 3: log likelihood = -1880.1253
Iteration 4: log likelihood = -1880.0701
Iteration 5: log likelihood = -1880.069
Iteration 6: log likelihood = -1880.069
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(3) = 15.12
Log likelihood = -1880.069 Prob > chi2 = 0.0017
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.044838 .1326597 0.35 0.730 .8146571 1.340057
2 | .994684 .1286252 -0.04 0.967 .7719942 1.281611
|
1.IMIDO | 1.485706 .1522237 3.86 0.000 1.215401 1.816126
_cons | .1170025 .0395811 -6.34 0.000 .0602893 .2270651
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6990755 .3968672 .2297706 2.126932
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .787457 .151022 .540729 1.146764
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 270.12 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOSCC stays out
.
. *Step 4h: IMIDO
. meglm IMIPC i.Tx || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2255.3529
Iteration 1: log likelihood = -2251.3561
Iteration 2: log likelihood = -2251.3524
Iteration 3: log likelihood = -2251.3524
Refining starting values:
Grid node 0: log likelihood = -2107.8746
Fitting full model:
Iteration 0: log likelihood = -2107.8746
Iteration 1: log likelihood = -2106.1639
Iteration 2: log likelihood = -2104.97
Iteration 3: log likelihood = -2104.0976
Iteration 4: log likelihood = -2103.8445
Iteration 5: log likelihood = -2103.8382
Iteration 6: log likelihood = -2103.8382
Mixed-effects GLM Number of obs = 4,173
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 168 596.1 1,270
CowID | 1,110 1 3.8 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.30
Log likelihood = -2103.8382 Prob > chi2 = 0.8588
------------------------------------------------------------------------------
IMIPC | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.028108 .1224685 0.23 0.816 .8140355 1.298477
2 | .9624265 .117121 -0.31 0.753 .7581968 1.221668
|
_cons | .1369277 .0470221 -5.79 0.000 .0698525 .2684112
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .7402117 .4188413 .2441811 2.243881
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7458774 .1363842 .5212242 1.067358
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 295.03 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. IMIDO stays out
. *Report final model
. meglm IMIPC i.Tx || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2255.3529
Iteration 1: log likelihood = -2251.3561
Iteration 2: log likelihood = -2251.3524
Iteration 3: log likelihood = -2251.3524
Refining starting values:
Grid node 0: log likelihood = -2107.8746
Fitting full model:
Iteration 0: log likelihood = -2107.8746
Iteration 1: log likelihood = -2106.1639
Iteration 2: log likelihood = -2104.97
Iteration 3: log likelihood = -2104.0976
Iteration 4: log likelihood = -2103.8445
Iteration 5: log likelihood = -2103.8382
Iteration 6: log likelihood = -2103.8382
Mixed-effects GLM Number of obs = 4,173
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 168 596.1 1,270
CowID | 1,110 1 3.8 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.30
Log likelihood = -2103.8382 Prob > chi2 = 0.8588
------------------------------------------------------------------------------
IMIPC | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0277202 .1191203 0.23 0.816 -.2057513 .2611917
2 | -.0382976 .1216934 -0.31 0.753 -.2768123 .2002172
|
_cons | -1.988302 .3434079 -5.79 0.000 -2.661369 -1.315235
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .7402117 .4188413 .2441811 2.243881
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7458774 .1363842 .5212242 1.067358
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 295.03 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. margins Tx
Adjusted predictions Number of obs = 4,173
Model VCE : OIM
Expression : Marginal predicted mean, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
0 | .1715523 .0413514 4.15 0.000 .090505 .2525996
1 | .1748378 .0418245 4.18 0.000 .0928634 .2568123
2 | .1670851 .0406833 4.11 0.000 .0873473 .246823
------------------------------------------------------------------------------
. margins, dydx(Tx)
Conditional marginal effects Number of obs = 4,173
Model VCE : OIM
Expression : Marginal predicted mean, predict()
dy/dx w.r.t. : 2.Tx 3.Tx
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0032855 .0141263 0.23 0.816 -.0244015 .0309726
2 | -.0044672 .0142121 -0.31 0.753 -.0323224 .023388
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.
.
. *Report ICC
. meglm IMIPC || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -2255.8741
Iteration 1: log likelihood = -2251.865
Iteration 2: log likelihood = -2251.8612
Iteration 3: log likelihood = -2251.8612
Refining starting values:
Grid node 0: log likelihood = -2107.9919
Fitting full model:
Iteration 0: log likelihood = -2107.9919
Iteration 1: log likelihood = -2106.2959
Iteration 2: log likelihood = -2105.1109
Iteration 3: log likelihood = -2104.2477
Iteration 4: log likelihood = -2103.9969
Iteration 5: log likelihood = -2103.9905
Iteration 6: log likelihood = -2103.9905
Mixed-effects GLM Number of obs = 4,173
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 168 596.1 1,270
CowID | 1,110 1 3.8 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(0) = .
Log likelihood = -2103.9905 Prob > chi2 = .
------------------------------------------------------------------------------
IMIPC | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | -1.991534 .3364834 -5.92 0.000 -2.651029 -1.332038
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .7414414 .4195001 .2446107 2.247388
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .7465621 .1363831 .5218758 1.067984
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 295.74 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. estat icc
Intraclass correlation
------------------------------------------------------------------------------
Level | ICC Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
FARMID | .1551824 .0740752 .057219 .3573024
CowID|FARMID | .3114365 .0645448 .2004738 .4493027
------------------------------------------------------------------------------
CrossTable(SDCTQTR$Tx,SDCTQTR$NewIMI,prop.c=FALSE,prop.t=FALSE,prop.chisq = FALSE)
##
##
## Cell Contents
## |-------------------------|
## | N |
## | N / Row Total |
## |-------------------------|
##
##
## Total Observations in Table: 3794
##
##
## | SDCTQTR$NewIMI
## SDCTQTR$Tx | 0 | 1 | Row Total |
## -------------|-----------|-----------|-----------|
## 0 | 1009 | 246 | 1255 |
## | 0.804 | 0.196 | 0.331 |
## -------------|-----------|-----------|-----------|
## 1 | 1026 | 272 | 1298 |
## | 0.790 | 0.210 | 0.342 |
## -------------|-----------|-----------|-----------|
## 2 | 995 | 246 | 1241 |
## | 0.802 | 0.198 | 0.327 |
## -------------|-----------|-----------|-----------|
## Column Total | 3030 | 764 | 3794 |
## -------------|-----------|-----------|-----------|
##
##
Model type: Logistic regression with mixed effects (generalized linear mixed model with binomial family / logit link).
Step 1: Identify potential confouders using a directed acyclic graph (DAG)
Step 2: Create model with all potential confounders
Step 3: Investigate potential effect measure modification
Step 4: Remove unneccesary covariates in backwards stepwise fashion using 10% rule (i.e. if odds ratio for algorithm or culture changes by >10% after removing the covariate, the covariate is retained in the model)
Step 5: Report final model
This is used to identify variables that could be confounders if they are not balanced between treatment groups.
library(DiagrammeR)
mermaid("graph LR
T(Treatment)-->U(New IMI)
A(Age)-->T
P(Parity)-->T
M(Yield at dry-off)-->T
S(SCC during prev lactation)-->T
C(CM in prev lact)-->T
D(DIM at dry off) --> T
I(IMI at dry off) --> T
K(DIM at post calving sample) --> T
I-->U
P-->I
A-->I
C-->I
I-->S
I-->M
D-->S
D-->M
D-->U
K-->U
A-->U
P-->U
M-->U
S-->U
C-->U
C-->M
P-->C
P-->S
P-->M
A-->P
A-->C
A-->S
A-->M
M-->S
C-->S
style D fill:#FFFFFF, stroke-width:0px
style K fill:#FFFFFF, stroke-width:0px
style A fill:#FFFFFF, stroke-width:0px
style T fill:#FFFFFF, stroke-width:2px
style P fill:#FFFFFF, stroke-width:0px
style M fill:#FFFFFF, stroke-width:0px
style S fill:#FFFFFF, stroke-width:0px
style C fill:#FFFFFF, stroke-width:0px
style I fill:#FFFFFF, stroke-width:0px
style U fill:#FFFFFF, stroke-width:2px
")
According to this DAG, I may need to control for the following variables.
Parity [“Parity”] or Age [“Age”] <- will use Parity
Yield at most recent test before dry off [“DOMY”]
Somatic cell count at last herd test during previous lactation [“DOSCC” or “PrevSCCHi”] <- will use DOSCC
Clinical mastitis in previous lactation [“PrevCM”]
IMI at dry-off [“DOIMI”]
Days in milk at dry-off [“DODIM”]
Days in milk at post-calving sample [“PCSampDIM”]
. *Outcome 3: New IMI
. *Step 2: Full model with possible covariates
. meglm NewIMI i.Tx Parity DOMY DOSCC PrevCM IMIDO DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial) link
> (logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1861.6904
Iteration 1: log likelihood = -1858.6785
Iteration 2: log likelihood = -1858.6761
Iteration 3: log likelihood = -1858.6761
Refining starting values:
Grid node 0: log likelihood = -1792.7867
Fitting full model:
Iteration 0: log likelihood = -1792.7867 (not concave)
Iteration 1: log likelihood = -1788.5687
Iteration 2: log likelihood = -1786.8649
Iteration 3: log likelihood = -1781.6151
Iteration 4: log likelihood = -1780.2114
Iteration 5: log likelihood = -1780.1959
Iteration 6: log likelihood = -1780.1959
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(9) = 22.75
Log likelihood = -1780.1959 Prob > chi2 = 0.0068
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.067021 .1320534 0.52 0.600 .8371998 1.359931
2 | 1.012385 .1274815 0.10 0.922 .790971 1.295778
|
Parity | 1.146605 .0749428 2.09 0.036 1.008739 1.303313
DOMY | 1.0017 .0072205 0.24 0.814 .9876471 1.015952
DOSCC | 1.056289 .0518521 1.12 0.265 .9593963 1.162966
PrevCM | 1.13313 .1644456 0.86 0.389 .852607 1.505949
IMIDO | .75524 .0825663 -2.57 0.010 .6095758 .935712
DODIM | 1.001827 .0011273 1.62 0.105 .9996199 1.004039
PCSampDIM | 1.047238 .0237995 2.03 0.042 1.001616 1.094939
_cons | .0275763 .0172592 -5.74 0.000 .0080871 .0940326
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5800246 .3402997 .1836739 1.831662
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5678001 .1358789 .3552192 .9075998
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 156.96 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
.
. *Step 3: Check for effect measure modification
. *I will investigate: Tx:FARM Tx:Parity Tx:IMIDO
.
. *Tx:FARMD
. meglm NewIMI i.Tx##i.FARMID Parity DOMY DOSCC PrevCM IMIDO DODIM PCSampDIM || CowID:, or family(binomial) link
> (logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1788.6826
Iteration 1: log likelihood = -1771.7626
Iteration 2: log likelihood = -1770.9436
Iteration 3: log likelihood = -1770.93
Iteration 4: log likelihood = -1770.93
Refining starting values:
Grid node 0: log likelihood = -1773.557
Fitting full model:
Iteration 0: log likelihood = -1773.557
Iteration 1: log likelihood = -1761.6884
Iteration 2: log likelihood = -1759.0793
Iteration 3: log likelihood = -1759.0549
Iteration 4: log likelihood = -1759.0549
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
Group variable: CowID Number of groups = 1,020
Obs per group:
min = 1
avg = 3.7
max = 14
Integration method: mvaghermite Integration pts. = 7
Wald chi2(27) = 167.25
Log likelihood = -1759.0549 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.835406 1.120958 0.99 0.320 .554457 6.075698
2 | .6735357 .515268 -0.52 0.605 .1503747 3.0168
|
FARMID |
2 | .3485607 .3005266 -1.22 0.222 .0643248 1.888767
3 | 4.563922 2.391028 2.90 0.004 1.634541 12.74327
4 | 9.977812 4.832916 4.75 0.000 3.861375 25.78272
5 | 4.310915 2.129946 2.96 0.003 1.636839 11.35358
6 | 2.301965 1.603881 1.20 0.231 .587528 9.019215
7 | 1.920534 1.07953 1.16 0.246 .6382088 5.779383
|
Tx#FARMID |
1#2 | 1.704183 1.832247 0.50 0.620 .2071808 14.0179
1#3 | .444524 .304844 -1.18 0.237 .1159208 1.704625
1#4 | .4113516 .2627111 -1.39 0.164 .1176496 1.438255
1#5 | .9443073 .6175043 -0.09 0.930 .2621157 3.401995
1#6 | .5510212 .5178955 -0.63 0.526 .0873249 3.476948
1#7 | .63422 .4931283 -0.59 0.558 .1381659 2.911247
2#2 | 4.211812 4.843033 1.25 0.211 .4422811 40.10878
2#3 | 1.742258 1.437172 0.67 0.501 .3459111 8.775271
2#4 | 1.087214 .8563911 0.11 0.915 .2321823 5.090973
2#5 | 1.969769 1.581921 0.84 0.399 .4081464 9.506372
2#6 | 1.102605 1.200846 0.09 0.929 .1304301 9.320996
2#7 | 2.15501 1.913196 0.86 0.387 .3782348 12.27827
|
Parity | 1.159285 .0748337 2.29 0.022 1.021513 1.315639
DOMY | 1.001043 .0071295 0.15 0.884 .9871663 1.015114
DOSCC | 1.053274 .0507829 1.08 0.282 .9582992 1.157661
PrevCM | 1.096585 .1565668 0.65 0.518 .8289157 1.450688
IMIDO | .746838 .0811995 -2.68 0.007 .6035038 .9242146
DODIM | 1.001846 .0011129 1.66 0.097 .9996671 1.004029
PCSampDIM | 1.041161 .0231728 1.81 0.070 .9967194 1.087584
_cons | .0113961 .0079917 -6.38 0.000 .002883 .045048
-------------+----------------------------------------------------------------
CowID |
var(_cons)| .4948639 .1294907 .2963142 .8264548
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chibar2(01) = 23.75 Prob >= chibar2 = 0.0000
. testparm Tx#FARMID
( 1) [NewIMI]2.Tx#2.FARMID = 0
( 2) [NewIMI]2.Tx#3.FARMID = 0
( 3) [NewIMI]2.Tx#4.FARMID = 0
( 4) [NewIMI]2.Tx#5.FARMID = 0
( 5) [NewIMI]2.Tx#6.FARMID = 0
( 6) [NewIMI]2.Tx#7.FARMID = 0
( 7) [NewIMI]3.Tx#2.FARMID = 0
( 8) [NewIMI]3.Tx#3.FARMID = 0
( 9) [NewIMI]3.Tx#4.FARMID = 0
(10) [NewIMI]3.Tx#5.FARMID = 0
(11) [NewIMI]3.Tx#6.FARMID = 0
(12) [NewIMI]3.Tx#7.FARMID = 0
chi2( 12) = 14.89
Prob > chi2 = 0.2475
.
. *Tx:Parity
. meglm NewIMI i.Tx##Parity DOMY DOSCC PrevCM IMIDO DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial) lin
> k(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1852.9035
Iteration 1: log likelihood = -1849.617
Iteration 2: log likelihood = -1849.6146
Iteration 3: log likelihood = -1849.6146
Refining starting values:
Grid node 0: log likelihood = -1787.0653
Fitting full model:
Iteration 0: log likelihood = -1787.0653 (not concave)
Iteration 1: log likelihood = -1782.8271
Iteration 2: log likelihood = -1781.6471
Iteration 3: log likelihood = -1774.3269
Iteration 4: log likelihood = -1773.3731
Iteration 5: log likelihood = -1773.3599
Iteration 6: log likelihood = -1773.3598
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(14) = 36.60
Log likelihood = -1773.3598 Prob > chi2 = 0.0008
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .9976673 .1867289 -0.01 0.990 .6913057 1.439797
2 | .9143309 .1786533 -0.46 0.647 .6234263 1.340978
|
Parity |
2 | 1.334815 .2782983 1.39 0.166 .8870581 2.008583
3 | .8965647 .2056382 -0.48 0.634 .5719368 1.40545
|
Tx#Parity |
1#2 | .953522 .2762496 -0.16 0.870 .5404118 1.682428
1#3 | 1.409618 .4292396 1.13 0.260 .7760754 2.560347
2#2 | .6961658 .2065276 -1.22 0.222 .3892167 1.245185
2#3 | 2.247515 .7002916 2.60 0.009 1.220341 4.139273
|
DOMY | 1.001291 .0071464 0.18 0.857 .9873821 1.015396
DOSCC | 1.050112 .0514067 1.00 0.318 .9540389 1.155859
PrevCM | 1.121525 .1614148 0.80 0.426 .845863 1.487022
IMIDO | .7609235 .0829293 -2.51 0.012 .614572 .9421265
DODIM | 1.001637 .0011201 1.46 0.143 .9994445 1.003835
PCSampDIM | 1.049288 .0236552 2.13 0.033 1.003934 1.096691
_cons | .0371982 .0230868 -5.30 0.000 .0110212 .125549
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5619739 .3297342 .1779425 1.774813
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5203301 .132726 .3156124 .8578349
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 152.51 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. testparm Tx#Parity
( 1) [NewIMI]2.Tx#2.Parity = 0
( 2) [NewIMI]2.Tx#3.Parity = 0
( 3) [NewIMI]3.Tx#2.Parity = 0
( 4) [NewIMI]3.Tx#3.Parity = 0
chi2( 4) = 13.64
Prob > chi2 = 0.0086
.
. *P<0.05. Will investigate further.
. margins Tx#Parity
Predictive margins Number of obs = 3,778
Model VCE : OIM
Expression : Marginal predicted mean, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx#Parity |
0#1 | .1401822 .0349876 4.01 0.000 .0716077 .2087567
0#2 | .1732482 .0408119 4.25 0.000 .0932583 .253238
0#3 | .1290123 .034408 3.75 0.000 .0615738 .1964507
1#1 | .1399357 .0341671 4.10 0.000 .0729694 .2069021
1#2 | .1671599 .0407446 4.10 0.000 .087302 .2470179
1#3 | .166311 .0407065 4.09 0.000 .0865278 .2460942
2#1 | .130967 .033026 3.97 0.000 .0662373 .1956968
2#2 | .1237738 .032809 3.77 0.000 .0594694 .1880782
2#3 | .2163237 .0485528 4.46 0.000 .121162 .3114853
------------------------------------------------------------------------------
.
. *Similar pattern to last model, with 3rd and greater parity cows in the algorithm group being much higher than
> other gropus (21% new IMI risk, compared 13% in other parities in algorithm group). Again, it seems to be an
> unnecessary complication to report stratified models in this situation, given that the 95% CI for the new IMI
> risk in that group is very wide (12-31%).
.
. *Tx:IMIDO
. meglm NewIMI i.Tx##i.IMIDO i.Parity DOMY DOSCC PrevCM DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial)
> link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1860.8614
Iteration 1: log likelihood = -1857.7827
Iteration 2: log likelihood = -1857.7802
Iteration 3: log likelihood = -1857.7802
Refining starting values:
Grid node 0: log likelihood = -1792.378
Fitting full model:
Iteration 0: log likelihood = -1792.378 (not concave)
Iteration 1: log likelihood = -1788.1618
Iteration 2: log likelihood = -1786.4059
Iteration 3: log likelihood = -1781.1496
Iteration 4: log likelihood = -1779.6714
Iteration 5: log likelihood = -1779.6553
Iteration 6: log likelihood = -1779.6553
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(12) = 23.76
Log likelihood = -1779.6553 Prob > chi2 = 0.0219
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.112747 .1559613 0.76 0.446 .8454601 1.464536
2 | 1.082339 .1534713 0.56 0.577 .8197217 1.429092
|
1.IMIDO | .8691404 .1613305 -0.76 0.450 .6040728 1.25052
|
Tx#IMIDO |
1#1 | .8537209 .2189073 -0.62 0.537 .5164813 1.411163
2#1 | .7644974 .2026174 -1.01 0.311 .4547567 1.285206
|
Parity |
2 | 1.170315 .1452765 1.27 0.205 .9175702 1.492679
3 | 1.310411 .172048 2.06 0.039 1.013096 1.69498
|
DOMY | 1.00169 .0072078 0.23 0.814 .9876626 1.015917
DOSCC | 1.05675 .0519908 1.12 0.262 .9596091 1.163725
PrevCM | 1.126278 .1634314 0.82 0.412 .8474808 1.496792
DODIM | 1.001846 .0011265 1.64 0.101 .9996407 1.004057
PCSampDIM | 1.047205 .023781 2.03 0.042 1.001617 1.094868
_cons | .0303745 .0189153 -5.61 0.000 .0089626 .1029394
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5776476 .338999 .182863 1.824737
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5627969 .1355316 .3510485 .9022697
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 156.25 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. testparm Tx#IMIDO
( 1) [NewIMI]2.Tx#1.IMIDO = 0
( 2) [NewIMI]3.Tx#1.IMIDO = 0
chi2( 2) = 1.04
Prob > chi2 = 0.5934
.
. *Step 4: remove unnecessary covariates using 10% rule. I will remove in the following order: DODIM DOMY Parity
> DOSCC PCSampDIM PrevCM IMIDO
.
. *Step 4a: Full model
. meglm NewIMI i.Tx i.IMIDO i.Parity DOMY DOSCC PrevCM DODIM PCSampDIM|| FARMID: || CowID:, or family(binomial)
> link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1861.6725
Iteration 1: log likelihood = -1858.6621
Iteration 2: log likelihood = -1858.6597
Iteration 3: log likelihood = -1858.6597
Refining starting values:
Grid node 0: log likelihood = -1792.8234
Fitting full model:
Iteration 0: log likelihood = -1792.8234 (not concave)
Iteration 1: log likelihood = -1788.6041
Iteration 2: log likelihood = -1786.8988
Iteration 3: log likelihood = -1781.626
Iteration 4: log likelihood = -1780.1935
Iteration 5: log likelihood = -1780.1767
Iteration 6: log likelihood = -1780.1766
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(10) = 22.78
Log likelihood = -1780.1766 Prob > chi2 = 0.0116
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.06856 .1324597 0.53 0.593 .8380758 1.362432
2 | 1.012813 .1275305 0.10 0.919 .791313 1.296313
|
1.IMIDO | .7548885 .0825396 -2.57 0.010 .6092735 .9353052
|
Parity |
2 | 1.170651 .1454678 1.27 0.205 .9176041 1.493481
3 | 1.311418 .1723582 2.06 0.039 1.013605 1.696733
|
DOMY | 1.001685 .0072193 0.23 0.815 .9876347 1.015935
DOSCC | 1.055508 .0519578 1.10 0.272 .958431 1.162418
PrevCM | 1.133756 .1645199 0.87 0.387 .8531026 1.506738
DODIM | 1.001825 .0011272 1.62 0.105 .999618 1.004037
PCSampDIM | 1.047391 .0238081 2.04 0.042 1.001752 1.095109
_cons | .0315214 .0196066 -5.56 0.000 .0093143 .1066742
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5793346 .3398983 .1834533 1.829504
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5670989 .1358741 .3545807 .9069899
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 156.97 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
.
. *Step 4b: Removed DODIM
. meglm NewIMI i.Tx i.IMIDO i.Parity DOMY DOSCC PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(l
> ogit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1862.5797
Iteration 1: log likelihood = -1859.6375
Iteration 2: log likelihood = -1859.6352
Iteration 3: log likelihood = -1859.6352
Refining starting values:
Grid node 0: log likelihood = -1793.6987
Fitting full model:
Iteration 0: log likelihood = -1793.6987 (not concave)
Iteration 1: log likelihood = -1789.4788
Iteration 2: log likelihood = -1787.7998
Iteration 3: log likelihood = -1782.6825
Iteration 4: log likelihood = -1781.4844
Iteration 5: log likelihood = -1781.475
Iteration 6: log likelihood = -1781.475
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(9) = 20.20
Log likelihood = -1781.475 Prob > chi2 = 0.0167
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.080621 .1341344 0.62 0.532 .847259 1.378258
2 | 1.019324 .1285538 0.15 0.879 .7960886 1.305158
|
1.IMIDO | .7542522 .082511 -2.58 0.010 .6086952 .9346162
|
Parity |
2 | 1.169168 .1456174 1.25 0.210 .9159281 1.492424
3 | 1.304125 .1717384 2.02 0.044 1.007455 1.688157
|
DOMY | .9995802 .0071005 -0.06 0.953 .9857599 1.013594
DOSCC | 1.056331 .0520548 1.11 0.266 .9590782 1.163447
PrevCM | 1.159 .1679974 1.02 0.309 .8723715 1.539804
PCSampDIM | 1.046796 .0238609 2.01 0.045 1.001059 1.094623
_cons | .0589433 .0283868 -5.88 0.000 .022935 .1514849
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5640013 .3314323 .1782692 1.784366
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5768512 .1366667 .3625755 .9177602
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 156.32 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DODIM stays out
.
. *Step 4c: Removed DOMY
. meglm NewIMI i.Tx i.IMIDO i.Parity DOSCC PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1863.411
Iteration 1: log likelihood = -1860.5129
Iteration 2: log likelihood = -1860.5105
Iteration 3: log likelihood = -1860.5105
Refining starting values:
Grid node 0: log likelihood = -1793.4569
Fitting full model:
Iteration 0: log likelihood = -1793.4569 (not concave)
Iteration 1: log likelihood = -1789.2499
Iteration 2: log likelihood = -1788.2965
Iteration 3: log likelihood = -1784.6423
Iteration 4: log likelihood = -1781.6453
Iteration 5: log likelihood = -1781.4771
Iteration 6: log likelihood = -1781.4767
Iteration 7: log likelihood = -1781.4767
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(8) = 20.19
Log likelihood = -1781.4767 Prob > chi2 = 0.0096
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.080339 .1340172 0.62 0.533 .8471637 1.377693
2 | 1.019161 .1285064 0.15 0.880 .7960021 1.304881
|
1.IMIDO | .7540274 .0823994 -2.58 0.010 .6086514 .9341264
|
Parity |
2 | 1.169183 .145624 1.25 0.210 .915933 1.492455
3 | 1.304316 .1717385 2.02 0.044 1.00764 1.68834
|
DOSCC | 1.05743 .0486781 1.21 0.225 .9662004 1.157274
PrevCM | 1.158337 .167532 1.02 0.309 .8724173 1.537961
PCSampDIM | 1.04686 .0238379 2.01 0.044 1.001166 1.09464
_cons | .0580389 .0234705 -7.04 0.000 .0262725 .1282148
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5635068 .3310508 .1781692 1.782239
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5769498 .1366686 .362664 .91785
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 158.07 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOMY stays out
.
. *Step 4d: Removed Parity
. meglm NewIMI i.Tx i.IMIDO DOSCC PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1864.4594
Iteration 1: log likelihood = -1861.628
Iteration 2: log likelihood = -1861.6257
Iteration 3: log likelihood = -1861.6257
Refining starting values:
Grid node 0: log likelihood = -1794.7534
Fitting full model:
Iteration 0: log likelihood = -1794.7534 (not concave)
Iteration 1: log likelihood = -1790.5609
Iteration 2: log likelihood = -1788.999
Iteration 3: log likelihood = -1784.343
Iteration 4: log likelihood = -1783.5845
Iteration 5: log likelihood = -1783.5819
Iteration 6: log likelihood = -1783.5819
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(6) = 16.02
Log likelihood = -1783.5819 Prob > chi2 = 0.0137
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.070017 .1331255 0.54 0.586 .8384728 1.365502
2 | 1.012496 .1282758 0.10 0.922 .7898645 1.29788
|
1.IMIDO | .7537521 .0824516 -2.58 0.010 .608299 .9339852
DOSCC | 1.085536 .0481186 1.85 0.064 .9952061 1.184065
PrevCM | 1.203671 .1736717 1.28 0.199 .907177 1.597068
PCSampDIM | 1.04518 .0239028 1.93 0.053 .9993656 1.093094
_cons | .0563869 .0227147 -7.14 0.000 .0256025 .124186
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5542098 .3263943 .1747313 1.757833
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .5987475 .1381081 .3809817 .9409863
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 156.09 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. Parity stays out
.
. *Step 4e: Removed DOSCC
. meglm NewIMI i.Tx i.IMIDO PrevCM PCSampDIM|| FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1871.002
Iteration 1: log likelihood = -1868.4634
Iteration 2: log likelihood = -1868.4612
Iteration 3: log likelihood = -1868.4612
Refining starting values:
Grid node 0: log likelihood = -1795.8335
Fitting full model:
Iteration 0: log likelihood = -1795.8335 (not concave)
Iteration 1: log likelihood = -1791.6748
Iteration 2: log likelihood = -1790.2424
Iteration 3: log likelihood = -1785.9546
Iteration 4: log likelihood = -1785.3009
Iteration 5: log likelihood = -1785.2913
Iteration 6: log likelihood = -1785.2913
Mixed-effects GLM Number of obs = 3,778
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 539.7 1,242
CowID | 1,073 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(5) = 12.64
Log likelihood = -1785.2913 Prob > chi2 = 0.0270
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.058321 .1318892 0.45 0.649 .8289713 1.351123
2 | 1.00742 .1279801 0.06 0.954 .7853733 1.292246
|
1.IMIDO | .7634746 .0834353 -2.47 0.014 .6162716 .9458386
PrevCM | 1.261812 .1797879 1.63 0.103 .9543599 1.668312
PCSampDIM | 1.04567 .0239614 1.95 0.051 .9997456 1.093704
_cons | .0762428 .0281896 -6.96 0.000 .0369385 .1573684
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .5704959 .3346868 .1806705 1.801432
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6115098 .1391301 .3915064 .9551419
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 166.34 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. DOSCC stays out
.
. *Step 4f: Removed PCSampDIM
. meglm NewIMI i.Tx i.IMIDO PrevCM || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1903.2371
Iteration 1: log likelihood = -1901.5457
Iteration 2: log likelihood = -1901.5446
Iteration 3: log likelihood = -1901.5446
Refining starting values:
Grid node 0: log likelihood = -1797.1515
Fitting full model:
Iteration 0: log likelihood = -1797.1515
Iteration 1: log likelihood = -1795.411
Iteration 2: log likelihood = -1791.7292
Iteration 3: log likelihood = -1789.064
Iteration 4: log likelihood = -1788.8922
Iteration 5: log likelihood = -1788.891
Iteration 6: log likelihood = -1788.891
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(4) = 8.94
Log likelihood = -1788.891 Prob > chi2 = 0.0626
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.048441 .1304032 0.38 0.704 .8216235 1.337873
2 | 1.006695 .1277623 0.05 0.958 .7850001 1.291
|
1.IMIDO | .7582053 .0828033 -2.53 0.011 .612107 .9391744
PrevCM | 1.266543 .1804773 1.66 0.097 .9579149 1.674606
_cons | .0938639 .0352136 -6.31 0.000 .0449951 .1958085
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .699638 .3995406 .228444 2.142728
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6124416 .1393736 .3920635 .9566938
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 225.31 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PCSampDIM stays out
.
. *Step 4g: Removed PrevCM
. meglm NewIMI i.Tx i.IMIDO || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1906.9318
Iteration 1: log likelihood = -1905.2447
Iteration 2: log likelihood = -1905.2437
Iteration 3: log likelihood = -1905.2437
Refining starting values:
Grid node 0: log likelihood = -1798.4938
Fitting full model:
Iteration 0: log likelihood = -1798.4938
Iteration 1: log likelihood = -1795.2981
Iteration 2: log likelihood = -1791.1013
Iteration 3: log likelihood = -1790.2708
Iteration 4: log likelihood = -1790.2522
Iteration 5: log likelihood = -1790.2521
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(3) = 6.24
Log likelihood = -1790.2521 Prob > chi2 = 0.1005
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.04531 .1300553 0.36 0.722 .819106 1.333981
2 | 1.000218 .1269186 0.00 0.999 .7799827 1.282639
|
1.IMIDO | .7642851 .0833703 -2.46 0.014 .6171689 .9464698
_cons | .1223913 .0416856 -6.17 0.000 .0627823 .2385965
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .7132042 .4068127 .2331779 2.181426
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6156926 .1396327 .3947483 .9603016
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 229.98 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Changed by <10%. PrevCM stays out
.
. *Step 4h: Removed IMIDO
. meglm NewIMI i.Tx || FARMID: || CowID:, or family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1906.9818
Iteration 1: log likelihood = -1905.2958
Iteration 2: log likelihood = -1905.2949
Iteration 3: log likelihood = -1905.2949
Refining starting values:
Grid node 0: log likelihood = -1799.1424
Fitting full model:
Iteration 0: log likelihood = -1799.1424
Iteration 1: log likelihood = -1797.7365
Iteration 2: log likelihood = -1795.025
Iteration 3: log likelihood = -1793.5051
Iteration 4: log likelihood = -1793.3548
Iteration 5: log likelihood = -1793.3536
Iteration 6: log likelihood = -1793.3536
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.17
Log likelihood = -1793.3536 Prob > chi2 = 0.9182
------------------------------------------------------------------------------
NewIMI | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | 1.046956 .1298974 0.37 0.712 .8209531 1.335175
2 | 1.003857 .1270208 0.03 0.976 .7833705 1.286403
|
_cons | .1159121 .0385802 -6.47 0.000 .0603692 .2225576
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6794512 .3882979 .2216701 2.082617
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6082918 .1386766 .3890966 .9509692
------------------------------------------------------------------------------
Note: Estimates are transformed only in the first equation.
Note: _cons estimates baseline odds (conditional on zero random effects).
LR test vs. logistic model: chi2(2) = 223.88 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. *Step 5: Report final model
. meglm NewIMI i.Tx || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1906.9818
Iteration 1: log likelihood = -1905.2958
Iteration 2: log likelihood = -1905.2949
Iteration 3: log likelihood = -1905.2949
Refining starting values:
Grid node 0: log likelihood = -1799.1424
Fitting full model:
Iteration 0: log likelihood = -1799.1424
Iteration 1: log likelihood = -1797.7365
Iteration 2: log likelihood = -1795.025
Iteration 3: log likelihood = -1793.5051
Iteration 4: log likelihood = -1793.3548
Iteration 5: log likelihood = -1793.3536
Iteration 6: log likelihood = -1793.3536
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(2) = 0.17
Log likelihood = -1793.3536 Prob > chi2 = 0.9182
------------------------------------------------------------------------------
NewIMI | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0458864 .1240715 0.37 0.712 -.1972893 .2890622
2 | .0038501 .1265327 0.03 0.976 -.2441495 .2518496
|
_cons | -2.154923 .3328397 -6.47 0.000 -2.807277 -1.502569
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6794512 .3882979 .2216701 2.082617
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .6082918 .1386766 .3890966 .9509692
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 223.88 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. margins Tx
Adjusted predictions Number of obs = 3,794
Model VCE : OIM
Expression : Marginal predicted mean, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
0 | .147021 .0366388 4.01 0.000 .0752102 .2188317
1 | .1520168 .0374303 4.06 0.000 .0786548 .2253789
2 | .1474354 .0367238 4.01 0.000 .075458 .2194128
------------------------------------------------------------------------------
. margins, dydx(Tx)
Conditional marginal effects Number of obs = 3,794
Model VCE : OIM
Expression : Marginal predicted mean, predict()
dy/dx w.r.t. : 2.Tx 3.Tx
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Tx |
1 | .0049959 .0135311 0.37 0.712 -.0215246 .0315164
2 | .0004144 .0136197 0.03 0.976 -.0262798 .0271086
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.
.
. *Report ICC
. meglm NewIMI || FARMID: || CowID:, family(binomial) link(logit)
Fitting fixed-effects model:
Iteration 0: log likelihood = -1907.3926
Iteration 1: log likelihood = -1905.7142
Iteration 2: log likelihood = -1905.7133
Iteration 3: log likelihood = -1905.7133
Refining starting values:
Grid node 0: log likelihood = -1799.2054
Fitting full model:
Iteration 0: log likelihood = -1799.2054
Iteration 1: log likelihood = -1797.8075
Iteration 2: log likelihood = -1795.1011
Iteration 3: log likelihood = -1793.5905
Iteration 4: log likelihood = -1793.4401
Iteration 5: log likelihood = -1793.4389
Iteration 6: log likelihood = -1793.4389
Mixed-effects GLM Number of obs = 3,794
Family: binomial
Link: logit
-------------------------------------------------------------
| No. of Observations per Group
Group Variable | Groups Minimum Average Maximum
----------------+--------------------------------------------
FARMID | 7 156 542.0 1,242
CowID | 1,078 1 3.5 4
-------------------------------------------------------------
Integration method: mvaghermite Integration pts. = 7
Wald chi2(0) = .
Log likelihood = -1793.4389 Prob > chi2 = .
------------------------------------------------------------------------------
NewIMI | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | -2.138052 .3248702 -6.58 0.000 -2.774785 -1.501318
-------------+----------------------------------------------------------------
FARMID |
var(_cons)| .6805675 .3888771 .2220719 2.085686
-------------+----------------------------------------------------------------
FARMID>CowID |
var(_cons)| .607988 .1386545 .3888432 .9506386
------------------------------------------------------------------------------
LR test vs. logistic model: chi2(2) = 224.55 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. estat icc
Intraclass correlation
------------------------------------------------------------------------------
Level | ICC Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
FARMID | .1486467 .0722295 .0539665 .3482828
CowID|FARMID | .2814409 .0657981 .1715021 .4256474
------------------------------------------------------------------------------