In a DOE analysis, the sum of squares (and degrees of freedom) for residual error can be partitioned in up to three parts: pure error, curvature, and lack of fit.

The total degrees of freedom for residual error are the total number of runs minus the number of parameters estimated (including the constant, any covariates, any block coefficients, any center point coefficients, the main effect coefficients, and any interaction coefficients). The total sum of squares for residual error is the sum of the squared residuals across all the runs in the design.

If the design has any replicates (that is, more than one run with exactly the same levels for all model terms) there will be degrees of freedom for pure error. Each set of replicates (r) will contribute r - 1 degrees of freedom for pure error. In other words, the degrees of freedom for pure error will equal:

m*(r - 1) + (c - 1)

Where:

- m is the number of corner points in the model
- r is the number of replicates
- c is the number of center points

The sum of squares for pure error is the sum of the squared deviations of the responses from the mean response in each set of replicates.

If you have an unreplicated design, when removing insignificant terms from the model it is possible to remove all terms containing one of the factors, resulting in a replicated design with one fewer factor. In this case, you will get an error term with an unreplicated design.

For example, if you create an unreplicated design with 3 factors (A, B, and C), and you remove the ABC, AC, BC, and C terms from the model, the reduced model is a replicated design with 2 factors (A and B).

If the design has any center points, you can choose to include a center point term as a parameter in the model or treat the curvature as a component of the error. In both cases, there is 1 degree of freedom associated with curvature. The curvature sum of squares is the reduction in the sum of squares of the residual error you obtain when you add the center point term to the model.

If the design has replicates and the model is unsaturated, some of the degrees of freedom are for lack-of-fit. The lack-of-fit degrees of freedom is found by subtracting the degrees of freedom for pure error and curvature (if appropriate) from the residual-error degrees of freedom. The sum of squares for lack of fit is found by subtracting the sums of squares for pure error and curvature (if appropriate) from the residual-error sum of squares. The sum of squares for lack of fit represents the total effect of all estimable interaction terms omitted from the model.