Multilevel generalized linear models

Stata fits multilevel mixed-effects generalized linear models (GLMs) with meglm.
GLMs for cross-sectional data have been a workhorse of statistics because of their flexibility
and ease of use. Stata’s xtgee command extends GLMs to the use of longitudinal/panel
data by the method of generalized estimating equations.

Now you can use meglm to fit GLMs to hierarchical multilevel datasets with normally distributed random effects. Seven distributions for the response
variable are supported (Gaussian, Bernoulli, binomial, gamma, negative
binomial, ordinal, and Poisson); and five link functions are possible
(identity, log, logit, probit, and complementary log-log).

Let's fit a three-level model.

We have student-level data, where students are nested in classes, and classes
are nested in schools. Our dependent variable thk is an
ordered categorical variable that takes on the values 1, 2, 3, or 4; and we
have three explanatory variables: prethk, cc, and tv. We
will treat prethk as continuous. cc and tv are binary, and
we want to include their interaction the model. Let's fit an ordered logit
model:

Our model has two random-effects equations, separated by ||. Our first
is a random intercept at the school level, and the second is a random
intercept at the class level. The order we listed them matters: class comes
after school, meaning that classes are nested within schools. Using the
same logic, we could include more levels of nesting. meglm also allows
crossed-effects models.

The output table includes the fixed-effect portion of our model, the
estimated cutpoints (because this is an ordered logit model), and the
estimated variance components.

This model can alternatively be fit with meologit, which is a convenient
use for meglm with an ordinal family and a logit link. See the
example fit with meologit.