Tutorials › Generalized Linear Models › Conditional Independence in Three-Way Tables

Poisson Loglinear Models · Tutorial 458 of 981

Conditional Independence in Three-Way Tables

Translate conditional independence into loglinear interaction constraints and derive the fitted cell means for the corresponding Poisson model.

Intermediate 12 min read

What You'll Learn

  • Define conditional independence for two variables within levels of a third
  • Identify the interaction terms that must vanish in the loglinear model
  • Relate conditional independence to rank-one mean tables within each stratum
  • Derive the fitted cell means from observed two-way margins
  • Check conditional independence and fitted counts in numerical examples
  • Avoid confusing a missing pairwise interaction with conditional independence

Conditional Independence Within Strata

A three-way table records two variables of interest, \(A\) and \(B\), alongside a third variable \(C\). Conditional independence asks whether the association between \(A\) and \(B\) disappears when comparisons are made among units with the same value of \(C\). The key is to examine each \(C\)-stratum separately: a pooled table can conceal different patterns across strata.

Let \(A\), \(B\), and \(C\) have \(I\), \(J\), and \(K\) levels, respectively. Write \(p_{ijk}=P(A=i,B=j,C=k)\), and suppose these probabilities are positive. The conditional probability of a cell within stratum \(k\) is \(p_{ij\mid k}=p_{ijk}/p_{++k}\), where \(p_{++k}=\sum_{i,j}p_{ijk}\).

Definition: \(A\) and \(B\) are conditionally independent given \(C\), written \(A\perp B\mid C\), if for every \(i,j,k\), $$ p_{ij\mid k}=p_{i\mid k}p_{j\mid k}. $$ Equivalently, within every stratum \(k\), the conditional joint distribution factors into the product of its two conditional marginal distributions.

For positive cell probabilities, an equivalent diagnostic is that every conditional odds ratio equals one. For levels \(i,i'\) of \(A\) and \(j,j'\) of \(B\), the conditional odds ratio in stratum \(k\) is \(\{p_{ijk}p_{i'j'k}\}/\{p_{ij'k}p_{i'jk}\}\). Independence requires this ratio to be one for all choices of levels and all strata.

Which Loglinear Interactions Must Vanish?

Let \(Y_{ijk}\) be independent Poisson cell counts with means \(\mu_{ijk}>0\). The saturated three-way loglinear representation, using the usual zero-sum constraints on effects, is

$$ \log \mu_{ijk} =\lambda+\lambda_i^A+\lambda_j^B+\lambda_k^C +\lambda_{ij}^{AB}+\lambda_{ik}^{AC}+\lambda_{jk}^{BC} +\lambda_{ijk}^{ABC}. $$

To see which terms express association between \(A\) and \(B\) within a fixed \(C\)-stratum, take a log cross-product ratio:

$$ \log\frac{\mu_{ijk}\mu_{i'j'k}}{\mu_{ij'k}\mu_{i'jk}} = \left(\lambda_{ij}^{AB}+\lambda_{i'j'}^{AB} -\lambda_{ij'}^{AB}-\lambda_{i'j}^{AB}\right) + \left(\lambda_{ijk}^{ABC}+\lambda_{i'j'k}^{ABC} -\lambda_{ij'k}^{ABC}-\lambda_{i'jk}^{ABC}\right). $$

The main effects and the \(AC\) and \(BC\) interactions cancel. Thus the conditional association can involve both the \(AB\) interaction and the \(ABC\) interaction. In particular, removing only the \(AB\) term does not generally make every within-stratum odds ratio equal to one: a three-factor term can still make those odds ratios vary with \(k\).

Theorem: In the saturated loglinear representation with zero-sum constraints, \(A\perp B\mid C\) holds if and only if both the \(AB\) and \(ABC\) interaction terms are zero. The corresponding conditional-independence loglinear model is $$ \log \mu_{ijk} =\lambda+\lambda_i^A+\lambda_j^B+\lambda_k^C +\lambda_{ik}^{AC}+\lambda_{jk}^{BC}. $$

Proof. If both interaction terms are zero, the displayed cross-product ratio is one for every \(i,i',j,j',k\). For positive probabilities, all such cross-product ratios being one implies that each conditional probability matrix has rank one and factors into its row and column margins. Hence \(A\perp B\mid C\).

Conversely, conditional independence makes every displayed log cross-product ratio zero. Fix \(i,i',j,j'\), and denote the \(AB\) contrast in parentheses by \(a\), and the \(ABC\) contrast in stratum \(k\) by \(b_k\). Then \(a+b_k=0\) for every \(k\). Under the zero-sum constraints, \(\sum_k b_k=0\). Summing \(a+b_k=0\) over the \(K\) strata gives \(Ka=0\), so \(a=0\), and then \(b_k=0\) for every \(k\). As this holds for every choice of levels, all \(AB\) and \(ABC\) interaction contrasts vanish, and therefore those interaction terms are zero. \(\square\)

The model is often denoted \([AC][BC]\): it retains the association of \(A\) with \(C\) and of \(B\) with \(C\), while excluding the two terms that together express conditional association between \(A\) and \(B\). It does not require \(A\) or \(B\) to be independent of \(C\).

Worked Example: Checking Independence in Each Stratum

Suppose a positive three-way distribution has the following two-by-two conditional probability matrices for \(C=1\) and \(C=2\):

$$ P(A,B\mid C=1)= \begin{pmatrix}0.30&0.20\\0.30&0.20\end{pmatrix}, \qquad P(A,B\mid C=2)= \begin{pmatrix}0.10&0.20\\0.20&0.50\end{pmatrix}. $$

In stratum 1, the row margins are \(0.50,0.50\) and the column margins are \(0.60,0.40\). Their products give the displayed cells: for example, \(0.50(0.60)=0.30\), and \(0.50(0.40)=0.20\). Thus the matrix factors and \(A\) and \(B\) are independent in that stratum.

In stratum 2, the row margins are \(0.30,0.70\) and the column margins are \(0.30,0.70\). The first cell under independence would be \(0.30(0.30)=0.09\), not \(0.10\). Equivalently, its odds ratio is \((0.10)(0.50)/\{(0.20)(0.20)\}=1.25\), not one. Independence fails in stratum 2, so \(A\perp B\mid C\) does not hold overall.

Fitted Means Under Conditional Independence

Let \(y_{ijk}\) denote the observed count in cell \((i,j,k)\). Define the observed two-way margins within each \(C\)-stratum by \(y_{i+k}=\sum_j y_{ijk}\), \(y_{+jk}=\sum_i y_{ijk}\), and \(y_{++k}=\sum_{i,j}y_{ijk}\). In the conditional-independence model, the fitted mean table within each stratum has rank one. Its fitted row and column margins match the corresponding observed margins.

Theorem: If \(y_{++k}>0\) for every stratum and the conditional-independence model has a finite maximum-likelihood estimate, its fitted cell means are $$ \hat{\mu}_{ijk}=\frac{y_{i+k}y_{+jk}}{y_{++k}}. $$ If a row or column margin is zero, this formula gives fitted means of zero in that row or column, interpreted as a boundary fit. An empty stratum has all fitted means zero at the likelihood supremum; the displayed ratio is then undefined.

Derivation. Within stratum \(k\), the model has \(\log\mu_{ijk}=r_{ik}+s_{jk}\) for suitable real parameters \(r_{ik}\) and \(s_{jk}\). The log-likelihood contribution, up to terms not depending on the means, is \(\sum_{i,j}(y_{ijk}\log\mu_{ijk}-\mu_{ijk})\). Differentiating with respect to \(r_{ik}\) gives the score equation

$$ \frac{\partial\ell}{\partial r_{ik}}=\sum_j(y_{ijk}-\mu_{ijk})=0, \qquad \frac{\partial\ell}{\partial s_{jk}}=\sum_i(y_{ijk}-\mu_{ijk})=0. $$

So, at a finite maximum, the fitted row and column margins equal \(y_{i+k}\) and \(y_{+jk}\). The model form also implies \(\hat{\mu}_{ijk}=u_{ik}v_{jk}\) for positive factors \(u_{ik},v_{jk}\). Let \(M_k=\sum_{i,j}\hat{\mu}_{ijk}\). The fitted row margin is \(u_{ik}\sum_jv_{jk}\), and the fitted column margin is \(v_{jk}\sum_i u_{ik}\). Their product divided by \(M_k=(\sum_i u_{ik})(\sum_j v_{jk})\) equals \(u_{ik}v_{jk}=\hat{\mu}_{ijk}\). Since the fitted margins equal the observed margins, the claimed formula follows.

For completeness, the formula is not just a necessary score condition. It defines a nonnegative rank-one table with exactly the observed row and column margins, so it belongs to the model and satisfies the score equations whenever margins are positive. The Poisson log-likelihood is concave in the loglinear parameters; consequently a stationary point is a global maximum. The fitted means are therefore the stated maximum-likelihood fit. Zero margins follow by taking the corresponding fitted row or column to zero, giving the boundary version of the same result. \(\square\)

Worked Example: Computing Fitted Counts Within One Stratum

For \(C=1\), suppose the observed table is

$$ \begin{pmatrix}8&12\\12&18\end{pmatrix}. $$

The row margins are \(20\) and \(30\); the column margins are \(20\) and \(30\); and the total is \(50\). The fitted counts under conditional independence are

$$ \begin{pmatrix} 20(20)/50&20(30)/50\\ 30(20)/50&30(30)/50 \end{pmatrix} = \begin{pmatrix}8&12\\12&18\end{pmatrix}. $$

The observed table already factors: its odds ratio is \(8(18)/\{12(12)\}=1\). The calculation also checks the margin property: the fitted first row sums to \(8+12=20\), and the fitted first column sums to \(8+12=20\).

Worked Example: Fitting a Nonindependent Observed Table

For a different stratum, suppose the observed counts are

$$ \begin{pmatrix}10&20\\30&40\end{pmatrix}. $$

The row margins are \(30,70\), the column margins are \(40,60\), and the total is \(100\). The conditional-independence fit is

$$ \begin{pmatrix} 30(40)/100&30(60)/100\\ 70(40)/100&70(60)/100 \end{pmatrix} = \begin{pmatrix}12&18\\28&42\end{pmatrix}. $$

Each fitted row and column margin matches the observed one: the fitted row totals are \(30,70\), and the fitted column totals are \(40,60\). The fitted odds ratio is \(12(42)/\{18(28)\}=1\), as required by the model. The observed odds ratio is \(10(40)/\{20(30)\}=2/3\); this observed association is not retained in the fitted conditional-independence table.

Why the Distinction Matters

The stratum-by-stratum factorization gives a direct interpretation of the model: for each \(k\), the expected count in a cell is the row margin times the column margin divided by the stratum total. Associations of \(A\) with \(C\), or of \(B\) with \(C\), can still be present because the margins may change from one stratum to another. The model only rules out association between \(A\) and \(B\) after conditioning on \(C\).

Worked Example: Why Omitting Only the Pairwise Term Is Not Enough

Consider positive mean tables in two equally weighted \(C\)-strata:

$$ \mu_{\cdot\cdot 1}= \begin{pmatrix}2&1\\1&1\end{pmatrix}, \qquad \mu_{\cdot\cdot 2}= \begin{pmatrix}1&2\\2&2\end{pmatrix}. $$

The conditional odds ratio in stratum 1 is \(2(1)/(1(1))=2\). In stratum 2 it is \(1(2)/(2(2))=1/2\). Neither stratum has independence. Yet the average of the two log odds ratios is \(\{\log 2+\log(1/2)\}/2=0\). In a two-level, zero-sum effect decomposition, this makes the common \(AB\) contrast zero, while the stratum-specific departures are represented by the \(ABC\) interaction. Thus setting the \(AB\) term to zero alone does not establish \(A\perp B\mid C\); the three-factor interaction must also be absent.

Common Mistake

  • Wrong reasoning: “The \(AB\) interaction is absent, so \(A\) and \(B\) are conditionally independent given \(C\).” This overlooks that the \(ABC\) term can produce a nonzero \(AB\) association within a particular stratum.
  • Correction: Conditional independence requires every within-stratum \(AB\) log odds ratio to be zero. In the saturated loglinear parameterization, that requires both the \(AB\) and \(ABC\) interactions to vanish.
  • Another warning: Do not infer conditional independence from an overall two-way table alone. The conditional odds ratios may differ across \(C\)-strata, including having different directions of association.
Key takeaway: The three-way conditional-independence model is \([AC][BC]\). Its fitted mean table factors within each stratum, with \(\hat{\mu}_{ijk}=y_{i+k}y_{+jk}/y_{++k}\) when the stratum total is positive.

Check Your Understanding

Use the definitions and fitted-mean result to answer the following questions.

  1. State conditional independence of \(A\) and \(B\) given \(C\) using conditional probabilities.
  2. In the saturated loglinear representation, which two interaction terms must be zero for \(A\perp B\mid C\)?
  3. A stratum has row margins \(15,25\), column margins \(10,30\), and total \(40\). What is the fitted count in the cell at the intersection of the first row and first column?
  4. Why can a model with no \(AB\) term still have nonzero conditional odds ratios?
  5. What margin-matching property should you check after computing fitted counts within a stratum?
Clinical Biostats