Tutorials › Generalized Linear Models › Hierarchical Loglinear Models and Generating Classes

Poisson Loglinear Models · Tutorial 460 of 981

Hierarchical Loglinear Models and Generating Classes

Learn to read, construct, and check hierarchical loglinear models using their interaction terms and maximal generating classes.

Intermediate 12 min read

What You'll Learn

  • Define hierarchical loglinear models as downward-closed collections of interaction terms.
  • Identify generating classes as the maximal included sets of factors.
  • Recover all included interactions from a model’s generating classes.
  • Check proposed term sets using the hierarchy principle.
  • Relate hierarchical models to products of functions over their generating classes.
  • Count model parameters in reference-cell coding.

Interactions as Sets of Factors

A loglinear model describes the expected counts in a contingency table through the log of each cell mean. Its interaction terms indicate which combinations of factors are allowed to contribute to that log mean. The central organizing rule here is the hierarchy principle: when a model includes an interaction among several factors, it must also include every lower-order interaction among subsets of those factors.

Let a table have \(p\) categorical factors, \(X_1,\ldots,X_p\). Factor \(X_j\) has \(r_j\) levels, and a cell is indexed by \(x=(x_1,\ldots,x_p)\). Write \(\mu(x)>0\) for its expected count and \(\ell(x)=\log\mu(x)\). A subset \(S\subseteq\{1,\ldots,p\}\) indexes an interaction among the factors in \(S\); the empty set indexes the intercept. For example, \(S=\{1,3\}\) indexes the \(X_1X_3\) interaction.

For clarity, use reference-cell coding: choose one reference level for each factor, and represent a term \(\lambda_S(x_S)\) so it is zero whenever any factor in \(S\) is at its reference level. With this coding, the interaction terms are identifiable, and including or excluding a term has a precise meaning. A loglinear model specifies a collection \(\mathcal M\) of included subsets and writes

$$ \log\mu(x)=\sum_{S\in\mathcal M}\lambda_S(x_S). $$

The intercept, indexed by the empty set, is included in the models discussed here. Excluding a nonempty \(S\) means its term is fixed at zero; including it allows its reference-coded coefficients to vary.

Definition: A loglinear model is hierarchical if its collection of included subsets is downward closed: whenever \(S\in\mathcal M\), every subset \(T\subseteq S\) is also in \(\mathcal M\). Thus, including a three-factor interaction requires including its three two-factor interactions, its three main effects, and the intercept.

The hierarchy principle concerns which terms belong to the model, not which estimated coefficients happen to be numerically nonzero. A model may include an interaction whose fitted coefficient is zero; that does not remove the term from the model.

Generating Classes

A hierarchical model can be specified compactly by listing only its largest included sets. These are called its generating classes. “Largest” means maximal under set inclusion: a generating class is included, and it is not a proper subset of any other included set. A set can have several incomparable maximal supersets, so a model may have several generating classes.

Definition: The generating classes of a hierarchical loglinear model are the maximal members of its collection \(\mathcal M\). The notation \([AB,AC]\), for example, means the hierarchical model generated by the sets \(\{A,B\}\) and \(\{A,C\}\): it includes those sets and all their subsets.

The notation is a shorthand for the full term list. Under \([AB,AC]\), the included sets are \(\varnothing,A,B,C,AB,AC\); the model excludes \(BC\) and \(ABC\). The hierarchy rule requires the subsets of each generator, not every subset of all factors in the table.

Worked Example: Three-Factor Homogeneous Association

Consider three binary factors \(A,B,C\), each coded 0 or 1, with reference level 0. The model \([AB,AC,BC]\) has all three pairwise interactions as generating classes. Its included term list is \(\varnothing,A,B,C,AB,AC,BC\), and it excludes \(ABC\).

For a concrete log-mean model, set

$$ \log\mu(a,b,c)=\log 10+0.2a+0.3b+0.4c+0.5ab+0.1ac-0.2bc. $$

At cell \((0,0,0)\), all non-intercept terms vanish, so \(\mu(0,0,0)=\exp(\log 10)=10\). At \((1,1,0)\), the non-intercept terms sum to \(0.2+0.3+0.5=1\), giving \(\mu(1,1,0)=10e^1\). At \((1,1,1)\), they sum to \(0.2+0.3+0.4+0.5+0.1-0.2=1.3\), giving \(\mu(1,1,1)=10e^{1.3}\). The absence of an \(ABC\) term is what distinguishes this model from the saturated three-factor model.

Worked Example: A Four-Factor Model from Its Generators

For four binary factors \(A,B,C,D\), take generating classes \([AB,BC,CD]\). Their subsets give the included terms \(\varnothing,A,B,C,D,AB,BC,CD\). In particular, \(AC\), \(AD\), \(BD\), \(ABC\), and \(ABCD\) are not included.

One possible log-mean specification is

$$ \log\mu(a,b,c,d)=\log 5+0.2a+0.1b-0.1c+0.3d+0.4ab-0.2bc+0.5cd. $$

At \((1,0,1,0)\), the included main-effect contributions sum to \(0.2-0.1=0.1\), and all three included pair terms vanish. Therefore \(\mu(1,0,1,0)=5e^{0.1}\). At \((1,1,1,1)\), the main effects sum to \(0.2+0.1-0.1+0.3=0.5\), and the pair terms sum to \(0.4-0.2+0.5=0.7\). Thus \(\mu(1,1,1,1)=5e^{1.2}\). The numerical values illustrate a model specification; they do not change which terms are included.

Why the Generators Determine the Model

In a finite collection of factor subsets, every included set lies inside at least one maximal included set: if a set is not maximal, move to a strictly larger included set, and this process must stop because there are only finitely many subsets. Downward closure then guarantees that every subset of each maximal set is included. Conversely, every subset of a generator is included by definition of the model generated by it. This gives the following result.

Theorem: A hierarchical model with generating classes \(\mathcal C\) has included collection \(\mathcal M=\{S:S\subseteq C\text{ for at least one }C\in\mathcal C\}\). The generating classes are uniquely determined by \(\mathcal M\).

Proof. First, take any \(S\in\mathcal M\). Since the collection is finite, there is a maximal included set \(C\) containing \(S\). Thus \(S\) is a subset of a generating class. In the other direction, if \(S\subseteq C\) for a generating class \(C\), downward closure gives \(S\in\mathcal M\). These two implications establish the stated description of \(\mathcal M\).

For uniqueness, the generating classes must be exactly the maximal members of \(\mathcal M\). A maximal member cannot be omitted from that list, and a nonmaximal member is contained in a larger included set, so it cannot be a generating class. Hence no different list of maximal sets generates the same collection. \(\square\)

A second useful characterization expresses the model as a product over its generators. This links the interaction-set description to the way a log mean can be assembled from functions of subsets of factors. It is a statement about the form of the mean, not by itself a claim of independence.

Theorem: For a hierarchical loglinear model with generating classes \(\mathcal C\), its positive mean functions can be written as \(\mu(x)=\prod_{C\in\mathcal C}\phi_C(x_C)\), where each \(\phi_C\) is a positive function of the factors in \(C\). Conversely, any positive mean function with such a product representation belongs to that hierarchical model.

Proof. If the model contains only terms indexed by subsets of generating classes, assign each included term to one generating class containing its index. Group the assigned terms for each \(C\) into a function \(\psi_C(x_C)\). Then \(\log\mu(x)=\sum_{C\in\mathcal C}\psi_C(x_C)\), so taking \(\phi_C(x_C)=\exp\{\psi_C(x_C)\}\) gives the required product.

For the converse, suppose \(\mu(x)=\prod_{C\in\mathcal C}\phi_C(x_C)\), with every \(\phi_C\) positive. Taking logarithms gives \(\log\mu(x)=\sum_C\log\phi_C(x_C)\). A function of the factors in \(C\) has a reference-coded expansion using only terms indexed by subsets of \(C\). To see why, for any function \(g(x_C)\), start with its value when all factors are at reference levels as the intercept. For each nonempty subset \(S\subseteq C\), define its term recursively as the value of \(g\) with factors in \(S\) set to their specified levels and other factors at reference, minus the terms already assigned to proper subsets of \(S\). This construction recovers \(g\) by summing its terms and gives zero for a term when any factor in it is at its reference level. Applying it to each \(\log\phi_C\) produces only terms contained in a generator. All such terms are in the hierarchical model, proving the converse. \(\square\)

Applying the Hierarchy Principle

To check whether a proposed interaction list defines a hierarchical model, test each included set against all of its subsets. The check is especially important when a model is described by a list of selected terms rather than by generating classes.

1
Write each term as a factor set.
For example, \(ABC\) represents \(\{A,B,C\}\), not three separate terms.
2
List its subsets.
For \(ABC\), check \(AB,AC,BC,A,B,C\), and the intercept.
3
Check inclusion.
If any subset is absent, the proposed term collection is not hierarchical.
4
State the maximal sets.
Once the collection passes the check, report its generating classes without listing every implied lower-order term.

Worked Example: Correcting a Nonhierarchical Term List

For three binary factors with reference level 0, consider the proposed log mean

$$ \log\mu(a,b,c)=\log 2+0.1a+0.2b+0.3c+0.4ab+0.5bc+0.6abc. $$

The list includes \(ABC\), so hierarchy requires \(AB\), \(AC\), \(BC\), \(A\), \(B\), \(C\), and the intercept. The list omits \(AC\), and is therefore not hierarchical. For a numerical check of the specified expression, at \((1,1,1)\) its non-intercept terms sum to \(0.1+0.2+0.3+0.4+0.5+0.6=2.1\), so it gives \(\mu(1,1,1)=2e^{2.1}\). That calculation does not repair the missing interaction.

There are two straightforward hierarchical alternatives, depending on the intended model. To keep \(ABC\), add the missing \(AC\) term; the resulting model is generated by \([ABC]\). To exclude \(ABC\), retain \(AB\) and \(BC\) as the largest terms and omit the three-factor term; the resulting model is generated by \([AB,BC]\). The choice is substantive: these are different model specifications.

Why Hierarchy Matters

Generating classes make model structure easier to state and audit. Instead of listing every main effect and lower-order interaction, a compact specification such as \([AB,AC]\) immediately tells the reader which interactions are available. It also prevents an invalid term list from being mistaken for an ordinary hierarchical loglinear model.

In reference-cell coding, the number of free coefficients gives another check on a specification. For a hierarchical model, the dimension is the sum, over included sets \(S\), of \(\prod_{j\in S}(r_j-1)\), where the empty-set product is 1. Each factor contributes \(r_j-1\) nonreference contrasts, so an interaction among \(S\) has that many coefficients. In the three-factor binary example \([AB,AC,BC]\), there are seven included terms, each contributing one coefficient, hence seven free coefficients. The saturated binary three-factor model has eight terms and eight free coefficients, including \(ABC\).

A common mistake is to think that a large interaction can be included on its own because the lower-order coefficients are estimated as zero or are not of interest. That reasoning confuses coefficient values with model membership. If a three-factor interaction is included, its lower-order terms must also be included in a hierarchical model; their estimates may be zero, but they remain part of the model. Conversely, a generating class lists only the maximal terms, not the complete set of included terms.

Key takeaway: A hierarchical loglinear model is a downward-closed collection of interaction sets. Its unique generating classes are its maximal included sets, and the model contains exactly the subsets of those classes.

Check Your Understanding

Use the hierarchy principle and generating-class notation to answer the following.

  1. For the model \([AB,AC]\), list every included term and name two terms that are excluded.
  2. A proposed four-factor model includes \(ABCD\), \(ABC\), \(ABD\), \(ACD\), and \(BCD\), but omits \(AC\). Is it hierarchical? Explain.
  3. What are the generating classes of a model whose included sets are \(\varnothing,A,B,C,AB,BC\)?
  4. For a three-factor binary table, how many free coefficients are in the model \([AB,AC,BC]\) under reference-cell coding?
  5. Explain why a fitted value of zero for a lower-order interaction coefficient does not mean that the term is absent from a model.
Clinical Biostats