Residual sum of squares
In statistics, the residual sum of squares (RSS), also known as the sum of squared residuals (SSR) or the sum of squared estimate of errors (SSE), is the sum of the squares of residuals (deviations predicted from actual empirical values of data). It is a measure of the discrepancy between the data and an estimation model, such as a linear regression. A small RSS indicates a tight fit of the model to the data. It is used as an optimality criterion in parameter selection and model selection.
In general, total sum of squares = explained sum of squares + residual sum of squares. For a proof of this in the multivariate ordinary least squares (OLS) case, see partitioning in the general OLS model.
One explanatory variable
In a model with a single explanatory variable, RSS is given by:[1]
- [math]\displaystyle{ \operatorname{RSS} = \sum_{i=1}^n (y_i - f(x_i))^2 }[/math]
where yi is the ith value of the variable to be predicted, xi is the ith value of the explanatory variable, and [math]\displaystyle{ f(x_i) }[/math] is the predicted value of yi (also termed [math]\displaystyle{ \hat{y_i} }[/math]). In a standard linear simple regression model, [math]\displaystyle{ y_i = \alpha + \beta x_i+\varepsilon_i\, }[/math], where [math]\displaystyle{ \alpha }[/math] and [math]\displaystyle{ \beta }[/math] are coefficients, y and x are the regressand and the regressor, respectively, and ε is the error term. The sum of squares of residuals is the sum of squares of [math]\displaystyle{ \widehat{\varepsilon\,}_i }[/math]; that is
- [math]\displaystyle{ \operatorname{RSS} = \sum_{i=1}^n (\widehat{\varepsilon\,}_i)^2 = \sum_{i=1}^n (y_i - (\widehat{\alpha\,} + \widehat{\beta\,} x_i))^2 }[/math]
where [math]\displaystyle{ \widehat{\alpha\,} }[/math] is the estimated value of the constant term [math]\displaystyle{ \alpha }[/math] and [math]\displaystyle{ \widehat{\beta\,} }[/math] is the estimated value of the slope coefficient [math]\displaystyle{ \beta }[/math].
Matrix expression for the OLS residual sum of squares
The general regression model with n observations and k explanators, the first of which is a constant unit vector whose coefficient is the regression intercept, is
- [math]\displaystyle{ y = X \beta + e }[/math]
where y is an n × 1 vector of dependent variable observations, each column of the n × k matrix X is a vector of observations on one of the k explanators, [math]\displaystyle{ \beta }[/math] is a k × 1 vector of true coefficients, and e is an n× 1 vector of the true underlying errors. The ordinary least squares estimator for [math]\displaystyle{ \beta }[/math] is
- [math]\displaystyle{ X \hat \beta = y \iff }[/math]
- [math]\displaystyle{ X^\operatorname{T} X \hat \beta = X^\operatorname{T} y \iff }[/math]
- [math]\displaystyle{ \hat \beta = (X^\operatorname{T} X)^{-1}X^\operatorname{T} y. }[/math]
The residual vector [math]\displaystyle{ \hat e = y - X \hat \beta = y - X (X^\operatorname{T} X)^{-1}X^\operatorname{T} y }[/math]; so the residual sum of squares is:
- [math]\displaystyle{ \operatorname{RSS} = \hat e ^\operatorname{T} \hat e = \| \hat e \|^2 }[/math],
(equivalent to the square of the norm of residuals). In full:
- [math]\displaystyle{ \operatorname{RSS} = y^\operatorname{T} y - y^\operatorname{T} X(X^\operatorname{T} X)^{-1} X^\operatorname{T} y = y^\operatorname{T} [I - X(X^\operatorname{T} X)^{-1} X^\operatorname{T}] y = y^\operatorname{T} [I - H] y }[/math],
where H is the hat matrix, or the projection matrix in linear regression.
Relation with Pearson's product-moment correlation
The least-squares regression line is given by
- [math]\displaystyle{ y=ax+b }[/math],
where [math]\displaystyle{ b=\bar{y}-a\bar{x} }[/math] and [math]\displaystyle{ a=\frac{S_{xy}}{S_{xx}} }[/math], where [math]\displaystyle{ S_{xy}=\sum_{i=1}^n(\bar{x}-x_i)(\bar{y}-y_i) }[/math] and [math]\displaystyle{ S_{xx}=\sum_{i=1}^n(\bar{x}-x_i)^2. }[/math]
Therefore,
- [math]\displaystyle{ \begin{align} \operatorname{RSS} & = \sum_{i=1}^n (y_i - f(x_i))^2= \sum_{i=1}^n (y_i - (ax_i+b))^2= \sum_{i=1}^n (y_i - ax_i-\bar{y} + a\bar{x})^2 \\[5pt] & = \sum_{i=1}^n (a(\bar{x}-x_i)-(\bar{y}-y_i))^2=a^2S_{xx}-2aS_{xy}+S_{yy}=S_{yy}-aS_{xy}=S_{yy} \left(1-\frac{S_{xy}^2}{S_{xx} S_{yy}} \right) \end{align} }[/math]
where [math]\displaystyle{ S_{yy}=\sum_{i=1}^n (\bar{y}-y_i)^2 . }[/math]
The Pearson product-moment correlation is given by [math]\displaystyle{ r=\frac{S_{xy}}{\sqrt{S_{xx}S_{yy}}}; }[/math] therefore, [math]\displaystyle{ \operatorname{RSS}=S_{yy}(1-r^2). }[/math]
See also
- Akaike information criterion
- Chi-squared distribution
- Degrees of freedom (statistics)
- Errors and residuals in statistics
- Lack-of-fit sum of squares
- Mean squared error
- Reduced chi-squared statistic, RSS per degree of freedom
- Squared deviations
- Sum of squares (statistics)
References
- ↑ Archdeacon, Thomas J. (1994). Correlation and regression analysis : a historian's guide. University of Wisconsin Press. pp. 161–162. ISBN 0-299-13650-7. OCLC 27266095.
- Draper, N.R.; Smith, H. (1998). Applied Regression Analysis (3rd ed.). John Wiley. ISBN 0-471-17082-8.
Original source: https://en.wikipedia.org/wiki/Residual sum of squares.
Read more |