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. 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 of the independent variable. 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.
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 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: 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. Because it is a property ofleast 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: 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 ithx value. The value of each response variable observation can be represented by Let be the least squares estimates of the unobservable parameters α and β based on the observed values of xi and Yi j. Let be the fitted values of the response variable. Then 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 scalar components, necessarily satisfies the two constraints It is thus constrained to lie in an -dimensional subspace of RN, i.e. there are N − 2 "degrees of freedom for error". Now let be the average of all Y-values associated with the ithx-value. We partition the sum of squares due to error into two components:
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 xi as constant rather than random. Then the response variables Yi 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, 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 ;