Actuarial Notes

Hat Matrix

Study guide: Exam MAS-I

The Hat Matrix is the n \times n matrix \mathbf{H} that turns the observed responses of a linear regression into its fitted values. It projects the response vector onto the space spanned by the columns of the design matrix \mathbf{X}, and it is

\mathbf{H} = \mathbf{X}(\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T

Substituting the least squares estimate \hat{\boldsymbol\beta} = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T\mathbf{y} into \hat{\mathbf{y}} = \mathbf{X}\hat{\boldsymbol\beta} shows that the fitted values are

\hat{\mathbf{y}} = \mathbf{H}\mathbf{y}

  • \mathbf{y} is the vector of observed responses.

Each fitted value is therefore row i of \mathbf{H} multiplied entry by entry with \mathbf{y} and summed, \hat{y}_i = \sum_{j} h_{ij}\, y_j. The matrix \mathbf{H} is symmetric, \mathbf{H}^T = \mathbf{H}, and idempotent, \mathbf{H}\mathbf{H} = \mathbf{H}. The residuals are \mathbf{e} = (\mathbf{I} - \mathbf{H})\mathbf{y}.

Row 1 of the hat matrix is (0.8333, 0.3333, -0.1667), and the responses are 2, 3 and 5. What are the fitted value and the residual of observation 1?

  • The fitted value is \hat{y}_1 = 0.8333(2) + 0.3333(3) - 0.1667(5) = 1.8333.
  • The residual is e_1 = y_1 - \hat{y}_1 = 2 - 1.8333 = 0.1667.

Leverage

The leverage of observation i is the diagonal entry h_{ii} of \mathbf{H}. It measures how far the observation's predictor values are from those of the other observations, and so how strongly the observation can pull its own fitted value toward itself. In simple linear regression the leverage is

h_{ii} = \frac{1}{n} + \frac{(x_i - \bar{x})^2}{\sum_{j=1}^{n} (x_j - \bar{x})^2}

  • \bar{x} is the mean of the predictor values.

The leverage depends only on the predictor values, not on y_i. It lies between 1/n and 1, and the leverages sum to p + 1, the number of coefficients, so their average is (p + 1)/n. An observation whose leverage greatly exceeds (p + 1)/n is a high-leverage point. The variance of its residual is \sigma^2(1 - h_{ii}), so a high-leverage point can have a small residual even when its response is unusual. An observation with both a high leverage and a large residual is influential, which Cook's distance measures.

Severity is regressed on insured value for five risks with insured values 1, 2, 3, 4 and 10. What is the leverage of the last risk, and is it a high-leverage point?

  • The mean insured value is \bar{x} = 20/5 = 4.
  • The sum of squared deviations is 9 + 4 + 1 + 0 + 36 = 50.
  • The leverage of the last risk is \frac{1}{5} + \frac{(10 - 4)^2}{50}, so h_{55} = 0.20 + 0.72 = 0.92.
  • The average leverage is (p + 1)/n = 2/5 = 0.40, and 0.92 is more than twice that, so the last risk is a high-leverage point.

Leave-one-out cross-validation

For a least squares fit, the error made in predicting observation i from a fit without it is e_i/(1 - h_{ii}), so leave-one-out cross-validation needs only one fit. The leave-one-out estimate of the test mean squared error is

\text{CV}_{(n)} = \frac{1}{n}\sum_{i=1}^{n} \left(\frac{y_i - \hat{y}_i}{1 - h_{ii}}\right)^2

Rural claims of 2 and 4 and urban claims of 7 and 9 are fitted with an intercept and an urban indicator. Each fitted value is its group's mean and each leverage is 0.5. What is the leave-one-out cross-validation estimate?

  • The fitted values are 3, 3, 8 and 8, so the residuals are -1, 1, -1 and 1.
  • Each leave-one-out error is \pm 1/(1 - 0.5) = \pm 2.
  • The estimate is \text{CV}_{(4)} = (4 + 4 + 4 + 4)/4 = 4, four times the mean squared residual of 1.

Practice questions

Actuarial Notes