for error, also called residual degrees of freedom. Example Perhaps the simplest example is this. Suppose are random variables each with expected value μ, and let be the "sample mean." Then the quantities are residuals that may be considered estimates of the errors Xi − μ. The sum of the residuals (unlike the sum of the errors) is necessarily 0. If one knows the values of any n − 1 of the residuals, one can thus find the last one. That means they are constrained to lie in a space of dimension n − 1. One says that there are n − 1 degrees of freedom for errors. An example which is only slightly less simple is that of least squares estimation of a and b in the model where xi is given, but ei and hence Yi are random. Let and be the least-squares estimates of a and b. Then the residuals are constrained to lie within the space defined by the two equations One says that there are n − 2 degrees of freedom for error. Notationally, the capital letter Y is used in specifying the model, while lower-case y in the definition of the residuals; that is because the former are hypothesized random variables and the latter are actual data. We can generalise this to multiple regression involving p parameters and covariates (e.g. p − 1 predictors and one mean (=intercept in the regression)), in which case the cost in degrees of freedom of the fit is p, leaving n - p degrees of freedom for errors In linear models The demonstration of the t and chi-squared distributions for one-sample problems above is the simplest example where degrees-of-freedom arise. However, similar geometry and vector decompositions underlie much of the theory of linear models, including linear regression and analysis of variance. An explicit example based on comparison of three means is presented here; the geometry of linear models is discussed in more complete detail by Christensen (2002). Suppose independent observations are made for three populations, , and . The restriction to three groups and equal sample sizes simplifies notation, but the ideas are easily generalized. The observations can be decomposed as where are the means of the individual samples, and is the mean of all 3n observations. In vector notation this decomposition can be written as The observation vector, on the left-hand side, has 3n degrees of freedom.