17.2 Logistic Regression 663
calculated as 7 (number of groups with observations) minus 4 (four estimated
parameters
β
0
−β
3
). Since it is found to be significant,
dev = 10.9967;
pval = 1 - chi2cdf(dev, 7-4) % 0.0117
the fit of this model is not good. To improve the fit, one may include the inter-
actions.
One may ask why the regression model was needed in the first place.
The probabilities of interest could be predicted by relative frequencies. For
example, in the case (
noplan = 0, riskfac = 1, antibio = 1), the relative fre-
quency of infection was 1/18
= 0.0556, just slightly larger than the model-
predicted
ˆ
p
=0.0424. There are two benefits to this approach. First, the model
is able to predict probabilities in the cases where no patients are present, such
as for (
noplan = 1, riskfac = 0, antibio = 1). Second, the predictions for the
cases where y
= 1 is not observed are “borrowing strength” from the model
and are not modeled individually. For example, zero as an estimator in the
case (
noplan = 1, riskfac = 0, antibio = 0) is not reasonable; the model-based
estimator
ˆ
p
= 0.3056 is more realistic. Figure 17.1 compares observed and
model-predicted infection rates. For a triple of covariates (noplan, riskfac, an-
tibio), the numbers on the x-axis code as follows: 1=(0,1,1), 2=(1,1,1), 3=(0,0,1),
4=(1,0,1), 5=(0,1,0), 6=(1,1,0), 7=(0,0,0), and 8=(1,0,0). Note that point 4 does
not have an observed proportion, however the model-predicted proportion can
be found. For computational aspects refer to file
caesarean.m.
Next, we provide a Bayesian solution to this example and compare the
model fit with the classical fit above. The comparisons are summarized in Ta-
ble 17.1.
C-SECTION INFECTIONS
model{
for(i in 1:N){
inf[i] ~ dbin(p[i],total[i])
logit(p[i]) <- beta0 + beta1
*
noplan[i] +
beta2
*
riskfac[i] + beta3
*
antibio[i]
}
beta0 ~dnorm(0, 0.00001)
beta1 ~dnorm(0, 0.00001)
beta2 ~dnorm(0, 0.00001)
beta3 ~dnorm(0, 0.00001)
}
DATA
list(inf=c(1, 11, 0, 0, 28, 23, 8, 0),
total = c(18, 98, 2, 0, 58, 26, 40, 9),
noplan = c(0,1,0,1,0,1,0,1),
riskfac = c(1,1, 0, 0, 1,1, 0, 0),
antibio =c(1,1,1,1,0,0,0,0), N=8)