Tutorials › Generalized Linear Models › Sparse Matched-Set Exact Inference Workshop

Conditional and Exact Inference · Tutorial 958 of 981

Sparse Matched-Set Exact Inference Workshop

Build and check a matched-set conditional likelihood, enumerate its exact reference distribution, and invert an exact test to obtain a confidence interval.

Advanced 10 min read

What You'll Learn

  • Write the conditional probability that a matched-set member is the case.
  • Construct the conditional likelihood for a sparse binary-exposure example.
  • Enumerate response allocations and calculate an exact upper-tail p-value.
  • Derive the conditional distribution of the exposure score.
  • Invert an exact test to obtain a confidence interval and explain its coverage.
  • Recognize why a sparse exact result need not agree with a large-sample approximation.

From Matched Sets to Exact Inference

In a matched case-control study, each set contains one case and one or more controls selected to match that case on specified characteristics. When exposure is sparse, a large-sample approximation can be unreliable, and a small number of matched sets may carry most of the information about the exposure effect. Conditional inference offers a direct route: condition on there being one case in each set, write the probability of each possible case assignment, and enumerate the resulting sample space.

We use a binary exposure \(x_{ij}\), where \(x_{ij}=1\) means member \(j\) of set \(i\) is exposed. Let \(\beta\) be the logistic exposure effect and write \(\theta=\exp(\beta)\), the matched odds ratio. The conditional probability below follows from the matched-set logistic model after conditioning on one case per set; the set-specific intercept cancels.

Definition: In a matched set \(i\) with \(m_i\) members and exactly one case, let \(Y_i=j\) mean that member \(j\) is the case. Given the covariates and the fact that the set has one case, the conditional logistic model assigns probability $$ P(Y_i=j\mid \text{one case in set }i,\ x_i) = \frac{\exp(\beta x_{ij})}{\sum_{k=1}^{m_i}\exp(\beta x_{ik})} = \frac{\theta^{x_{ij}}}{\sum_{k=1}^{m_i}\theta^{x_{ik}}}. $$ For conditionally independent matched sets, multiply these probabilities across sets to obtain the conditional likelihood.

Worked Example: Constructing the Conditional Likelihood

Worked Example: Constructing the Conditional Likelihood

Consider three matched triplets, each with one case and two controls. In set A, the case is exposed and both controls are unexposed. In set B, the case and one control are exposed and the other control is unexposed. In set C, all three members are unexposed. Find the conditional likelihood for the observed case assignments.

In set A, the exposed case has weight \(\theta\) and the two unexposed controls each have weight \(1\). The conditional probability of the observed assignment is therefore \(\theta/(\theta+2)\).

In set B, the case has weight \(\theta\), the exposed control has weight \(\theta\), and the unexposed control has weight \(1\). The probability that the observed case is the case is \(\theta/(2\theta+1)\). The fact that another member is exposed does not make the two exposed members interchangeable as observed assignments; the case identity is part of the response allocation.

In set C, all three members have weight \(1\), so the probability of the observed case assignment is \(1/3\). Multiplying the three set contributions gives $$ L(\theta)=\frac{\theta}{\theta+2}\frac{\theta}{2\theta+1}\frac{1}{3} =\frac{\theta^2}{3(\theta+2)(2\theta+1)}. $$ The constant \(1/3\) has no effect on inference about \(\theta\), but it is the probability contribution of the observed assignment in set C. That set contributes no information about the exposure effect.

For these data, the exposure score is \(T=\sum_i x_{i,\text{case}}\), the number of exposed cases. Its observed value is \(T=2\). Given the exposure pattern in each set, every possible response allocation has probability proportional to \(\theta^T\), with a normalizing denominator that depends on the covariates and \(\theta\). This makes it possible to derive the distribution of \(T\) by counting allocations.

Result: For matched sets with one case each and binary exposure, the conditional likelihood of the observed assignment is $$ L(\theta)=\prod_i \frac{\theta^{x_{i,\text{case}}}}{\sum_{j=1}^{m_i}\theta^{x_{ij}}}. $$ If \(T=\sum_i x_{i,\text{case}}\), the conditional distribution of \(T\) has the form \(P_\theta(T=t)=c_t\theta^t/Z(\theta)\), where \(c_t\) counts the response allocations with score \(t\) and \(Z(\theta)=\sum_t c_t\theta^t\).

To verify the distributional form, consider a complete allocation \(a\) that selects one case member in every set. Its probability is the product of the set probabilities, hence $$ P_\theta(a)= \frac{\theta^{T(a)}}{\prod_i\sum_j\theta^{x_{ij}}}. $$ The denominator is the same for every allocation with the same observed covariate pattern. Summing over the allocations with \(T(a)=t\) gives \(c_t\theta^t\) divided by that common denominator. Summing over all allocations shows that the denominator equals \(\sum_t c_t\theta^t\), proving the stated distribution. \(\square\)

Worked Example: Enumerating the Exact Sample Space

Worked Example: Enumerating the Exact Sample Space

Use sets A and B from the preceding example. Enumerate all labeled response allocations and find the conditional distribution of \(T\). Set A has three possible case assignments: its exposed member or either of its two unexposed members. Set B has three: either of its two exposed members or its unexposed member.

There are \(3\times3=9\) joint allocations. For \(T=0\), A’s case must be unexposed (two choices) and B’s case must be unexposed (one choice), giving 2 allocations. For \(T=1\), either A’s case is exposed and B’s is unexposed (1 allocation), or A’s is unexposed and B’s is exposed (2 times 2, or 4 allocations). This gives 5 allocations. For \(T=2\), A’s case is exposed and B’s is one of its two exposed members, giving 2 allocations.

Thus \(c_0=2,\ c_1=5,\ c_2=2\), and the normalizing polynomial is $$ Z(\theta)=2+5\theta+2\theta^2=(\theta+2)(2\theta+1). $$ Therefore $$ P_\theta(T=0)=\frac{2}{(\theta+2)(2\theta+1)},\qquad P_\theta(T=1)=\frac{5\theta}{(\theta+2)(2\theta+1)},\qquad P_\theta(T=2)=\frac{2\theta^2}{(\theta+2)(2\theta+1)}. $$ As a check, the three numerators sum to \(2+5\theta+2\theta^2\), the denominator. At \(\theta=1\), the probabilities are \(2/9,\ 5/9,\ 2/9\), which sum to one. The observed data have \(T=2\).

An Exact Test and Its Conditional Justification

For a prespecified alternative that exposure increases the odds of being the case, an exact upper-tail test of \(H_0:\theta=1\) uses \(P_{\theta=1}(T\geq T_{\text{obs}})\). The test is exact in the sense that its null distribution is calculated from the conditional sample space, not approximated by a continuous distribution.

Worked Example: An Exact Upper-Tail Test

For the observed \(T=2\), the only possible score at least as large is 2. Under the null \(\theta=1\), $$ p_{\text{upper}}=P_{\theta=1}(T\geq2)=P_{\theta=1}(T=2)=\frac{2}{9}\approx0.222. $$ At a 5% significance level this upper-tail test does not reject \(H_0\), because \(2/9>0.05\). The result is not evidence that the odds ratio equals one; it says that this small conditional sample does not yield a sufficiently small upper-tail p-value against the specified one-sided alternative.

The calibration of the upper-tail p-value follows directly from discreteness. Under any fixed null value, let \(q(t)=P(T\geq t)\). Since \(q(t)\) decreases as \(t\) increases, the event \(q(T)\leq a\) consists of an upper tail of possible values. Its probability is the probability of that tail, which is at most \(a\); the inequality may be strict because the distribution places probability at discrete points. Thus a test that rejects when \(q(T)\leq a\) has null rejection probability no greater than \(a\).

For the observed maximum score in this example, a probability-ordering two-sided p-value and a doubled one-sided p-value need not agree in general. Here the two point masses at \(T=0\) and \(T=2\) are equal under the null, so probability-ordering includes both and gives \(4/9\); doubling the smaller one-sided tail also gives \(4/9\). The convention should be stated when a two-sided exact p-value is reported.

Worked Example: Inverting the Test for a Confidence Interval

Worked Example: Inverting the Test for a Confidence Interval

Construct an equal-tailed 95% exact confidence set for \(\theta\) from the observed \(T=2\), using tail probability \(0.025\) for each side. The lower endpoint is found by setting the upper-tail probability equal to \(0.025\): $$ P_\theta(T\geq2)=\frac{2\theta^2}{(\theta+2)(2\theta+1)}=0.025. $$ Multiplying through gives \(2\theta^2=0.025(2\theta^2+5\theta+2)\), or \(78\theta^2-5\theta-2=0\). The positive root is $$ \theta_L=\frac{5+\sqrt{649}}{156}\approx0.1954. $$ The other root is negative and is not in the parameter space \(\theta>0\).

There is no finite upper endpoint: \(T=2\) is the largest possible score, so \(P_\theta(T\leq2)=1\) for every \(\theta>0\), and this lower-tail probability never reaches \(0.025\). The equal-tailed confidence set is therefore approximately \([0.1954,\infty)\). It includes \(\theta=1\), consistent with the upper-tail test result.

Here is the coverage argument behind this inversion. For a finite conditional exponential family \(P_\theta(T=t)=c_t\theta^t/Z(\theta)\), the distribution shifts toward larger \(T\) as \(\theta\) increases. In fact, for any nondecreasing function \(g\), $$ \frac{d}{d\log\theta}E_\theta[g(T)] =\operatorname{Cov}_\theta(g(T),T)\geq0. $$ The equality follows by differentiating the finite sum defining the expectation. The covariance is nonnegative because if \(T'\) is an independent copy of \(T\), then \(2\operatorname{Cov}(g(T),T)=E[(g(T)-g(T'))(T-T')]\geq0\). Taking \(g(T)=I(T\geq t)\) proves that upper tails are nondecreasing in \(\theta\); applying the same argument to lower-tail indicators shows lower tails are nonincreasing. \(\square\)

To see why inversion gives at least 95% coverage, set \(\alpha=0.05\) and form the lower endpoint from the upper-tail equation \(P_\theta(T\geq t)=\alpha/2\), and the upper endpoint from the lower-tail equation \(P_\theta(T\leq t)=\alpha/2\), using parameter-space boundaries when an equation has no solution. At the true parameter, the probability that the lower endpoint exceeds the truth is at most \(\alpha/2\): that event requires an upper-tail p-value no greater than \(\alpha/2\), whose probability is at most \(\alpha/2\) by the discrete-tail argument. The probability that the upper endpoint falls below the truth is likewise at most \(\alpha/2\). By adding these two error probabilities, the interval covers the true parameter with probability at least \(1-\alpha=0.95\). Discreteness can make coverage larger than 95%.

Why Sparsity and Allocation Checks Matter

When matched sets are sparse, the conditional sample space may be small enough to enumerate, but it is easy to count it incorrectly. In the example, B has two exposed members. Those are two distinct possible case assignments, even though they have the same exposure value. Treating them as one allocation would change the coefficient of \(\theta\), and hence the exact distribution and p-value.

A second useful check is to verify the normalizing polynomial in two ways: multiply the set-specific sums, \((\theta+2)(2\theta+1)\), and add the score-specific allocation weights, \(2+5\theta+2\theta^2\). They agree. Also check that probabilities are nonnegative and sum to one at the null value. These elementary checks are especially valuable when one or two allocations can materially change an exact result.

Common pitfall: Counting exposure patterns instead of labeled response allocations can omit multiplicities. In set B, assigning the case to the exposed case member and assigning it to the exposed control are two distinct allocations. Count both, even though both contribute score 1. The correction is to enumerate possible case identities within every matched set, then aggregate allocations by score.
Key takeaway: Conditional exact matched-set inference starts with the probability of each possible case assignment. The score distribution is obtained by aggregating the assignment weights, and exact tests and confidence sets follow from its finite tails. When data are sparse, checking the allocation count and normalizer is part of the inference, not just bookkeeping.

Check Your Understanding

Use the definitions and allocation logic in this tutorial to answer the following.

  1. In a matched triplet with one exposed member and two unexposed members, what is the conditional probability that the exposed member is the case?
  2. Why are the two exposed members in set B counted as two allocations, even though both contribute one to \(T\)?
  3. For the two informative sets in the examples, verify that the three probabilities for \(T=0,1,2\) sum to one for general \(\theta>0\).
  4. Why can an exact test have null rejection probability strictly below its nominal level?
  5. Why does the observed maximum score \(T=2\) produce no finite upper endpoint in the equal-tailed confidence set?
Clinical Biostats