Degrees of freedom (statistics)

In statistics, the number of degrees of freedom is the number of values in the final calculation of a statistic that are free to vary.^{[1]}
Estimates of statistical parameters can be based upon different amounts of information or data. The number of independent pieces of information that go into the estimate of a parameter is called the degrees of freedom (df). In general, the degrees of freedom of an estimate of a parameter is equal to the number of independent scores that go into the estimate minus the number of parameters used as intermediate steps in the estimation of the parameter itself (which, in sample variance, is one, since the sample mean is the only intermediate step).^{[2]}
Mathematically, degrees of freedom is the dimension of the domain of a random vector, or essentially the number of 'free' components: how many components need to be known before the vector is fully determined.
The term is most often used in the context of linear models (linear regression, analysis of variance), where certain random vectors are constrained to lie in linear subspaces, and the number of degrees of freedom is the dimension of the subspace. The degreesoffreedom are also commonly associated with the squared lengths (or "Sum of Squares") of such vectors, and the parameters of chisquared and other distributions that arise in associated statistical testing problems.
While introductory texts may introduce degrees of freedom as distribution parameters or through hypothesis testing, it is the underlying geometry that defines degrees of freedom, and is critical to a proper understanding of the concept. Walker (1940)^{[3]} has stated this succinctly:
 For the person who is unfamiliar with Ndimensional geometry or who knows the contributions to modern sampling theory only from secondhand sources such as textbooks, this concept often seems almost mystical, with no practical meaning.
Contents
Notation
In equations, the typical symbol for degrees of freedom is ν (lowercase Greek letter nu). In text and tables, the abbreviation "d.f." is commonly used. R.A. Fisher used n to symbolize degrees of freedom (writing n′ for sample size) but modern usage typically reserves n for sample size.
Residuals
A common way to think of degrees of freedom is as the number of independent pieces of information available to estimate another piece of information. More concretely, the number of degrees of freedom is the number of independent observations in a sample of data that are available to estimate a parameter of the population from which that sample is drawn. For example, if we have two observations, when calculating the mean we have two independent observations; however, when calculating the variance, we have only one independent observation, since the two observations are equally distant from the mean.
In fitting statistical models to data, the vectors of residuals are constrained to lie in a space of smaller dimension than the number of components in the vector. That smaller dimension is the number of degrees of freedom for error.
Linear regression
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 X_{i} − μ. 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 residual."
An only slightly less simple example is that of least squares estimation of a and b in the model
where ε_{i} and hence Y_{i} are random. Let and be the leastsquares 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.
The capital Y is used in specifying the model, and lowercase y in the definition of the residuals. That is because the former are hypothesized random variables and the latter are data.
We can generalise this to multiple regression involving p parameters and covariates (e.g. p − 1 predictors and one mean), in which case the cost in degrees of freedom of the fit is p.
Degrees of freedom of a random vector
Geometrically, the degrees of freedom can be interpreted as the dimension of certain vector subspaces. As a starting point, suppose that we have a sample of n independent normally distributed observations,
 .
This can be represented as an ndimensional random vector:
Since this random vector can lie anywhere in ndimensional space, it has n degrees of freedom.
Now, let be the sample mean. The random vector can be decomposed as the sum of the sample mean plus a vector of residuals:
The first vector on the righthand side is constrained to be a multiple of the vector of 1's, and the only free quantity is . It therefore has 1 degree of freedom.
The second vector is constrained by the relation . The first n − 1 components of this vector can be anything. However, once you know the first n − 1 components, the constraint tells you the value of the nth component. Therefore, this vector has n − 1 degrees of freedom.
Mathematically, the first vector is the orthogonal, or leastsquares, projection of the data vector onto the subspace spanned by the vector of 1's. The 1 degree of freedom is the dimension of this subspace. The second residual vector is the leastsquares projection onto the (n − 1)dimensional orthogonal complement of this subspace, and has n − 1 degrees of freedom.
In statistical testing applications, often one isn't directly interested in the component vectors, but rather in their squared lengths. In the example above, the residual sumofsquares is
If the data points X_{i} are normally distributed with mean 0 and variance σ^{2}, then the residual sum of squares has a scaled chisquared distribution (scaled by the factor σ^{2}), with n − 1 degrees of freedom. The degreesoffreedom, here a parameter of the distribution, can still be interpreted as the dimension of an underlying vector subspace.
Likewise, the onesample ttest statistic,
follows a Student's t distribution with n − 1 degrees of freedom when the hypothesized mean μ_{0} is correct. Again, the degreesoffreedom arises from the residual vector in the denominator.
Degrees of freedom in linear models
The demonstration of the t and chisquared distributions for onesample problems above is the simplest example where degreesoffreedom 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).^{[4]}
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 lefthand side, has 3n degrees of freedom. On the righthand side, the first vector has one degree of freedom (or dimension) for the overall mean. The second vector depends on three random variables, , and . However, these must sum to 0 and so are constrained; the vector therefore must lie in a 2dimensional subspace, and has 2 degrees of freedom. The remaining 3n − 3 degrees of freedom are in the residual vector (made up of n − 1 degrees of freedom within each of the populations).
Sum of squares and degrees of freedom
In statistical testing problems, one usually isn't interested in the component vectors themselves, but rather in their squared lengths, or Sum of Squares. The degrees of freedom associated with a sumofsquares is the degreesoffreedom of the corresponding component vectors.
The threepopulation example above is an example of oneway Analysis of Variance. The model, or treatment, sumofsquares is the squared length of the second vector,
with 2 degrees of freedom. The residual, or error, sumofsquares is
with 3(n1) degrees of freedom. Of course, introductory books on ANOVA usually state formulae without showing the vectors, but it is this underlying geometry that gives rise to SS formulae, and shows how to unambiguously determine the degrees of freedom in any given situation.
Under the null hypothesis of no difference between population means (and assuming that standard ANOVA regularity assumptions are satisfied) the sums of squares have scaled chisquared distributions, with the corresponding degrees of freedom. The Ftest statistic is the ratio, after scaling by the degrees of freedom. If there is no difference between population means this ratio follows an F distribution with 2 and 3n − 3 degrees of freedom.
In some complicated settings, such as unbalanced splitplot designs, the sumsofsquares no longer have scaled chisquared distributions. Comparison of sumofsquares with degreesoffreedom is no longer meaningful, and software may report certain fractional 'degrees of freedom' in these cases. Such numbers have no genuine degreesoffreedom interpretation, but are simply providing an approximate chisquared distribution for the corresponding sumofsquares. The details of such approximations are beyond the scope of this page.
Degrees of freedom parameters in probability distributions
Several commonly encountered statistical distributions (Student's t, ChiSquared, F) have parameters that are commonly referred to as degrees of freedom. This terminology simply reflects that in many applications where these distributions occur, the parameter corresponds to the degrees of freedom of an underlying random vector, as in the preceding ANOVA example. Another simple example is: if are independent normal (μ,σ^{2}) random variables, the statistic
follows a chisquared distribution with n−1 degrees of freedom. Here, the degrees of freedom arises from the residual sumofsquares in the numerator, and in turn the n−1 degrees of freedom of the underlying residual vector .
In the application of these distributions to linear models, the degrees of freedom parameters can take only integer values. The underlying families of distributions allow fractional values for the degreesoffreedom parameters, which can arise in more sophisticated uses. One set of examples is problems where chisquared approximations based on effective degrees of freedom are used. In other applications, such as modelling heavytailed data, a t or F distribution may be used as an empirical model. In these cases, there is no particular degrees of freedom interpretation to the distribution parameters, even though the terminology may continue to be used.
Effective degrees of freedom
Many regression methods, including ridge regression, linear smoothers and smoothing splines are not based on ordinary least squares projections, but rather on regularized (generalized and/or penalized) leastsquares, and so degrees of freedom defined in terms of dimensionality is generally not useful for these procedures. However, these procedures are still linear in the observations, and the fitted values of the regression can be expressed in the form
where is the vector of fitted values at each of the original covariate values from the fitted model, y is the original vector of responses, and H is the hat matrix or, more generally, smoother matrix.
For statistical inference, sumsofsquares can still be formed: the model sumofsquares is   Hy   ^{2}; the residual sumofsquares is . However, because H does not correspond to an ordinary leastsquares fit (i.e. is not an orthogonal projection), these sumsofsquares no longer have (scaled, noncentral) chisquared distributions, and dimensionallydefined degreesoffreedom are not useful.
The effective degrees of freedom of the fit can be defined in various ways to implement goodnessoffit tests, crossvalidation and other inferential procedures. Here one can distinguish between regression effective degrees of freedom and residual effective degrees of freedom. Regarding the former, appropriate definitions can include the trace of the hat matrix, tr(H) (^{[5]}, eq.(5.16)), the trace of the quadratic form of the hat matrix, tr(H'H), the form tr(2H  H H'), or the Satterthwaite approximation, tr(H'H)^{2}/tr(H'HH'H). In the case of linear regression, the hat matrix H is X(X 'X)^{−1}X ', and all these definitions reduce to the usual degrees of freedom. Notice that
i.e., the regression (not residual) degrees of freedom in linear models are "the sum of the sensitivities of the fitted values with respect to the observed response values" (^{[6]}, eq.(7)).
There are corresponding definitions of residual effective degreesoffreedom, with H replaced by I − H. For example, if the goal is to estimate error variance, the redf would be defined as tr((I − H)'(I − H)), and the unbiased estimate is (with ),
or (^{[7]}, eq.(2.18), p.30; ^{[8]}, p.54; ^{[9]}, eq.(4,14), p.172)):
the last approximation above (derived in ^{[8]}, eq.(B.1), p.305) reduces the computational cost from O(n^{2}) to only O(n). In general the numerator would be the objective function being minimized; e.g., if the hat matrix includes an observation covariance matrix, Σ, then becomes .
Note that unlike in the original case, we allow noninteger degrees of freedom, though the value must usually still be constrained between 0 and n.
Consider, as an example, the knearest neighbour smoother, which is the average of the k nearest measured values to the given point. Then, at each of the n measured points, the weight of the original value on the linear combination that makes up the predicted value is just 1/k. Thus, the trace of the hat matrix is n/k. Thus the smooth costs n/k effective degrees of freedom.
As another example, consider the existence of nearly duplicated observations. Naive application of classical formula, n  p, would lead to overestimation of the residuals degree of freedom, as if each observation were independent. More realistically, though, the hat matrix H = X(X ' Σ^{−1} X)^{−1}X ' Σ^{−1} would involve an observation covariance matrix Σ indicating the nonzero correlation among observations. The more general formulation of effective degree of freedom would result in a more realistic estimate for, e.g., the error variance σ^{2}.
Similar concepts are the equivalent degrees of freedom in nonparametric regression (^{[10]}, eq.(3.15), p.37), the degree of freedom of signal in atmospheric studies (^{[11]}, eq.(2.56), p.31; ^{[12]}, eq.(4.26), p.114) and the noninteger degree of freedom in geodesy (^{[13]}, eq.(27), p.205), going back at least to 1963 (^{[14]}, eq.(5.19)(5.20)).
See also
References
 ^ "Degrees of Freedom". "Glossary of Statistical Terms". Animated Software. http://www.animatedsoftware.com/statglos/sgdegree.htm. Retrieved 20080821.
 ^ Lane, David M.. "Degrees of Freedom". HyperStat Online. Statistics Solutions. http://davidmlane.com/hyperstat/A42408.html. Retrieved 20080821.
 ^ Walker, H. M. (April 1940). "Degrees of Freedom". Journal of Educational Psychology 31 (4): 253–269. doi:10.1037/h0054588.
 ^ Christensen, Ronald (2002). Plane Answers to Complex Questions: The Theory of Linear Models (Third ed.). New York: Springer. ISBN 0387953612.
 ^ Trevor Hastie, Robert Tibshirani, Jerome H. Friedman (2009), The elements of statistical learning: data mining, inference, and prediction, 2nd ed., 746 p. ISBN 9780387848570, doi:10.1007/9780387848587, [1]
 ^ Ye, J. (1998), On Measuring and Correcting the Effects of Data Mining and Model Selection, Journal of the American Statistical Association, Vol. 93, No. 441, pp. 120131. [2]
 ^ Clive Loader (1999), Local regression and likelihood, 308 p., ISBN 9780387987750, doi:10.1007/b98858, [3]
 ^ ^{a} ^{b} Trevor Hastie, Robert Tibshirani (1990), Generalized additive models, CRC Press, 335 p., [4]
 ^ Simon N. Wood (2006), Generalized additive models: an introduction with R, CRC Press, 391 p., [5]
 ^ Peter J. Green, B. W. Silverman (1994), Nonparametric regression and generalized linear models: a roughness penalty approach, CRC Press, 182 pp. [6]
 ^ Clive D. Rodgers (2000), Inverse methods for atmospheric sounding: theory and practice, World Scientific, 238 p.
 ^ Adrian Doicu, Thomas Trautmann, Franz Schreier (2010), Numerical Regularization for Atmospheric Inverse Problems, Springer, 426 p.
 ^ D. Dong, T. A. Herring and R. W. King (1997), Estimating regional deformation from a combination of space and terrestrial geodetic data, J. Geodesy, Volume 72, Number 4, pp. 200214, doi:10.1007/s001900050161
 ^ H. Theil (1963), On the Use of Incomplete Prior Information in Regression Analysis, Journal of the American Statistical Association, Vol. 58, No. 302 pp. 401414, [7]

 Eisenhauer, J.G. (2008) "Degrees of Freedom". Teaching Statistics, 30(3), 75–78
External links
 Walker, HW (1940) "Degrees of Freedom" Journal of Educational Psychology 31(4) 253269. Transcription by C Olsen with errata
 Good, IJ (1973). "What Are Degrees of Freedom?". The American Statistician (The American Statistician, Vol. 27, No. 5) 27 (5): 227–228. doi:10.2307/3087407. JSTOR 3087407.
 Yu, Chongho (1997) Illustrating degrees of freedom in terms of sample size and dimensionality
 Dallal, GE. (2003) Degrees of Freedom
Categories: Statistical terminology
Wikimedia Foundation. 2010.
Look at other dictionaries:
Degrees of freedom — can mean: Degrees of freedom (mechanics), independent displacements and/or rotations that specify the orientation of the body or system Degrees of freedom (physics and chemistry), a term used in explaining dependence on parameters, or the… … Wikipedia
degrees of freedom — n. Statistics the number of independent variables entering into a statistical measure or frequency distribution * * * … Universalium
degrees of freedom — n. Statistics the number of independent variables entering into a statistical measure or frequency distribution … English World dictionary
Degrees Of Freedom — In statistics, the number of values in a study that are free to vary. For example, if you have to take ten different courses to graduate, and only ten different courses are offered, then you have nine degrees of freedom. Nine semesters you will… … Investment dictionary
degrees of freedom — number of unrestricted values that can be applied in any order to a distribution (Statistics) … English contemporary dictionary
statistics — /steuh tis tiks/, n. 1. (used with a sing. v.) the science that deals with the collection, classification, analysis, and interpretation of numerical facts or data, and that, by use of mathematical theories of probability, imposes order and… … Universalium
freedom, degree of — ▪ mathematics and statistics in mathematics, any of the number of independent quantities necessary to express the values of all the variable properties of a system. A system composed of a point moving without constraints in space, for… … Universalium
Freedom of religion in Egypt — The Constitution provides for freedom of belief and the practice of religious rites, although the Government places restrictions on these rights in practice. Islam is the official state religion and Shari a (Islamic law) is the primary source of… … Wikipedia
Freedom of religion in Vietnam — The Constitution provides for freedom of worship; however, government restrictions still remained on the organized activities of religious groups.The status for the respect of religious freedom and practice continued to experience important… … Wikipedia
Freedom of religion in Taiwan — The Constitution provides for freedom of religion, and the authorities generally respected this right in practice. There was no change in the status of respect for religious freedom by the authorities during the period covered by this report, and … Wikipedia