AI Glossary / Statistics and probability / Intermediate
Hierarchical log-linear model
Definition
A hierarchical log-linear model describes expected counts in a contingency table through a linear model for their logarithms, with a hierarchy rule for included terms. Whenever an interaction is included, all its lower-order component interactions and main effects are included too. The hierarchy concerns the structure of terms, not necessarily people nested within organizations or a Bayesian prior hierarchy.
What it means
A table can classify each observation by several categorical variables, such as service channel, request type, and resolution status. A log-linear model describes how frequently their combinations occur.
Main effects represent differences associated with individual classifications, while interaction terms represent associations among classifications. The hierarchy rule keeps the model structurally coherent: a three-variable interaction requires all three pairwise interactions as well as the three main effects.
How it works
Let m_ijk be the expected count for a combination of three categorical variables A, B, and C. A saturated model includes an intercept, their main effects, all pairwise interactions, and the three-way interaction in log(m_ijk). Constraints or reference-category coding identify its parameters.
A hierarchical submodel omits selected interactions while retaining all terms required by interactions that remain. For example, the model written [AB][AC] includes A, B, C, AB, and AC, but excludes BC and ABC. Under the usual positive-cell formulation, it represents independence of B and C conditional on A.
The notation lists maximal terms: smaller required terms are implicit. By contrast, [AB][AC][BC] includes every pairwise interaction but no three-way interaction. It generally does not assert that any pair is conditionally independent; for a three-way binary table, it allows pairwise odds ratios that remain constant across levels of the third variable.
Counts are commonly fitted through a Poisson log-link model or by methods appropriate to a fixed-total multinomial sampling scheme. Iterative proportional fitting can estimate hierarchical models by matching their specified margins. The observed counts themselves are not simply logged and passed to ordinary least squares.
Check whether zeros are sampling zeros or structural zeros. A sampling zero is a possible combination that was not observed. A structural zero represents an impossible combination and changes the sample space and potentially the degrees of freedom. Software may require explicit instructions to preserve it.
Assess fit with residuals and suitable likelihood-based or Pearson comparisons, while checking whether sparse cells undermine asymptotic approximations. Compare nested models using the correct parameter difference and sampling assumptions; adding interactions always improves or preserves fitted likelihood but may overfit.
Interpret associations in terms of expected counts, conditional independence, or odds ratios. Main-effect coefficients can depend on coding and on included interactions. A statistical association in a contingency table does not establish a causal pathway.
Three practical examples
- A support team models joint counts by channel, request category, and resolution outcome.
- An AI evaluator examines whether error type and task category remain associated after conditioning on language.
- A survey analyst investigates patterns across several categorical responses without initially designating one as the sole dependent variable.
Think of it this way
Think of building a structure with upper levels supported by all their required lower levels. Including a three-way interaction while removing one of its component pairwise terms breaks the hierarchy rule, even if software can fit some nonhierarchical specification.
Worked example
Take binary variables A, B, and C coded 0 or 1. Define illustrative expected counts by m_abc = 10 x 2^a x 3^b x 4^c x 2^(ab) x 3^(ac).
Taking logarithms yields an intercept log(10), three main effects, an AB term, and an AC term. There is no BC or ABC term, so this is the hierarchical model [AB][AC].
For A = 0, the expected counts across B,C combinations (0,0), (0,1), (1,0), and (1,1) are 10, 40, 30, and 120. The B-C conditional odds ratio is (10 x 120)/(40 x 30) = 1.
For A = 1, the corresponding counts are 20, 240, 120, and 1,440. The B-C conditional odds ratio is (20 x 1,440)/(240 x 120) = 1 again. This matches conditional independence of B and C given A.
The A-B conditional odds ratio is 2 at either value of C: for C = 0 it is (10 x 120)/(30 x 20) = 2. Thus conditional independence of one pair does not mean all variables are mutually independent. These are stipulated expected counts demonstrating the model structure, not observed data or a completed significance test.
Illustrative case study
Fictional case: Juniper Service collects counts by support channel, issue category, and resolution status. Its analyst proposes several hierarchical models to distinguish broad associations from channel-specific patterns.
The team discovers that one channel cannot process a particular issue category. That combination is a structural zero, so it revises the table specification instead of treating the zero as an ordinary missing event. It also checks whether repeated requests from the same customer violate the assumed sampling structure.
After comparing fit and interpretability, Juniper reports which associations the selected model retains, with uncertainty and sparse-cell limitations. Managers use the analysis to design follow-up investigation rather than claiming the table proves that changing channels causes better resolution.
Common misconceptions and mistakes
Avoid interpreting hierarchical as automatically multilevel, retaining a high-order term while deleting required lower-order terms, or mistaking [AB][AC][BC] for mutual independence.
Other mistakes include logging zero counts directly, overlooking structural zeros, and treating a nonsignificant goodness-of-fit test as proof of the model. The supplied seed definition mentions main effects; the full hierarchy also requires component interactions below higher-order terms.
Business use
These models can simplify multidimensional categorical patterns and make conditional-association assumptions explicit. Business users benefit from a clear table definition, intelligible odds ratios, and a record of excluded interactions. The number of possible cells grows rapidly, so data adequacy should guide model complexity.
People also ask
Must there be a single outcome variable?
No. A log-linear contingency-table model describes the joint count structure.
Does including AB require A and B?
Yes.
Does including ABC require AB, AC, and BC?
Yes, along with the main effects, for a hierarchical model.
Check your understanding
Which interactions appear in [AB][AC]?
Answer: AB and AC, with their required main effects.
What is the B-C odds ratio within each A stratum in the example?
Answer: One.
Does that imply complete independence of A, B, and C?
Answer: No; A-B association remains.
Related terms
- Contingency table
- Poisson regression
- Conditional independence
- Odds ratio
- Saturated model
- interaction
- iterative proportional fitting
- structural zero
Learn next
Start with two-way independence models, then compare [A][B][C], [AB][AC], and [AB][AC][BC]. Translate each model's restrictions into a precise statement about associations before interpreting fitted coefficients.
More in Statistics and probability
- Heteroskedasticity-consistent standard errors - Heteroskedasticity-consistent standard errors estimate regression-coefficient uncertainty while allowing error variance to differ across observations.
- Hidden Markov model - A Hidden Markov model (HMM) is a probabilistic model for a sequence of observations generated by an unobserved sequence of states.
- Hierarchical (sequential) sums of squares - Hierarchical (sequential) sums of squares measure how much residual squared error decreases as terms enter a linear model in a specified order.
- High-dimensional statistics - High-dimensional statistics studies estimation, prediction, and inference when the number of variables or model parameters is large relative to the...
- High frequency data - High frequency data are observations recorded at short time intervals relative to the process being studied.
- Higher order interaction - A higher order interaction is a statistical interaction involving three or more predictors or factors.
Sources
David Howell, glossary: https://www.uvm.edu/~statdhtx/methods8/Glossary/Glossary.html R stats, fitting log-linear models: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/loglin.html Ronald Christensen, Log-Linear Models and Logistic Regression, university-hosted text: https://www.stat.cmu.edu/~brian/valerie/617-2022/0%20-%20books/1997_Book_Log-LinearModelsAndLogisticReg.pdf
Previous: Hierarchical Language Model Next: Hierarchical lookahead