bacteria.RdTests of the presence of the bacteria H. influenzae in children with otitis media in the Northern Territory of Australia.
bacteriaThis data frame has 220 rows and the following columns:
presence or absence: a factor with levels
n and y.
active/placebo: a factor with levels a and p.
hi/low compliance: a factor with levels hi amd
lo.
numeric: week of test.
subject ID: a factor.
a factor with levels placebo, drug and
drug+, a re-coding of ap and hilo.
Dr A. Leach tested the effects of a drug on 50 children with a history of otitis media in the Northern Territory of Australia. The children were randomized to the drug or the a placebo, and also to receive active encouragement to comply with taking the drug.
The presence of H. influenzae was checked at weeks 0, 2, 4, 6 and 11: 30 of the checks were missing and are not included in this data frame.
Dr Amanda Leach via Mr James McBroom.
Menzies School of Health Research 1999–2000 Annual Report. p.20. https://www.menzies.edu.au/icms_docs/172302_2000_Annual_report.pdf.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
contrasts(bacteria$trt) <- structure(contr.sdif(3),
dimnames = list(NULL, c("drug", "encourage")))
## fixed effects analyses
summary(glm(y ~ trt * week, binomial, data = bacteria))
#>
#> Call:
#> glm(formula = y ~ trt * week, family = binomial, data = bacteria)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.97548 0.30053 6.573 4.92e-11 ***
#> trtdrug -0.99848 0.69490 -1.437 0.15075
#> trtencourage 0.83865 0.73482 1.141 0.25374
#> week -0.11814 0.04460 -2.649 0.00807 **
#> trtdrug:week -0.01722 0.10570 -0.163 0.87061
#> trtencourage:week -0.07043 0.10964 -0.642 0.52060
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 217.38 on 219 degrees of freedom
#> Residual deviance: 203.12 on 214 degrees of freedom
#> AIC: 215.12
#>
#> Number of Fisher Scoring iterations: 4
#>
summary(glm(y ~ trt + week, binomial, data = bacteria))
#>
#> Call:
#> glm(formula = y ~ trt + week, family = binomial, data = bacteria)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 1.96018 0.29705 6.599 4.15e-11 ***
#> trtdrug -1.10667 0.42519 -2.603 0.00925 **
#> trtencourage 0.45502 0.42766 1.064 0.28735
#> week -0.11577 0.04414 -2.623 0.00872 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 217.38 on 219 degrees of freedom
#> Residual deviance: 203.81 on 216 degrees of freedom
#> AIC: 211.81
#>
#> Number of Fisher Scoring iterations: 4
#>
summary(glm(y ~ trt + I(week > 2), binomial, data = bacteria))
#>
#> Call:
#> glm(formula = y ~ trt + I(week > 2), family = binomial, data = bacteria)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) 2.2479 0.3560 6.315 2.71e-10 ***
#> trtdrug -1.1187 0.4288 -2.609 0.00909 **
#> trtencourage 0.4815 0.4330 1.112 0.26614
#> I(week > 2)TRUE -1.2949 0.4104 -3.155 0.00160 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> (Dispersion parameter for binomial family taken to be 1)
#>
#> Null deviance: 217.38 on 219 degrees of freedom
#> Residual deviance: 199.18 on 216 degrees of freedom
#> AIC: 207.18
#>
#> Number of Fisher Scoring iterations: 5
#>
# conditional random-effects analysis
library(survival)
bacteria$Time <- rep(1, nrow(bacteria))
coxph(Surv(Time, unclass(y)) ~ week + strata(ID),
data = bacteria, method = "exact")
#> Call:
#> coxph(formula = Surv(Time, unclass(y)) ~ week + strata(ID), data = bacteria,
#> method = "exact")
#>
#> coef exp(coef) se(coef) z p
#> week -0.16256 0.84996 0.05472 -2.971 0.00297
#>
#> Likelihood ratio test=9.85 on 1 df, p=0.001696
#> n= 220, number of events= 177
coxph(Surv(Time, unclass(y)) ~ factor(week) + strata(ID),
data = bacteria, method = "exact")
#> Call:
#> coxph(formula = Surv(Time, unclass(y)) ~ factor(week) + strata(ID),
#> data = bacteria, method = "exact")
#>
#> coef exp(coef) se(coef) z p
#> factor(week)2 0.1983 1.2193 0.7241 0.274 0.7842
#> factor(week)4 -1.4206 0.2416 0.6665 -2.131 0.0331
#> factor(week)6 -1.6615 0.1899 0.6825 -2.434 0.0149
#> factor(week)11 -1.6752 0.1873 0.6780 -2.471 0.0135
#>
#> Likelihood ratio test=15.45 on 4 df, p=0.003854
#> n= 220, number of events= 177
coxph(Surv(Time, unclass(y)) ~ I(week > 2) + strata(ID),
data = bacteria, method = "exact")
#> Call:
#> coxph(formula = Surv(Time, unclass(y)) ~ I(week > 2) + strata(ID),
#> data = bacteria, method = "exact")
#>
#> coef exp(coef) se(coef) z p
#> I(week > 2)TRUE -1.6701 0.1882 0.4817 -3.467 0.000527
#>
#> Likelihood ratio test=15.15 on 1 df, p=9.927e-05
#> n= 220, number of events= 177
# PQL glmm analysis
library(nlme)
## IGNORE_RDIFF_BEGIN
summary(glmmPQL(y ~ trt + I(week > 2), random = ~ 1 | ID,
family = binomial, data = bacteria))
#> iteration 1
#> iteration 2
#> iteration 3
#> iteration 4
#> iteration 5
#> iteration 6
#> Linear mixed-effects model fit by maximum likelihood
#> Data: bacteria
#> AIC BIC logLik
#> NA NA NA
#>
#> Random effects:
#> Formula: ~1 | ID
#> (Intercept) Residual
#> StdDev: 1.410637 0.7800511
#>
#> Variance function:
#> Structure: fixed weights
#> Formula: ~invwt
#> Fixed effects: y ~ trt + I(week > 2)
#> Value Std.Error DF t-value p-value
#> (Intercept) 2.7447864 0.3784193 169 7.253294 0.0000
#> trtdrug -1.2473553 0.6440635 47 -1.936696 0.0588
#> trtencourage 0.4930279 0.6699339 47 0.735935 0.4654
#> I(week > 2)TRUE -1.6072570 0.3583379 169 -4.485311 0.0000
#> Correlation:
#> (Intr) trtdrg trtncr
#> trtdrug 0.009
#> trtencourage 0.036 -0.518
#> I(week > 2)TRUE -0.710 0.047 -0.046
#>
#> Standardized Within-Group Residuals:
#> Min Q1 Med Q3 Max
#> -5.1985361 0.1572336 0.3513075 0.4949482 1.7448845
#>
#> Number of Observations: 220
#> Number of Groups: 50
## IGNORE_RDIFF_END