Bayesian Selection of Log-Linear Models

Python · R · Part 4 of the variable-selection arc — categorical data

Overview

Part 4 of the variable-selection arc: selection for categorical data. Variable selection for a contingency table means choosing which associations belong in a log-linear model. Albert (1996) brought the Bayesian selection machinery to this setting — model the cell counts as Poisson with a log-linear mean, place robust heavy-tailed priors on the interaction terms, and compare models by marginal likelihood, so the data (not the prior's tails) decide which associations are real. The showcase is the Berkeley graduate-admissions table (4,526 applicants cross-classified by admission, gender, and department A–F): aggregated, men are admitted at a higher rate than women — apparent bias. The log-linear selection asks the precise question — is there a direct admission–gender association, once department is accounted for? — posing Simpson's paradox as model selection.

logE[y]=μ+A+G+D+(AG)+(AD)+(GD)pairwise associations+(AGD)three-way\log \mathbb E[y] = \mu + A + G + D + \underbrace{(AG) + (AD) + (GD)}_{\text{pairwise associations}} + \underbrace{(AGD)}_{\text{three-way}}

Poisson log-linear models, robust priors, Laplace evidence

The 24 cell counts are independent Poisson with a log-linear mean over the factors admit (AA), gender (GG), department (DD): main effects plus the pairwise associations (AG),(AD),(GD)(AG),(AD),(GD) and the three-way (AGD)(AGD). Main effects are always present — they only fix the marginal totals — so selection is over the interaction terms, which are the associations. Keeping models hierarchical (a term enters only with all its lower-order relatives) leaves nine candidates, from mutual independence [A][G][D][A][G][D] to the saturated [AGD][AGD]; the key contrast is [AD][GD][AD][GD] — admission and gender conditionally independent given department — versus [AG][AD][GD][AG][AD][GD], which adds a direct admission–gender link. Each model's evidence is computed by a Laplace approximation around the Poisson-GLM fit (logH\log|H| from the Fisher information H=Xdiag(μ^)XH=X'\,\mathrm{diag}(\hat\mu)\,X). Albert's robustness comes from the prior: diffuse normals on the intercept and main effects, but a heavy-tailed Cauchy(0, 1) on the interaction coefficients being tested — so a genuine association is not shrunk away, and a spurious one is not kept on the strength of prior tails. A uniform prior over the nine models gives posterior model probabilities and association inclusion probabilities. Engine: a self-contained loglinsel.py.

Results

The conditional-independence model wins outright. [AD][GD][AD][GD] — admission depends on department, application patterns depend on department, but admission and gender are conditionally independent given department — carries 90% of the posterior; adding the direct admission–gender term actually lowers the evidence. Quantified: Admit:Dept and Gender:Dept have inclusion probability 1.00 (departments differ sharply in selectivity, and men and women apply to different departments), but Admit:Gender sits at 0.10 and the three-way term is essentially absent (0.002). Simpson's paradox, resolved: the raw aggregate gap disappears within department — women simply applied more to the competitive departments — and the selection encodes exactly this (drop AGAG, keep ADAD and GDGD). The near-zero inclusion of Admit:Gender is robust by design: the Cauchy prior means it is a statement about the data, not a tight prior shrinking it — a genuine association of that size would still have been detected. Exact enumeration with Laplace marginal likelihoods and a PyMC group-SSVS (an on/off indicator per interaction block) agree. Here "which predictors matter" becomes "which associations are present in the table" — the same spike-and-slab / marginal-likelihood logic as Parts 1–3, over the interactions of a log-linear model.

Notebooks

Downloads

References