## Estimating HLM Models Using R: Part 1

Estimating HLM Models Using R: Part 1 There are a number of different R packages that now exist for fitting mixed models, including hierarchical linear models. For cross-sectional applications, perhaps the most frequently used package is lme4 (Bates et al., 2015). However, due to ambiguity in how to appropriately determine the degrees of freedom for $$t$$-tests, lme4 does not provide $$p$$-values for the fixed effects. The lmerTest package (Kuznetsova et al.

## Estimating HLM Models Using R: Part 2

Estimating HLM Models Using R: Part 2 The Means-as-Outcomes Model After estimating the empty model, R&B develop a Means-as-Outcomes model in which a school-level variable, meanses, is added to the model for the intercept. This variable reflects the average student SES level in each school. Recall that, when fitting the empty model, we began with the following equation: $Y_{ij} = \beta_{0j} + e_{ij}$ Now the intercept can be modeled as a grand mean, $$\gamma_{00}$$, plus the effect of the average SES score, $$\gamma_{01}$$, plus a random error, $$u_{0j}$$.

## Estimating HLM Models Using R: Part 3

Estimating HLM Models Using R: Part 3 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. The following creates a new, group mean centered SES variable.

## Estimating HLM Models Using R: Part 4

Estimating HLM Models Using R: Part 4 Intercepts- and Slopes-as-Outcomes R&B present a final model that includes one further generalization of the random coefficients model. Start again with the level-1 model. $Y_{ij} = \beta_{0j} + +\beta_{1j}(\text{SES}_{ij}) + e_{ij}$ Next, model the intercept, $$\beta_{0j}$$, as a function of school-level characteristics mean SES and school type (public or private). \begin{aligned} \beta_{0j} &= \gamma_{00} + \gamma_{01}(\text{Mean SES}_j) + \gamma_{02}(\text{School Type}_j) + u_{0j} \\ \beta_{1j} &= \gamma_{10} + \gamma_{11}(\text{Mean SES}_j) + \gamma_{12}(\text{School Type}_j) + u_{1j} \end{aligned}

## Estimating HLM Models Using SPSS Menus: Part 4

Note: For a fuller treatment, download our series of lectures Hierarchical Linear Models. Intercepts- and Slopes-as-Outcomes Model R&B present a final model that includes one further generalization of the random coefficients model. They begin again with the level-1 model: $$$Y_{ij} = \beta_{0j} + \beta_{1j}(SES)+ e_{ij} \tag{6}$$$ The intercept $$\beta_{0j}$$ is now modeled as a function of the average SES level of the school and whether or not the school is public or private.

## Estimating HLM Models Using Stata: Part 1

Estimating HLM Models Using Stata: Part 1 The data used in this tutorial can be downloaded from (here)[https://github.com/jeralbri/tutorial-data/tree/master/data]. What follows replicates the results from Raudenbush and Bryk’s (2002, herafter R&B) cannonical text on hierarchical linear models (see especially chapter 4). The Empty Model As a first step, R&B begin with an empty model containing no covariates. $Y_{ij} = \beta_{0j} + e_{ij}$ Each school’s intercept, $$\beta_{0j}$$, is then set equal to a grand mean, $$\gamma_{00}$$, and a random error $$u_{0j}$$.

## Estimating HLM Models Using Stata: Part 2

Estimating HLM Models Using Stata: Part 2 The Means-as-Outcomes Model After estimating the empty model, R&B develop a Means-as-Outcomes model in which a school-level variable, meanses, is added to the model for the intercept. This variable reflects the average student SES level in each school. Recall that, when fitting the empty model, we began with the following equation: $Y_{ij} = \beta_{0j} + e_{ij}$ Now the intercept can be modeled as a grand mean, $$\gamma_{00}$$, plus the effect of the average SES score, $$\gamma_{01}$$, plus a random error, $$u_{0j}$$.

## Estimating HLM Models Using Stata: Part 3

Estimating HLM Models Using Stata Part 3 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. The following creates a new, group mean centered SES variable.
Estimating HLM Models Using Stata: Part 4 Intercepts- and Slopes-as-Outcomes R&B present a final model that includes one further generalization of the random coefficients model. Start again with the level-1 model. $Y_{ij} = \beta_{0j} + +\beta_{1j}(\text{SES}_{ij}) + e_{ij}$ Next, model the intercept, $$\beta_{0j}$$, as a function of school-level characteristics mean SES and school type (public or private). \begin{aligned} \beta_{0j} &= \gamma_{00} + \gamma_{01}(\text{Mean SES}_j) + \gamma_{02}(\text{School Type}_j) + u_{0j} \\ \beta_{1j} &= \gamma_{10} + \gamma_{11}(\text{Mean SES}_j) + \gamma_{12}(\text{School Type}_j) + u_{1j} \end{aligned}
Note: For a fuller treatment, download our series of lectures Hierarchical Linear Models. The Empty Model As a first step, R&B begin with an empty model containing no covariates. $$$Y_{ij} = \beta_{0j} + e_{ij}\tag{1}$$$ Each school’s intercept, $$\beta_{0j}$$, is then set equal to a grand mean, $$\gamma_{00}$$, and a random error $$u_{0j}$$. $$$\beta_{0j} = \gamma_{00} + u_{0j}\tag{2}$$$ Substituting (2) into (1) produces $$$Y_{ij} = \gamma_{00} + u_{0j} + e_{ij}\tag{3}$$$