Lack-of-fit sum of squares
In statistics, a sum of squares due to lack of fit, or more tersely a lack-of-fit sum of squares, is one of the components of a partition of the sum of squares of residuals in an analysis of variance, used in the numerator in an F-test of the null hypothesis that says that a proposed model fits well. The other component is the pure-error sum of squares. The pure-error sum of squares is the sum of squared deviations of each value of the dependent variable from the average value over all observations sharing its independent variable value(s). These are errors that could never be avoided by any predictive equation that assigned a predicted value for the dependent variable as a function of the value(s) of the independent variable(s). The remainder of the residual sum of squares is attributed to lack of fit of the model since it would be mathematically possible to eliminate these errors entirely.
Principle
In order for the lack-of-fit sum of squares to differ from the sum of squares of residuals, there must be more than one value of the response variable for at least one of the values of the set of predictor variables. For example, consider fitting a line
- [math]\displaystyle{ y = \alpha x + \beta \, }[/math]
by the method of least squares. One takes as estimates of α and β the values that minimize the sum of squares of residuals, i.e., the sum of squares of the differences between the observed y-value and the fitted y-value. To have a lack-of-fit sum of squares that differs from the residual sum of squares, one must observe more than one y-value for each of one or more of the x-values. One then partitions the "sum of squares due to error", i.e., the sum of squares of residuals, into two components:
- sum of squares due to error = (sum of squares due to "pure" error) + (sum of squares due to lack of fit).
The sum of squares due to "pure" error is the sum of squares of the differences between each observed y-value and the average of all y-values corresponding to the same x-value.
The sum of squares due to lack of fit is the weighted sum of squares of differences between each average of y-values corresponding to the same x-value and the corresponding fitted y-value, the weight in each case being simply the number of observed y-values for that x-value.[1][2] Because it is a property of least squares regression that the vector whose components are "pure errors" and the vector of lack-of-fit components are orthogonal to each other, the following equality holds:
- [math]\displaystyle{ \begin{align} &\sum (\text{observed value} - \text{fitted value})^2 && \text{(error)} \\ &\qquad = \sum (\text{observed value} - \text{local average})^2 && \text{(pure error)} \\ &\qquad\qquad {} + \sum \text{weight}\times (\text{local average} - \text{fitted value})^2 && \text{(lack of fit)} \end{align} }[/math]
Hence the residual sum of squares has been completely decomposed into two components.
Mathematical details
Consider fitting a line with one predictor variable. Define i as an index of each of the n distinct x values, j as an index of the response variable observations for a given x value, and ni as the number of y values associated with the i th x value. The value of each response variable observation can be represented by
- [math]\displaystyle{ Y_{ij} = \alpha x_i + \beta + \varepsilon_{ij},\qquad i = 1,\dots, n,\quad j = 1,\dots,n_i. }[/math]
Let
- [math]\displaystyle{ \widehat\alpha, \widehat\beta \, }[/math]
be the least squares estimates of the unobservable parameters α and β based on the observed values of x i and Y i j.
Let
- [math]\displaystyle{ \widehat Y_i = \widehat\alpha x_i + \widehat\beta \, }[/math]
be the fitted values of the response variable. Then
- [math]\displaystyle{ \widehat\varepsilon_{ij} = Y_{ij} - \widehat Y_i \, }[/math]
are the residuals, which are observable estimates of the unobservable values of the error term ε ij. Because of the nature of the method of least squares, the whole vector of residuals, with
- [math]\displaystyle{ N = \sum_{i=1}^n n_i }[/math]
scalar components, necessarily satisfies the two constraints
- [math]\displaystyle{ \sum_{i=1}^n \sum_{j=1}^{n_i} \widehat\varepsilon_{ij} = 0 \, }[/math]
- [math]\displaystyle{ \sum_{i=1}^n \left(x_i \sum_{j=1}^{n_i} \widehat\varepsilon_{ij} \right) = 0. \, }[/math]
It is thus constrained to lie in an (N − 2)-dimensional subspace of R N, i.e. there are N − 2 "degrees of freedom for error".
Now let
- [math]\displaystyle{ \overline{Y}_{i\bullet} = \frac{1}{n_i} \sum_{j=1}^{n_i} Y_{ij} }[/math]
be the average of all Y-values associated with the i th x-value.
We partition the sum of squares due to error into two components:
- [math]\displaystyle{ \begin{align} & \sum_{i=1}^n \sum_{j=1}^{n_i} \widehat\varepsilon_{ij}^{\,2} = \sum_{i=1}^n \sum_{j=1}^{n_i} \left( Y_{ij} - \widehat Y_i \right)^2 \\ & = \underbrace{ \sum_{i=1}^n \sum_{j=1}^{n_i} \left(Y_{ij} - \overline Y_{i\bullet}\right)^2 }_\text{(sum of squares due to pure error)} + \underbrace{ \sum_{i=1}^n n_i \left( \overline Y_{i\bullet} - \widehat Y_i \right)^2. }_\text{(sum of squares due to lack of fit)} \end{align} }[/math]
Probability distributions
Sums of squares
Suppose the error terms ε i j are independent and normally distributed with expected value 0 and variance σ2. We treat x i as constant rather than random. Then the response variables Y i j are random only because the errors ε i j are random.
It can be shown to follow that if the straight-line model is correct, then the sum of squares due to error divided by the error variance,
- [math]\displaystyle{ \frac{1}{\sigma^2}\sum_{i=1}^n \sum_{j=1}^{n_i} \widehat\varepsilon_{ij}^{\,2} }[/math]
has a chi-squared distribution with N − 2 degrees of freedom.
Moreover, given the total number of observations N, the number of levels of the independent variable n, and the number of parameters in the model p:
- The sum of squares due to pure error, divided by the error variance σ2, has a chi-squared distribution with N − n degrees of freedom;
- The sum of squares due to lack of fit, divided by the error variance σ2, has a chi-squared distribution with n − p degrees of freedom (here p = 2 as there are two parameters in the straight-line model);
- The two sums of squares are probabilistically independent.
The test statistic
It then follows that the statistic
- [math]\displaystyle{ \begin{align} F & = \frac{ \text{lack-of-fit sum of squares} /\text{degrees of freedom} }{\text{pure-error sum of squares} / \text{degrees of freedom} } \\[8pt] & = \frac{\left.\sum_{i=1}^n n_i \left( \overline Y_{i\bullet} - \widehat Y_i \right)^2\right/ (n-p)}{\left.\sum_{i=1}^n \sum_{j=1}^{n_i} \left(Y_{ij} - \overline Y_{i\bullet}\right)^2 \right/ (N - n)} \end{align} }[/math]
has an F-distribution with the corresponding number of degrees of freedom in the numerator and the denominator, provided that the model is correct. If the model is wrong, then the probability distribution of the denominator is still as stated above, and the numerator and denominator are still independent. But the numerator then has a noncentral chi-squared distribution, and consequently the quotient as a whole has a non-central F-distribution.
One uses this F-statistic to test the null hypothesis that the linear model is correct. Since the non-central F-distribution is stochastically larger than the (central) F-distribution, one rejects the null hypothesis if the F-statistic is larger than the critical F value. The critical value corresponds to the cumulative distribution function of the F distribution with x equal to the desired confidence level, and degrees of freedom d1 = (n − p) and d2 = (N − n).
The assumptions of normal distribution of errors and independence can be shown to entail that this lack-of-fit test is the likelihood-ratio test of this null hypothesis.
See also
Notes
- ↑ Brook, Richard J.; Arnold, Gregory C. (1985). Applied Regression Analysis and Experimental Design. CRC Press. pp. 48–49. ISBN 0824772520. https://archive.org/details/appliedregressio0000broo/page/48.
- ↑ Neter, John; Kutner, Michael H.; Nachstheim, Christopher J.; Wasserman, William (1996). Applied Linear Statistical Models (Fourth ed.). Chicago: Irwin. pp. 121–122. ISBN 0256117365.
Original source: https://en.wikipedia.org/wiki/Lack-of-fit sum of squares.
Read more |