Log-Linear Models

This chapter describes graphical models for multivariate discrete (categorical) data. It starts out by describing various different ways in which such data may be represented in R—for example, as contingency tables—and how to convert between these representations. It then gives a concise exposition of the theory of hierarchical log-linear models, with illustrative examples using the gRim package. Topics covered include log-linear model formulae, dependence graphs, graphical and decomposable models, maximum likelihood estimation using the IPS algorithm, and hypothesis testing. Model selection is briefly discussed and illustrated using a stepwise algorithm. Graphical modeling is particularly useful for multi-dimensional tables, and since these are often sparse, it is necessary to adjust the degrees of freedom as normally calculated. Other topics treated in the chapter include exact conditional tests, ordinal categorical variables, and a comparison of fitting log-linear models using IPS and the glm algorithms. A final section describes some utilities for working with the models.