# Estimation of residuals in multilevel models

Let us consider this simple variance component model:

Y_{ij} = β_{0} + β_{1}*X_{ij} + u_{0j} + e_{ij}

The estimates of the residuals in multilevel models are less straightforward than in OLS regression models, where we can estimate the residuals by subtracting the predicted values of the dependent variable from the observed values. In multilevel models with residuals at two or more levels, the estimation procedure is more complex (Rasbash, Steele, Browne & Prosser 2005: 36-41, Goldstein 1995, Appendix 2.2, Hox 2010: 24-32).

In multilevel models, the level 2 residuals are of special interest because they can be used to estimate the regression lines for each level 2 unit. The first step is to calculate the raw residual for each individual (level 1 unit):

The raw residual for the jth level 2 unit (firm, country) is the mean of the raw residuals for the individuals belonging to level 2 unit j: r_{+j}. The level 2 residual for this unit is found by multiplying r_{+j} by a *shrinkage* factor (Rasbash, Steele, Browne & Prosser 2005: 36):

The multiplier is always less than or equal to 1, so that the estimated residual is almost always smaller than the raw residual. The multiplier is therefore known as a *shrinkage* factor. The shrinkage factor will be smaller (more shrinkage), the larger the level 1 residual (σ^{2}_{e}) compared with the intercept variance (σ^{2}_{u0}) and the smaller the sample for each unit (n_{j}).
This means that, for level 2 units where the information is scarce, such as having two to five observations, the estimate of the regression line for that unit is shrunk towards the mean regression. For level 2 units with larger sample sizes, the estimates of the regression coefficients are more reliable and the level 2 residual will be less shrunk towards the overall line.

Having estimated the level 2 residuals, the level 1 residuals can be calculated as follows: