Log-Linear Model
Study guide: Exam MAS-I
A Log-Linear Model is a Poisson regression for the counts in a contingency table, in which the logarithm of each cell's expected count is a sum of effects of the classifying variables and their interactions. In a table with I rows and J columns, the independence model for the expected count \mu_{ij} in row i and column j is
\ln \mu_{ij} = \beta_0 + \alpha_i + \gamma_j
\beta_0is the intercept.\alpha_iis the effect of rowiand\gamma_jis the effect of columnj, each set to 0 at a reference level.
This model has I + J - 1 parameters. It says the row and column variables are independent, and its fitted count in each cell is
\hat\mu_{ij} = \frac{y_{i\cdot}\, y_{\cdot j}}{n}
y_{i\cdot}is the total of rowiandy_{\cdot j}is the total of columnj.nis the grand total of the observed countsy_{ij}.
The cell counts may be independent Poisson variables, or multinomial with the grand total fixed. Conditioning independent Poisson counts on their total gives the multinomial distribution, so the Poisson log-linear model gives the same fitted counts and tests under either.
600 closed claims are classified by whether they were litigated and whether they were large. What are the fitted counts under the independence model? The observed counts are:
Large Not large Total Litigated 24 76 100 Not litigated 66 434 500 Total 90 510 600
- Each fitted count is the row total times the column total, divided by 600.
- The litigated row gets
100 \times 90/600 = 15and100 \times 510/600 = 85.- The not-litigated row gets
500 \times 90/600 = 75and500 \times 510/600 = 425.
Testing a log-linear model
The deviance of a log-linear model measures its lack of fit against the saturated model, which has one parameter per cell and deviance 0. The deviance is
D = 2 \sum_{i,j} y_{ij} \ln\!\left(\frac{y_{ij}}{\hat\mu_{ij}}\right)
and Pearson's chi-square statistic is
X^2 = \sum_{i,j} \frac{(y_{ij} - \hat\mu_{ij})^2}{\hat\mu_{ij}}
Each is approximately chi-squared with degrees of freedom equal to the number of cells less the number of parameters. For the independence model this is IJ - (I + J - 1) = (I-1)(J-1). A statistic below the critical value means the model fits.
In the claims table above, is litigation independent of claim size at the
5\%significance level?
- The deviance is
2(11.280 - 8.506 - 8.437 + 9.095) = 6.86.- Each cell differs from its fitted count by 9, so
X^2 = \frac{81}{15} + \frac{81}{85} + \frac{81}{75} + \frac{81}{425} = 7.62.- There are
(2-1)(2-1) = 1degree of freedom, with critical value3.841.- Both statistics exceed
3.841, so independence is rejected. Litigation and claim size are associated.
The saturated model
Adding the interaction gives the saturated model, which reproduces every count exactly:
\ln \mu_{ij} = \beta_0 + \alpha_i + \gamma_j + (\alpha\gamma)_{ij}
(\alpha\gamma)_{ij}is the interaction of rowiand columnj, set to 0 when either is at its reference level.
Each cell's fitted value is the sum of the parameters that apply to it, so with two binary variables each of the four cells has its own mean.
In the claims table, with "not litigated" and "not large" as the reference levels, what is the interaction term of the saturated model?
- The reference cell gives
\beta_0 = \ln 434.- The litigated, not-large cell gives
\alpha_{\text{lit}} = \ln(76/434), and the not-litigated, large cell gives\gamma_{\text{large}} = \ln(66/434).- The litigated, large cell gives
\ln 24 = \beta_0 + \alpha_{\text{lit}} + \gamma_{\text{large}} + (\alpha\gamma).- Solving,
(\alpha\gamma) = \ln\frac{24 \times 434}{76 \times 66} = \ln 2.077 = 0.731, the log of the odds ratio of the table.
Three-way tables
With three classifying variables A, B and C, terms are added hierarchically, and each model says which variables are independent:
| Model | Meaning |
|---|---|
A + B + C |
All three variables are mutually independent. |
AB + C |
A and B are associated, and the pair (A, B) is independent of C. |
AB + BC |
A and C are independent given B. |
AB + AC + BC |
Each pair is associated, with no three-factor interaction. |
ABC |
The saturated model. |
Two nested models are compared by the drop in deviance, which is chi-squared with degrees of freedom equal to the difference in their degrees of freedom (likelihood ratio test).
A
2 \times 2 \times 3table ofA,BandCgives deviance14.0on 6 degrees of freedom forAB + Cand4.1on 4 degrees of freedom forAB + BC. Which model should be chosen at the5\%significance level, and what does it say?
AB + Cdoes not fit, because14.0exceeds the critical value12.592for 6 degrees of freedom.- Adding
BClowers the deviance by9.9on 2 degrees of freedom, above the critical value5.991, soBCis kept.AB + BCfits, because4.1is below the critical value9.488for 4 degrees of freedom.- Under
AB + BC,AandCare independent givenB.