You can fit a wide variety of random-intercept and random-slope models.
Let us show you an example with an ordered categorical outcome, random intercepts, and three-level data.
Using a four-level Likert scale, we ran an experiment measuring students' attitudes toward statistics after taking an introductory statistics class. In some of the classes, Stata was used. Other packages were used in the remaining classes. The question is, does exposure to Stata result in a more positive attitude toward statistics?
In the model we fit, we control for use of Stata, each student's average score in previous math courses, and whether either of the student's parents is in a science-related profession.
We will imagine that the fictional data were collected from various courses at various undergraduate schools. School may have an effect, as might class within school.
The results are
|No. of Observations per Group|
|Group Variable||Groups Minimum Average Maximum|
|school||28 18 57.1 137|
|class||135 1 11.9 28|
|attitude||Coef. Std. Err. z P>|z| [95% Conf. Interval]|
|mathscore||.4085273 .039616 10.31 0.000 .3308814 .4861731|
|1.stata||.8844369 .2099124 4.21 0.000 .4730161 1.295858|
|1.science||.236448 .2049065 1.15 0.249 -.1651614 .6380575|
|1 1||-.3717699 .2958887 -1.26 0.209 -.951701 .2081612|
|/cut1||-.0959459 .1688988 -0.57 0.570 -.4269815 .2350896|
|/cut2||1.177478 .1704946 6.91 0.000 .8433151 1.511642|
|/cut3||2.383672 .1786736 13.34 0.000 2.033478 2.733865|
|var(_cons)||.0448735 .0425387 .0069997 .2876749|
|var(_cons)||.1482157 .0637521 .063792 .3443674|
(stata##science is how we introduce a full factorial interaction of stata and school in Stata; see Factor variables and value labels.)
We discover that exposure to Stata does indeed improve students' attitudes toward statistics.
The effect of school is minimal (the variance is small).
Class has a larger effect as revealed by its larger variance, so teachers matter.
Above we showed you an example with random intercepts. We could just as easily have shown you an example with random slopes.
See the all-new 358-page Multilevel Mixed-Effects Reference Manual.
The manual demonstrates many of the possible models, links, and families, including:
Introduction to multilevel mixed-effects models
Multilevel mixed-effects generalized linear model
Multilevel mixed-effects logistic regression
Multilevel mixed-effects probit regression
Multilevel mixed-effects complementary log-log regression
Multilevel mixed-effects ordered logistic regression
Multilevel mixed-effects ordered probit regression
Multilevel mixed-effects Poisson regression
Multilevel mixed-effects negative binomial regression
In multilevel data, observations—subjects, for want of a better term—can be divided into groups that have something in common:
See New in Stata 17 to learn about what was added in Stata 17.