Ordinary Least Squares
Study guides: Exam SRM, Exam MAS-I, Exam ACIA-CAPSTONE
Ordinary Least Squares is the method of estimating the coefficients of a linear regression by choosing the values that minimize the residual sum of squares. For n observations and p predictors, the least squares estimates \hat\beta_0, \ldots, \hat\beta_p are the values of \beta_0, \ldots, \beta_p that minimize
\text{RSS} = \sum_{i=1}^{n} \left(y_i - \beta_0 - \beta_1 x_{i1} - \cdots - \beta_p x_{ip}\right)^2
y_iis the observed response of observationi, andx_{ij}is its value of predictorj.
At the estimates, each term of the sum is the square of a residual, e_i = y_i - \hat{y}_i.
Simple linear regression
With one predictor, the least squares slope is
\hat\beta_1 = \frac{\sum_{i=1}^{n} (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^{n} (x_i - \bar{x})^2}
\bar{x}and\bar{y}are the sample means of thex_iand they_i.
and the least squares intercept is
\hat\beta_0 = \bar{y} - \hat\beta_1 \bar{x}
The fitted line therefore passes through the point of means (\bar{x}, \bar{y}). Dividing the top and the bottom of \hat\beta_1 by n gives the same slope as the sample covariance of x and y divided by the sample variance of x:
\hat\beta_1 = \frac{\overline{xy} - \bar{x}\,\bar{y}}{\overline{x^2} - \bar{x}^2}
\overline{xy}is the mean of the productsx_i y_i, and\overline{x^2}is the mean of the squaresx_i^2.
Average claim severity, in thousands, for years
x = 1, 2, 3, 4, 5is10.0,10.6,11.1,11.9and12.4. What is the least squares line, and what severity does it project for year 6?
- The sample means are
\bar{x} = 3and\bar{y} = 56.0/5 = 11.2.- The deviations of
xare-2, -1, 0, 1, 2, so\sum (x_i - \bar{x})^2 = 10.- The products of the deviations of
xandyare2.4,0.6,0,0.7and2.4, so\sum (x_i - \bar{x})(y_i - \bar{y}) = 6.1.- The slope is
\hat\beta_1 = 6.1/10 = 0.61, and the intercept is\hat\beta_0 = 11.2 - 0.61(3) = 9.37.- The projected severity for year 6 is
9.37 + 0.61(6) = 13.03thousand.
Matrix form of the estimates
In matrix form the least squares estimate of the coefficient vector is
\hat{\boldsymbol\beta} = (\mathbf{X}^T\mathbf{X})^{-1}\mathbf{X}^T\mathbf{y}
\mathbf{X}is then \times (p + 1)design matrix, and\mathbf{y}is the vector of observed responses.\mathbf{X}^T\mathbf{X}must be invertible.
Each entry of \hat{\boldsymbol\beta} estimates the coefficient of the corresponding column of \mathbf{X}. The fitted values are \hat{\mathbf{y}} = \mathbf{X}\hat{\boldsymbol\beta}.
A regression with an intercept is fitted to the points
(1, 2),(2, 3)and(3, 5). What are the least squares estimates? The design matrix has a column of ones and a column of thexvalues:
\mathbf{X} = \begin{bmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{bmatrix}, \quad \mathbf{y} = \begin{bmatrix} 2 \\ 3 \\ 5 \end{bmatrix}
\mathbf{X}^T\mathbf{X}has entries3,6,6and14, and its determinant is3(14) - 6(6) = 6.\mathbf{X}^T\mathbf{y}has entries2 + 3 + 5 = 10and2 + 6 + 15 = 23.- By the inverse of a
2 \\times 2matrix,\hat\beta_0 = (14 \times 10 - 6 \times 23)/6 = 1/3.- Likewise
\hat\beta_1 = (-6 \times 10 + 3 \times 23)/6 = 1.5.- The fitted line is
\hat{y} = 0.3333 + 1.5x.
Properties of the least squares estimators
If the model is correctly specified and the errors are uncorrelated with mean 0 and variance \sigma^2, the least squares estimators are unbiased, E[\hat{\boldsymbol\beta}] = \boldsymbol\beta, and their covariance matrix is
\text{Var}(\hat{\boldsymbol\beta}) = \sigma^2 (\mathbf{X}^T\mathbf{X})^{-1}
The error variance is estimated by
\hat\sigma^2 = \frac{\text{RSS}}{n - p - 1}
The standard error of \hat\beta_j, \text{SE}(\hat\beta_j), is the square root of the corresponding diagonal entry of \hat\sigma^2 (\mathbf{X}^T\mathbf{X})^{-1}. If the errors are also normal, the least squares estimates are the maximum likelihood estimates, and the statistic for testing H_0\colon \beta_j = 0 is
t = \frac{\hat\beta_j}{\text{SE}(\hat\beta_j)}
- Under
H_0,thas atdistribution withn - p - 1degrees of freedom.
A coefficient whose t statistic is not significant, such as an intercept close to zero, is consistent with a true value of zero.
The severity trend line above has
\text = 0.019. Is the slope significantly different from zero at the 5% level?
- With
n = 5andp = 1, the error variance estimate is\hat\sigma^2 = 0.019/3 = 0.006333.- In simple linear regression, the variance of
\hat\beta_1is estimated by\hat\sigma^2divided by\sum (x_i - \bar{x})^2 = 10.- The standard error is
\text{SE}(\hat\beta_1) = \sqrt{0.006333/10} = 0.02517.- The statistic is
t = 0.61/0.02517 = 24.2.- The two-sided 5% critical value with 3 degrees of freedom is
3.182, so the slope is significantly different from zero.
Generalized least squares
When the errors have unequal variances or are correlated, with covariance matrix \sigma^2 \mathbf{V}, the generalized least squares estimate is
\hat{\boldsymbol\beta} = (\mathbf{X}^T\mathbf{V}^{-1}\mathbf{X})^{-1}\mathbf{X}^T\mathbf{V}^{-1}\mathbf{y}
\mathbf{V}is a knownn \times nmatrix that describes the covariance structure of the errors, such as their autocorrelation.
With \mathbf{V} diagonal this is weighted least squares, and with \mathbf{V} = \mathbf{I} it is ordinary least squares. When the variance of the residuals grows with the fitted values, transforming the response, for example to \ln y, can also make the variance more nearly constant.
Extrapolating the fitted line beyond the data A least squares fit describes the relationship only over the range of the observed predictor values. The data cannot show whether the line continues outside that range, so a prediction far from the observed
xvalues rests on an assumption the data cannot check.
Practice questions
- CAS Exam MAS-I Fall 2018, Question 29
- CAS Exam MAS-I Fall 2019, Question 35
- CAS Exam MAS-I Spring 2019, Question 32
- Exam MAS-I Practice Question 107
- Exam MAS-I Practice Question 126
- Exam MAS-I Practice Question 161
- Exam MAS-I Practice Question 162
- Exam MAS-I Practice Question 163
- SOA Exam SRM Sample Question 14
- SOA Exam SRM Sample Question 23
- SOA Exam SRM Sample Question 53
- Exam SRM Practice Question 3