Why Condition on the Margins?
For a two-by-two table, the odds ratio measures the association between a binary group indicator and a binary outcome. Conditional inference fixes the row and column totals and treats one cell count as random. The nuisance probabilities disappear from its distribution, leaving a model indexed by the odds ratio alone. This gives a direct route to conditional tests and confidence limits.
Write the table as follows, with \(X\) denoting the upper-left cell count:
Here \(N\) is the total sample size, \(r\) is the first row total, and \(c\) is the first column total. For probabilities \(p_1\) and \(p_2\) of Outcome 1 in Groups 1 and 2, respectively, the population odds ratio is
The table’s sample cross-product odds ratio is \(X(N-r-c+X)/\{(r-X)(c-X)\}\), when the denominator is nonzero. Conditional maximum likelihood estimation, introduced below, is a different calculation in general.
The Conditional Noncentral Hypergeometric Distribution
Given the margins, the possible values of \(X\) form the support \(S=\{m,m+1,\ldots,M\}\), where \(m=\max(0,r+c-N)\) and \(M=\min(r,c)\). Under independent binomial sampling within the two groups, the probability of observing \(X=x\), before conditioning, contains the factors
For fixed margins, the terms depending on \(x\) reduce, up to a factor constant in \(x\), to \(\binom{r}{x}\binom{N-r}{c-x}\theta^x\). Thus the conditional distribution is
This is the noncentral hypergeometric distribution. At \(\theta=1\), it is the ordinary hypergeometric distribution used in Fisher’s exact test. When \(S\) has at least two values, the conditional likelihood for an observed value \(a\) is proportional to \(w_a\theta^a/Z(\theta)\).
Worked Example: Write Down the Conditional Distribution
Suppose \(N=5\), \(r=2\), and \(c=2\). Then \(S=\{0,1,2\}\), since \(m=\max(0,2+2-5)=0\) and \(M=\min(2,2)=2\). The three weights are
\(w_0=\binom20\binom32=3\), \(w_1=\binom21\binom31=6\), and \(w_2=\binom22\binom30=1\). Therefore \(Z(\theta)=3+6\theta+\theta^2\), and
At \(\theta=1\), these probabilities are \(3/10,6/10,1/10\). They sum to one, as required.
Conditional Maximum Likelihood Estimation
It is convenient to use the log-odds parameter \(\eta=\log\theta\). For observed \(X=a\), the conditional log-likelihood, up to an additive constant independent of \(\theta\), is \(a\eta-\log Z(e^\eta)\). Its derivative is \(a-E_\theta[X]\); differentiating the conditional mean with respect to \(\eta\) gives \(\operatorname{Var}_\theta(X)\).
Proof. Writing the finite sum \(Z(e^\eta)=\sum_{x\in S}w_xe^{\eta x}\), differentiation gives
If \(S\) contains at least two values, every support point has positive probability for finite \(\theta>0\), so this variance is strictly positive. As \(\theta\) tends to zero, the term \(w_m\theta^m\) dominates the finite sum; dividing numerator and denominator by \(\theta^m\) shows that the distribution concentrates at \(m\). Dividing by \(\theta^M\) instead shows concentration at \(M\) as \(\theta\) tends to infinity. The mean is therefore continuous, strictly increasing, and has limits \(m\) and \(M\). For an interior observation, the equation \(E_\theta[X]=a\) has exactly one solution. The log-likelihood derivative \(a-E_\theta[X]\) is positive below that solution and negative above it, proving it is the unique maximizer. For \(a=m\), the derivative is negative for every finite \(\theta\); for \(a=M\), it is positive. These give the stated boundary suprema. If \(S=\{m\}\), then \(Z(\theta)=w_m\theta^m\), so \(\theta^m/Z(\theta)=1/w_m\); the likelihood is constant. \(\square\)
Worked Example: Calculate an Interior Conditional Estimate
Use the margins in the preceding example, and suppose the observed upper-left cell is \(a=1\). The conditional mean is
Setting this equal to the observed count gives \(6\theta+2\theta^2=3+6\theta+\theta^2\), hence \(\theta^2=3\). The unique positive conditional maximum likelihood estimate is \(\hat\theta_c=\sqrt{3}\), approximately \(1.732\). The table cells are \(1,1,1,2\), so the sample cross-product odds ratio is \(2\), not \(\sqrt{3}\). The two estimates use different likelihood calculations and need not agree.
Exact Conditional Tests
To test \(H_0:\theta=\theta_0\) against \(H_1:\theta>\theta_0\), the conditional exact p-value is \(P_{\theta_0}(X\ge a)\). For \(H_1:\theta<\theta_0\), it is \(P_{\theta_0}(X\le a)\). Each probability sums the relevant conditional mass function over the observed tail. A two-sided exact test requires a specified convention: for example, the equal-tailed convention doubles the smaller one-sided tail probability, capped at one. Discreteness means that exact tests can be conservative; their null rejection probability is no greater than the stated level.
For the \(N=4,r=2,c=2\) table, the weights are \(1,4,1\) on \(S=\{0,1,2\}\). If \(a=2\), then under \(H_0:\theta=1\), \(P(X=2)=1/6\). The one-sided p-value against \(\theta>1\) is \(P(X\ge2)=1/6\). The equal-tailed two-sided convention gives \(\min(1,2\min\{P(X\le2),P(X\ge2)\})=1/3\). This illustrates why a two-sided p-value should be reported with its convention.
Exact Confidence Limits by Inversion
A central equal-tailed \(100(1-\alpha)\%\) conditional confidence interval is obtained by inverting the two one-sided tests. For a non-singleton support and observed value \(a\), its lower limit \(L\) solves \(P_L(X\ge a)=\alpha/2\), and its upper limit \(U\) solves \(P_U(X\le a)=\alpha/2\). These tail probabilities are finite sums of the noncentral hypergeometric probabilities. If an observed value is an endpoint of the support, the corresponding limit is a boundary value: \(L=0\) when \(a=m\), and \(U=\infty\) when \(a=M\). These conventions describe limits in the extended positive parameter space; the odds ratio itself is positive and finite.
The tail probabilities move in the required directions as \(\theta\) changes. To see this, write \(\eta=\log\theta\). For any function \(g\) on the finite support, differentiation of the weighted sum gives
Taking \(g(X)=\mathbf{1}\{X\ge k\}\) makes this covariance nonnegative: if \(X'\) is an independent copy of \(X\), twice the covariance equals \(E[(g(X)-g(X'))(X-X')]\), whose integrand is nonnegative because \(g\) is nondecreasing. Thus upper-tail probabilities are nondecreasing in \(\theta\), and lower-tail probabilities are nonincreasing. This establishes the monotonicity needed for test inversion. The resulting interval has coverage at least \(1-\alpha\): each excluded tail event has probability at most \(\alpha/2\) under the true parameter, and the union bound gives total noncoverage at most \(\alpha\). Discreteness can make coverage greater than the nominal level.
Worked Example: Obtain a One-Sided-Boundary Exact Interval
Take \(N=4,r=2,c=2\), for which \(Z(\theta)=1+4\theta+\theta^2\), and observe \(a=2\), the maximum support value. For a 95% equal-tailed interval, \(\alpha/2=0.025\). The lower limit solves
Rearranging gives \(0.975L^2-0.1L-0.025=0\). The positive root is
Because \(a=2\) is the maximum support value, \(P_U(X\le2)=1\) for every finite \(U\); the upper confidence limit is therefore \(\infty\). The interval is approximately \([0.2194,\infty)\). It is not a finite two-sided interval: the data place the observation at the largest possible conditional count.
Degenerate Margins and Common Pitfalls
Worked Example: Recognize a Nonidentifiable Conditional Odds Ratio
Suppose \(r=0\), \(N=10\), and \(c=4\). Then \(X=0\) with probability one given these margins, so \(S=\{0\}\). The conditional likelihood is \(w_0\theta^0/Z(\theta)=1\) for every \(\theta>0\). No value of the odds ratio is favored by the conditional data. It would be incorrect to call the estimate both zero and infinity merely because the observed count equals both the minimum and maximum support values: there is only one support point, and every positive odds ratio maximizes the likelihood.
- Treating the sample cross-product ratio as the conditional maximum likelihood estimate. They are generally different; calculate the conditional likelihood or solve \(E_{\hat\theta_c}[X]=a\) for an interior observation.
- Applying endpoint rules without checking the support size. First check whether \(m<M\). If \(m=M\), the conditional likelihood is constant, not maximized uniquely at either boundary.
- Reporting an exact two-sided p-value without its definition. Different two-sided conventions can produce different values. State the tail or ordering convention used.
- Assuming an exact interval must have finite endpoints. An endpoint observation can yield a zero or infinite limit; that is a consequence of the conditional support, not a calculation failure.
Check Your Understanding
Use the conditional distribution and the boundary conventions to answer these questions.
- For \(N=8,r=3,c=2\), find the support of \(X\) and write the weights \(w_x\).
- Why does the conditional mean \(E_\theta[X]\) increase with \(\theta\) when the support contains at least two values?
- For \(N=4,r=c=2\) and observed \(a=0\), which endpoint of a central exact interval is a boundary value, and why?
- What is the conditional likelihood’s behavior when the margins force \(X\) to a single value?
- Why should a reported two-sided exact p-value identify the convention used?