### Note: For a fuller treatment, download our series of lectures Hierarchical Linear Models.

#### Random Coefficient Model

Next, R&B present a model in which student-level SES is included instead of average SES, and they treat the slope of student SES as random. One complication is that R&B present results after group-mean centering student SES. Group-mean centering means that the average SES for each student’s school is subtracted from each student’s individual SES. To complete the group-mean centering, subtract *meanses* from each *ses* variable. Go to **Transform > Compute Variable**.

`knitr::include_graphics("../images/hlm-spss-13.jpg", error = FALSE)`

In the menu that appears, create a **Target Variable** named *grp_ses* that is equal to *ses* minus *meanses*.

`knitr::include_graphics("../images/hlm-spss-14.jpg", error = FALSE)`

Click **OK**. The group-centered SES variable can now be used.

The level-1 equation is the following:

\[ \begin{equation}Y_{ij} = \beta_{0j} + \beta_{1j}(SES)+ e_{ij} \tag{6}\end{equation} \]

The intercept \(\beta_{0j}\) can be modelled as a grand mean \(\gamma_{00}\) plus random error, \(u_{0j}\). Similarly the slope \(\beta_{1j}\) can be modelled as having a grand mean \(\gamma_{10}\) plus random error \(u_{1j}\).

\[ \begin{equation}\beta_{0j} = \gamma_{00} + u_{0j} \tag{7}\end{equation} \]

\[ \begin{equation}\beta_{1j} = \gamma_{10} + u_{1j} \tag{8}\end{equation} \]

Combining (7) and (8) into (6) produces:

\[ \begin{equation} Y_{ij} = \gamma_{00} + \gamma_{10}(SES) + u_{0j} + u_{1j}(SES) + e_{ij} \tag{9}\end{equation} \]

To estimate (9) in SPSS go to **Analyze > Mixed Models > Linear**. The **Specify Subjects and Repeated** menu appears again. As before, place *schid* in the **Subjects** box and leave **Repeated** blank.

`knitr::include_graphics("../images/hlm-spss-15.jpg", error = FALSE)`

Click **Continue**. In the next menu one specifies the dependent and independent variables. The dependent variable is *mathach*, and the single covariate will be *grp_ses*.

`knitr::include_graphics("../images/hlm-spss-16.jpg", error = FALSE)`

To specify the model’s fixed effects click on **Fixed**. In the **Fixed Effects** menu, bring *grp_ses* variable over to the **Model** box and make sure **Include Intercept** is checked.

`knitr::include_graphics("../images/hlm-spss-17.jpg", error = FALSE)`

Click **Continue**, then on **Random**.

In the **Random Effects** menu, place the grouping variable *schid* in the **Combinations** box. Also, because *grp_ses* will have a random slope it is necessary to place it in the **Model** box. Next, make sure that **Include Intercept** is checked so that the intercept is also allowed to vary randomly. Finally, the presence of two random effects means that the dimensions of the covariance matrix **G** are now 2?2. The default in SPSS is to assume a variance components structure, which implies that there is no covariance between the random intercept and random slope (see the table of covariance structures in A Review of Random Effects ANOVA Models). This assumption can be loosened so that the covariances are free parameters to be estimated from the data. Specify **Unstructured** for the **Covariance Type**.

`knitr::include_graphics("../images/hlm-spss-18.jpg", error = FALSE)`

Click **Continue**. Then click **Statistics** to specify what appears in the output. Check **Parameter Estimates** to get results for the fixed effects.

`knitr::include_graphics("../images/hlm-spss-19.jpg", error = FALSE)`

Click **Continue**, then **OK**. A portion of the results is the following:

`knitr::include_graphics("../images/hlm-spss-20.jpg", error = FALSE)`

These results correspond to Table 4.4 in R&B. See also the variance-covariance components at the bottom of their page 77.

The final model R&B present is an intercept- and slopes-as-outomes model.

Still have questions? Contact us!