bacteria package:MASS R Documentation _P_r_e_s_e_n_c_e _o_f _B_a_c_t_e_r_i_a _a_f_t_e_r _D_r_u_g _T_r_e_a_t_m_e_n_t_s _D_e_s_c_r_i_p_t_i_o_n: Tests of the presence of the bacteria _H. influenzae_ in children with otitis media in the Northern Territory of Australia. _U_s_a_g_e: bacteria _F_o_r_m_a_t: This data frame has 220 rows and the following columns: _y presence or absence: a factor with levels 'n' and 'y'. _a_p active/placebo: a factor with levels 'a' and 'p'. _h_i_l_o hi/low compliance: a factor with levels 'hi' amd 'lo'. _w_e_e_k numeric: week of test. _I_D subject ID: a factor. _t_r_t a factor with levels 'placebo', 'drug' and 'drug+', a re-coding of 'ap' and 'hilo'. _D_e_t_a_i_l_s: 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. _S_o_u_r_c_e: Menzies School of Health Research 1999-2000 Annual Report pp. 18-21 (). _R_e_f_e_r_e_n_c_e_s: Venables, W. N. and Ripley, B. D. (2002) _Modern Applied Statistics with S._ Fourth edition. Springer. _E_x_a_m_p_l_e_s: contrasts(bacteria$trt) <- structure(contr.sdif(3), dimnames = list(NULL, c("drug", "encourage"))) ## fixed effects analyses summary(glm(y ~ trt * week, binomial, data = bacteria)) summary(glm(y ~ trt + week, binomial, data = bacteria)) summary(glm(y ~ trt + I(week > 2), binomial, data = bacteria)) # conditional random-effects analysis library(survival) bacteria$Time <- rep(1, nrow(bacteria)) coxph(Surv(Time, unclass(y)) ~ week + strata(ID), data = bacteria, method = "exact") coxph(Surv(Time, unclass(y)) ~ factor(week) + strata(ID), data = bacteria, method = "exact") coxph(Surv(Time, unclass(y)) ~ I(week > 2) + strata(ID), data = bacteria, method = "exact") # PQL glmm analysis library(nlme) summary(glmmPQL(y ~ trt + I(week > 2), random = ~ 1 | ID, family = binomial, data = bacteria))