Tutorials › Generalized Linear Models › Conditioning Margins in Poisson Loglinear Models

Conditional and Exact Inference · Tutorial 951 of 981

Conditioning Margins in Poisson Loglinear Models

Learn how fixed margins turn a Poisson loglinear model into a conditional distribution that eliminates nuisance main effects but retains information about association.

Advanced 9 min read

What You'll Learn

  • Derive the table distribution conditional on fixed row and column margins
  • Identify which loglinear parameters cancel under margin conditioning
  • Express the two-by-two conditional law using the odds ratio
  • Calculate conditional probabilities under independence and nonzero association
  • Recognize why conditioning only one set of margins may leave nuisance parameters

Why Condition on Table Margins?

A two-way contingency table can be modeled as independent Poisson counts, with row and column effects describing baseline rates and interaction terms describing association. When the row and column effects are nuisance parameters, their values can complicate inference about association. Conditioning on the observed row and column totals removes those main effects from the probability law, while the interaction can still affect the relative probabilities of tables with the same margins.

The key is to condition on the margins that carry the nuisance effects. The resulting distribution is not generally an ordinary hypergeometric distribution: that familiar special case corresponds to no association. With association present, the conditional weights retain the interaction parameters.

Poisson Loglinear Model and Fixed Margins

Let \(N_{ij}\) be the count in row \(i\), column \(j\) of an \(r\)-by-\(c\) table, for \(i=1,\ldots,r\) and \(j=1,\ldots,c\). Assume the cell counts are mutually independent and \(N_{ij}\sim\operatorname{Poisson}(\mu_{ij})\), with \(\mu_{ij}>0\). Write the loglinear model as \(\log\mu_{ij}=\alpha_i+\beta_j+\gamma_{ij}\). Here \(\alpha_i\) and \(\beta_j\) are row and column main effects, and \(\gamma_{ij}\) represents the cell’s interaction contribution. Constraints may be imposed to identify a particular parameterization; the conditional law below depends on the interaction only up to terms that are additive by row or column.

Definition: The row margins and column margins are \(R_i=\sum_jN_{ij}\) and \(C_j=\sum_iN_{ij}\). A fixed-margin fiber is the set of all nonnegative-integer tables \(n=(n_{ij})\) having specified row totals \(R_i\) and column totals \(C_j\). It is finite, since every cell count is bounded by its row and column totals.

The independent Poisson joint probability of a table \(n\) is \(\prod_{i,j}e^{-\mu_{ij}}\mu_{ij}^{n_{ij}}/n_{ij}!\). Substituting the loglinear model shows why conditioning works: row and column effects enter through the margins, which have fixed values throughout a fiber.

Theorem: Under the independent Poisson loglinear model above, conditional on all row and column margins, a table \(n\) in the fixed-margin fiber has probability \[ P(N=n\mid R,C)= \frac{\displaystyle\prod_{i,j}\frac{\exp(\gamma_{ij}n_{ij})}{n_{ij}!}} {\displaystyle\sum_{u\text{ in the same fiber}}\prod_{i,j}\frac{\exp(\gamma_{ij}u_{ij})}{u_{ij}!}}. \] Thus the conditional law contains no row main-effect or column main-effect parameters. Its weights can still depend on the interaction.

Proof. For any table \(n\) in the fiber, the joint probability is \[ \begin{aligned} P(N=n) &=\prod_{i,j}\frac{\exp(-\mu_{ij})\exp\{(\alpha_i+\beta_j+\gamma_{ij})n_{ij}\}}{n_{ij}!}\\ &=\exp\left(-\sum_{i,j}\mu_{ij} +\sum_i\alpha_iR_i+\sum_j\beta_jC_j\right) \prod_{i,j}\frac{\exp(\gamma_{ij}n_{ij})}{n_{ij}!}. \end{aligned} \] The exponential factor preceding the product is constant over the fiber: the means and parameters are fixed, and the margins have fixed values. To obtain the conditional probability, divide this joint probability by the sum of the joint probabilities over all tables in the fiber. That common factor cancels, leaving the stated numerator divided by its sum over the fiber. The fiber is finite, so this normalizing sum is finite; its terms are positive, so the sum is nonzero. \(\square\)

This also explains a useful invariance. Replacing \(\gamma_{ij}\) by \(\gamma_{ij}+a_i+b_j\) multiplies every fiber weight by the same factor \(\exp(\sum_i a_iR_i+\sum_j b_jC_j)\). After normalization, the conditional law is unchanged. The information that remains is about interaction contrasts, rather than arbitrary row- or column-additive components of \(\gamma\).

The Two-by-Two Table: Association as a Conditional Parameter

For a two-by-two table, let \(X=N_{11}\), and write the fixed margins as \(R_1,R_2,C_1,C_2\). Every table in the fiber is determined by \(x=X\): \[ n_{11}=x,\quad n_{12}=R_1-x,\quad n_{21}=C_1-x,\quad n_{22}=R_2-C_1+x. \] The feasible integer values satisfy \(\max(0,C_1-R_2)\le x\le \min(R_1,C_1)\). In this case the interaction is summarized by the log cross-product ratio \(\delta=\log(\mu_{11}\mu_{22}/(\mu_{12}\mu_{21}))\); write \(\omega=e^\delta\) for the cross-product ratio.

Result: Conditional on the margins, \(X\) has probability \[ P(X=x\mid R,C)= \frac{\binom{C_1}{x}\binom{C_2}{R_1-x}\omega^x} {\displaystyle\sum_{u=L}^{U}\binom{C_1}{u}\binom{C_2}{R_1-u}\omega^u}, \qquad L=\max(0,C_1-R_2),\quad U=\min(R_1,C_1). \] This is Fisher’s noncentral hypergeometric distribution. When \(\omega=1\), it reduces to the central hypergeometric distribution.

Derivation. Use the loglinear parameterization \(\log\mu_{ij}=\alpha_i+\beta_j+\delta\,\mathbf{1}\{i=1,j=1\}\). Its log cross-product ratio is \(\delta\), because the row and column effects cancel in \(\log\mu_{11}+\log\mu_{22}-\log\mu_{12}-\log\mu_{21}\). The general fixed-margin formula assigns \(x\) a weight proportional to \[ \frac{e^{\delta x}} {x!(R_1-x)!(C_1-x)!(R_2-C_1+x)!}. \] Multiplying this weight by the positive constant \(C_1!C_2!\), which does not depend on \(x\), gives \(\binom{C_1}{x}\binom{C_2}{R_1-x}\omega^x\): indeed \(C_2-R_1+x=R_2-C_1+x\), since both row totals and column totals sum to the same grand total. Normalizing over the feasible \(x\) proves the formula.

A further check makes the role of \(\omega\) explicit. For any adjacent feasible values \(x\) and \(x+1\), the ratio of their conditional probabilities is \[ \frac{P(X=x+1\mid R,C)}{P(X=x\mid R,C)} =\omega\,\frac{(C_1-x)(R_1-x)} {(x+1)(R_2-C_1+x+1)}. \] The factorial terms give the displayed combinatorial ratio, and the interaction contributes the factor \(\omega\). Thus changing the association parameter changes the relative probabilities of tables even though their margins are held fixed. If \(\omega=1\), the interaction contributes no tilt, giving the central hypergeometric law.

Worked Conditional Distributions

Worked Example: Independence with Fixed Margins

Suppose \(R_1=5,\ R_2=7,\ C_1=6,\ C_2=6\). The support of \(X\) is \(0,1,2,3,4,5\). Under independence, \(\omega=1\), so the unnormalized weights are \(\binom{6}{x}\binom{6}{5-x}\).

For \(x=0,1,2,3,4,5\), respectively, the weights are \(6,90,300,300,90,6\). They sum to \(792=\binom{12}{5}\). Therefore the conditional probabilities are those weights divided by 792. For example, if the observed upper-left count is \(x=4\), its conditional probability under independence is \(90/792=5/44\). The margins are fixed in every case; only the allocation within those margins varies.

Worked Example: A Nonzero Association Parameter

Keep the margins from the preceding calculation, but set \(\omega=2\). The unnormalized weights are the independence weights multiplied by \(2^x\). In support order \(x=0,\ldots,5\), these are \(6,\ 180,\ 1200,\ 2400,\ 1440,\ 192\). Their sum is \(5418\), so the conditional probability at \(x=4\) is \(1440/5418=80/301\). This differs from \(5/44\) under independence: conditioning has removed the nuisance main effects, not the association.

Worked Example: Changing Main Effects Without Changing the Conditional Law

Consider mean matrix \[ \begin{pmatrix}6&2\\3&3\end{pmatrix}. \] Its cross-product ratio is \(6\cdot3/(2\cdot3)=3\). Multiply its first row by 2 and its second row by 5, and then multiply its first column by 7 and its second column by \(1/2\). The new mean matrix is \[ \begin{pmatrix}84&2\\105&7.5\end{pmatrix}. \] Its cross-product ratio remains \(84\cdot7.5/(2\cdot105)=3\). These row and column multipliers change the main effects but preserve the interaction contrast. Consequently, for any fixed margins, both mean matrices induce the same conditional law: the formula depends on them through \(\omega=3\) alone. For the margins \(5,7,6,6\) above, the normalizing sum of the noncentral hypergeometric weights is \(19824\), and the probability of \(X=4\) is \(7290/19824=1215/3304\).

What Conditioning Does—and Does Not Do

Fixing both sets of margins gives a conditional likelihood for association that does not require estimating the row and column main effects. It is useful when those effects are nuisance parameters and the scientific question concerns whether, or how strongly, the row and column classifications are associated. The reduction is exact for the stated independent-Poisson model and its fixed-margin conditional distribution; it does not assert that the original counts were sampled with fixed margins.

The two-by-two case makes the distinction especially clear. Under independence, \(\omega=1\), and the conditional distribution is central hypergeometric. Under an alternative association, its weights are tilted by \(\omega^x\). Conditional inference therefore retains information about the cross-product ratio even though the margins themselves are no longer random in the conditional calculation.

Common Mistake

  • Wrong reasoning: “Once the margins are fixed, the conditional distribution must be hypergeometric, so the association parameter disappears.”
  • Correction: Fixing both margins removes the row and column main effects. It does not remove interaction terms: in a two-by-two table, the conditional weights still include \(\omega^x\). The central hypergeometric law follows only when \(\omega=1\).
  • Another pitfall: Conditioning on row totals alone generally leaves column main effects in the conditional law. To cancel both sets of main effects in this two-way model, condition on both row and column margins.
Key takeaway: In an independent-Poisson two-way loglinear model, conditioning on all row and column margins cancels the nuisance main effects. The remaining conditional distribution is determined by interaction contrasts and the factorial weights of the cell counts.

Check Your Understanding

Use the definitions and formulas above to answer these questions.

  1. In the fixed-margin formula, where do the row and column main effects appear before conditioning, and why do they cancel?
  2. For a two-by-two table, identify the feasible support of \(X=N_{11}\) from the four margins.
  3. Why is the central hypergeometric distribution the conditional law under independence, rather than under every Poisson loglinear model?
  4. What happens to the conditional distribution if an interaction contribution is changed by adding a row-only and column-only term?
  5. For the margins \(R_1=5,R_2=7,C_1=6,C_2=6\), what is the conditional probability at \(x=4\) when \(\omega=1\), and how does it compare with the value when \(\omega=2\)?
Clinical Biostats