Endo: conditional inference in case-control studies

This example analyses a matched case-control study of endometrial cancer, from the data of Breslow and Day (1980). There are I = 183 strata, each one a case matched with a single control, and the exposure of interest, estrogen use, is binary. The data are supplied in collapsed form as three counts: 43 pairs in which the case was exposed and the control was not, 7 in which the control was exposed and the case was not, and 12 in which both were exposed. The remaining 121 pairs, in which neither member was exposed, are implied by the total. The model itself expands these counts back into the full 183-by-2 exposure array est and the response array Y using deterministic loops, so the only actual data the program needs are the four numbers.

The estimand is a single log odds ratio beta for the exposure, and the point of the example is how to estimate it without also estimating a nuisance intercept for every one of the 183 strata. The trick is conditional inference: given that exactly one member of each pair is a case, the probability that the case is the exposed member depends on beta alone, and the stratum-specific baseline risk cancels out. In BUGS this conditional likelihood is written as a one-trial multinomial over the two members of the pair:

\[Y_{i,1:2} \sim \text{Multinomial}(p_{i,1:2},\ 1), \qquad p_{ij} = \frac{\exp(\beta\, \mathrm{est}_{ij})}{\exp(\beta\, \mathrm{est}_{i1}) + \exp(\beta\, \mathrm{est}_{i2})}\]

One consequence falls straight out of that expression: when both members of a pair share the same exposure the two probabilities are equal at one half whatever beta is, so only the 50 discordant pairs carry any information about the odds ratio. beta is given a vague normal prior with precision 1.0E-6, precision rather than variance being the BUGS convention.

Two alternative codings of the same problem are kept in the source as comments: a plain logistic regression on the within-pair exposure difference, and a set of Poisson regressions with an explicit nuisance intercept per stratum. See Volume 2 of the classic BUGS examples and the OpenBUGS Endo page for the background to the study and the published comparison of the three approaches.

The model definition, data, initial values, and published reference results shown here all come from JuliaBUGS.BUGSExamples.VOLUME_2.endo, which ships with the package.

Model

using JuliaBUGS

example = JuliaBUGS.BUGSExamples.VOLUME_2.endo
example.model_def
quote
    for i = 1:I
        Y[i, 1] = 1
        Y[i, 2] = 0
    end
    for i = 1:n10
        est[i, 1] = 1
        est[i, 2] = 0
    end
    for i = n10 + 1:n10 + n01
        est[i, 1] = 0
        est[i, 2] = 1
    end
    for i = n10 + n01 + 1:n10 + n01 + n11
        est[i, 1] = 1
        est[i, 2] = 1
    end
    for i = n10 + n01 + n11 + 1:I
        est[i, 1] = 0
        est[i, 2] = 0
    end
    beta ~ dnorm(0, 1.0e-6)
    for i = 1:I
        Y[i, 1:J] ~ dmulti(p[i, 1:J], 1)
        for j = 1:2
            p[i, j] = e[i, j] / sum(e[i, :])
            e[i, j] = exp(beta * est[i, j])
        end
    end
end

The program as it appears in the original BUGS distribution:

print(example.original_syntax_program)
model {
	# transform collapsed data into full
	for (i in 1 : I){
		Y[i,1] <- 1
		Y[i,2] <- 0
	}
	# loop around strata with case exposed, control not exposed  (n10)
	for (i in 1 : n10){
		est[i,1] <- 1
		est[i,2] <- 0
	}
	# loop around strata with case not exposed, control exposed  (n01)
	for (i in (n10+1) : (n10+n01)){
		est[i,1] <- 0
		est[i,2] <- 1
	}
	# loop around strata with case exposed, control exposed  (n11)
	for (i in (n10+n01+1) : (n10+n01+n11)){
		est[i,1] <- 1
		est[i,2] <- 1
	}
	# loop around strata with case not exposed, control not exposed  (n00)
	for (i in (n10+n01+n11+1) :I ){
		est[i,1] <- 0
		est[i,2] <- 0
	}

	# PRIORS
	beta ~ dnorm(0,1.0E-6)

	# LIKELIHOOD
	for (i in 1 : I) { # loop around strata
	# METHOD 1 - logistic regression
	#   Y[i,1] ~ dbin( p[i,1], 1)
	#   logit(p[i,1]) <- beta * (est[i,1] - est[i,J])
	# METHOD 2 - conditional likelihoods
		Y[i, 1 : J] ~ dmulti( p[i, 1 : J],1)
		for (j in 1:2){
			p[i, j] <- e[i, j] / sum(e[i, ])
			log( e[i, j] ) <- beta * est[i, j]
		}
	# METHOD 3 fit standard Poisson regressions relative to baseline
	# for (j in 1:J) {
	#	 Y[i, j] ~ dpois(mu[i, j]);
	#	log(mu[i, j]) <- beta0[i] +  beta*est[i, j];
	}
	# beta0[i] ~ dnorm(0, 1.0E-6)
}

Data

example.data
(n10 = 43, n01 = 7, n11 = 12, I = 183, J = 2)

Compiling the model

model = JuliaBUGS.compile(example.model_def, example.data, example.inits)
BUGSModel (parameters are in transformed (unconstrained) space, with dimension 1):

  Model parameters:
    beta

  Variable sizes and types:
    n10: type = Int64
    I: type = Int64
    beta: type = Float64
    J: type = Int64
    p: size = (183, 2), type = Matrix{Float64}
    e: size = (183, 2), type = Matrix{Float64}
    n01: type = Int64
    est: size = (183, 2), type = Matrix{Int64}
    Y: size = (183, 2), type = Matrix{Int64}
    n11: type = Int64

The example's own initial values are passed in here. Several of these models fail from random starting values, so example.inits is not optional in practice; a second set is available as example.inits_alternative.

See Getting Started for the recipe that takes a compiled model to posterior samples.

Reference results

The posterior summaries published with the original example. A converged chain should reproduce these up to Monte Carlo error.

example.reference_results
(beta = (mean = 1.873, std = 0.4177),)