Is it possible to graph my multilevel model using HLM?
This FAQ assumes that you know how to run and interpret a two level model using HLM. If you do not, see our online HLM tutorial. This document uses the sample dataset HSB.SSM that is available with the HLM software.
HLM added a graphing facility in version 5.04 of the software. You can graph models with random slopes and intercepts using this graphing facility.
Before graphing an equation, you should first set up and run an analysis on your model, including all of the variables that you would like to graph.
The first step to graphing a multilevel model is to specify a location on disk for your graph file. To do this, select the Basic Specifications menu item. In the ensuing dialog box, click Graph Equations. If you are using HLM on the Windows terminal server, Earthquake.cc.utexas.edu, the graph file must be saved to your user drive (the U drive).
Next, go to the File menu and select the Graph Equation menu item.
Your Y axis will always be the dependent variable specified in the level-1 equation. You can choose any variable that you like for the X axis. For example, if you were studying the relationship between SES and math achievement scores, you would likely choose SES as your X axis variable. Choosing a continuous variable for the X axis will produce a line graph that is the regression line, whereas choosing a categorical variable for the X axis will produce a bar graph. If you choose only an X variable, your graph will be the regression line for the entire population. For example, using the HLM sample data set HSB.SSM, graphing the regression line for the math achievement regressed on SES produces the following graph:
The graphing facility can also be used for more sophisticated graphs as well that contain level-2 variables and random effects. Using the options for the Z axis, you can add additional variables to the model containing random slopes and intercepts. For example, the model shown below has a random intercept and random slope for the SES variable.
After running this model, you can request separate lines for the variable sector. This variable has two values, 0 and 1. Selecting this variable in the Z focus(1) section of the dialog box, under the Level-2 dropdown menu produces the following graph:
The two lines represent the two values of sector. As the legend indicates, the line with the lower intercept is for cases where sector has a value of 0 and the higher intercept is for cases that have values of 1 for the sector variable.
In addition to graphing separate lines for dummy coded, or categorical data, you can also graph separate lines for continuous independent variables. You would likely not want to graph separate lines for every value of a continuous variable, so you will have to make some decisions about how to represent these variables. Continuing with the above example, the level-2 variable, school’s mean SES, can be added using the Z focus(2) section of the dialog box. Selecting meanses from the Level-2 dropdown menu will add this variable to the graph. There are several options available for representing continuous variables, such as meanses. Once a continuous variable has been chosen, the Range of z axis dropdown menu will be populated with the following options: 25th and 75th percentiles, 25th/50th/75th percentiles, Averaged upper/lower quartiles, and Choose up to 6 values. If you select the Choose up to 6 values option, you will need to fill in the boxes under the Choose up to 6 heading. Otherwise, separate lines will be plotted for each of the percentiles or quartiles that were selected. For example, choosing the 25th and 75th percentiles option, in conjunction with the options selected in the previous examples, produces the following graph:
In this graph the lower 25th percentile of meanses is -.296 and the upper 75th percentile is .332. Thus, there is a line plotted for cases with a value of 0 for sector and a mean SES of -.296 as well as a line for a mean SES of .332. The same is true for cases with a value of 1 for sector: there is a line for a mean SES of -.296 as well as a line for a mean SES of .332.
If you have further questions, send E-mail to stats@ssc.utexas.edu.