![]() | ![]() | ![]() | ![]() |
PROC MIXED and GLIMMIX can fit HLMs using RANDOM statements. HLMs are also known as random coefficients or multilevel models. Random coefficients models are sensible when data arise from clusters and the regression model for each cluster can be assumed to be a random deviation from some overall population regression model. The models assume that these random deviations come from normal distributions and that the deviations across the intercepts and slopes might be correlated.
The data involved in an HLM will have a nested or hierarchical design structure while data in random coefficients model may not. Data at the individual level (such as students, patients, IDs) represent one level of the hierarchy while the additional levels are represented by the group characteristics, (such as classroom, school, cluster, clinic, site). In a simple HLM, you might only have one level of clustering. For example, suppose you have a series of measurements observed on schools taken over time. These repeated observations are taken at the school level making the observations clustered within schools.
Following is an example of fitting a simple HLM with PROC MIXED for such data. The MODEL statement fits an overall intercept and slope on time. The RANDOM statement fits a random deviation from the overall intercept for each subject and a random deviation from the overall slope on time for each subject. The TYPE=UN option on the RANDOM statement models the variance-covariance structure for the random intercept deviations and the random slope deviations for each subject, allowing for covariance between the intercept and slope deviations. The SOLUTION option in the MODEL statement gives you the overall slope and intercept for the model while the SOLUTION option in the RANDOM statements gives you the deviation from the overall intercept and slope for each subject.
proc mixed data=hlm1; class school; model y = time / solution; random int time / solution type=un subject=school; run;
Both PROC MIXED and GLIMMIX report the overall regression coefficients and the deviations from the overall regression coefficients for each subject with respective SOLUTION options in the MODEL and RANDOM statements. If you want an estimate of the intercept and slope for an individual, add the individual adjustment from the RANDOM statement to the overall estimate from the MODEL statement. That calculation can be done by merging the results of the associated ODS data sets containing these statistics or by writing ESTIMATE statements. Refer to this note to obtain the subject-specific parameter estimates and tests for a random coefficients model. Refer to this note to obtain a graphical representation of a random coefficients model. Refer to note 37047 and note 37057 for information on efficient coding techniques to reduce memory and the amount of time needed to fit random coefficients and HLMs.
You may estimate more complex random coefficients models that have more than two random coefficients or additional levels of hierarchy. The additional levels of hierarchy are modeled with multiple RANDOM statements. For example, the data may have a three-level hierarchy — multiple observations within students, students nested within classrooms, and classrooms nested within schools.
Following is an example of fitting a three-level HLM in PROC MIXED. The RANDOM statements fit random adjustments to the overall slope and intercept for the school, classroom, and pupil levels. The TYPE=UN option in the RANDOM statement specifies an unstructured covariance matrix for the random intercept and slope effects for each level of hierarchy. The TYPE=UN option provides a mechanism for estimating the correlation between the random coefficients at each level.
proc mixed data=hlm3; class school classroom pupil; model y = time / solution; random int time / solution type=un subject=school; random int time / solution type=un subject=classroom(school); random int time / solution type=un subject=pupil(classroom school); run;
Beginning in SAS 9.1 TS1M3, PROC GLIMMIX can be used to estimate HLMs for nonnormal distributions which are members of the exponential family (binomial, poisson, gamma, etc.). For example, suppose your dependent variable is binary and the data are collected from a two-level hierarchy with two measurements taken on each student, students are nested within classrooms, and classrooms are nested within schools. The following PROC GLIMMIX statements fit a two-level, binary HLM. The EVENT="1" option specifies the response category representing the event in binary models. The DIST= option specifies the assumed distribution for the response variable, and the LINK= option specifies the link function for that distribution. The SOLUTION option in the MODEL statement gives the overall slope and intercept for the model while the SOLUTION option in the multiple RANDOM statements provide the deviations from the overall intercept and slope for each subject.
proc glimmix data=hlm2; class school classroom; model y(event="1") = x1 x2 / dist=binary link=logit solution; random int x1 x2 / solution type=un subject=school; random int x1 x2 / solution type=un subject=classroom(school); run;
For more information on HLMs, see SAS System for Mixed Models and Singer (1998) cited in this note.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | SAS/STAT | All | n/a |
Type: | Usage Note |
Priority: | low |
Topic: | SAS Reference ==> Procedures ==> MIXED SAS Reference ==> Procedures ==> GLIMMIX Analytics ==> Mixed Models |
Date Modified: | 2003-04-29 06:20:15 |
Date Created: | 2002-12-16 10:56:40 |