A degrees of freedom calculator finds the number of degrees of freedom for a t-test, a chi-squared test, an ANOVA or a regression. Choose the test, enter the sample sizes or counts, and it gives the degrees of freedom with the formula used.
How to use the degrees of freedom calculator
- Choose the test or model from the list.
- Enter the sample sizes, groups, rows and columns, or predictors that the test needs.
- Press Calculate to see the degrees of freedom, the working and whether the rule is on the cited page.
What degrees of freedom are
The Wikipedia article on degrees of freedom says that the number of independent pieces of information that go into the estimate of a parameter is called the degrees of freedom.[1] It says this is equal to the number of independent scores that go into the estimate minus the number of parameters used as intermediate steps in estimating the parameter itself.[1] For a variance, one intermediate parameter, the sample mean, is estimated, so the degrees of freedom is N − 1.[1] This idea explains most of the formulas in the calculator.
One-sample t-test
The page says the one-sample t statistic follows a Student's t distribution with n − 1 degrees of freedom when the hypothesised mean is correct.[1] With 10 observations, the degrees of freedom is 9. Its small example makes the idea concrete: for three values, once two of the deviations from the mean are known, the third is forced, so only n − 1 of them are free.[1] A paired t-test applies the same rule to the differences, with n pairs and n − 1 degrees of freedom. That reading is our own working, because the page does not name the paired test.
Two-sample t-tests
For two groups with equal variances, the pooled test has n1 + n2 − 2 degrees of freedom: for 10 and 12 observations, 20. For unequal variances the Welch–Satterthwaite formula is (s1²/n1 + s2²/n2)² ÷ ((s1²/n1)²/(n1 − 1) + (s2²/n2)²/(n2 − 1)). With 10 and 12 observations and standard deviations 2 and 3 it gives about 19.19, which is not a whole number. The page names the Satterthwaite approximation only in its regression section and gives no formula for the t-test, so both are our own working from the standard formulas.[1]
Chi-squared tests
For goodness of fit, the degrees of freedom are the number of categories minus 1 minus the number of parameters estimated from the data: 6 categories give 5. For a test of independence in a table, they are (rows − 1) × (columns − 1), so a 3 by 4 table has 6. The page does not give these rules; it says only that a sum of squared deviations of normal variables divided by the variance follows a chi-squared distribution with n − 1 degrees of freedom.[1] We give the two formulas as our own working and label them as such in the result.
One-way ANOVA
The page works through a three-group example with n observations per group. The treatment sum of squares has 2 degrees of freedom, the residual sum of squares has 3(n − 1), and the F distribution has 2 and 3n − 3 degrees of freedom.[1] The general version for k groups and N observations is k − 1 between groups and N − k within groups, with N − 1 in total. The calculator shows the split. For 3 groups and 15 observations, that is 2 and 12.
Regression
In a simple linear regression with an intercept and one slope, two degrees of freedom are used by the two fitted parameters and the remaining n − 2 belong to the residuals.[1] The page generalises this: when p coefficients are estimated, p degrees of freedom are consumed and n − p are left for the residuals, where p counts the intercept.[1] The calculator asks for the number of predictors and subtracts the predictors plus 1. With 20 observations and 1 predictor the result is 18, and with 3 predictors it is 16.
Fractional degrees of freedom
The page notes that software may report fractional degrees of freedom in some cases.[1] Welch's test is the common example. When you look up a critical value in a table, round down to the next whole number, which gives a slightly more cautious result. Software that uses the exact t distribution can use the fractional value directly.
Why degrees of freedom matter
The degrees of freedom decide which t, chi-squared or F distribution you compare your test statistic with. With few degrees of freedom the distributions have heavier tails, so you need a more extreme statistic to reach significance. As the degrees of freedom grow, the t distribution approaches the normal distribution. Using the wrong number can change a p-value, so it is worth checking it before reading a result from a table or from software.
A worked set of examples
A one-sample t-test on 25 measurements has 24 degrees of freedom. A pooled two-sample test on groups of 15 and 18 has 31. A chi-squared test on a 2 by 2 table has 1. A one-way ANOVA with 4 groups and 40 observations has 3 between groups and 36 within groups. A regression with 50 observations and 4 predictors has 45 residual degrees of freedom. All of these are our own applications of the formulas above.
Common mistakes
- Using the total sample size. Degrees of freedom are usually smaller than n.
- Using the pooled formula when variances differ. Welch's test is safer when they do.
- Forgetting the intercept in regression. It uses one degree of freedom.
What next
Use this often? Add Degrees of F to your Home screen.
Frequently asked questions
What is a degrees of freedom calculator?
A tool that finds the degrees of freedom of a test or model, such as n − 1 for a one-sample t-test, from the sample sizes or counts.
What are degrees of freedom?
The number of independent pieces of information used to estimate a parameter, which is the number of independent scores minus the parameters used as intermediate steps.
What is the degrees of freedom for a t-test?
n − 1 for a one-sample or paired test, and n1 + n2 − 2 for a pooled two-sample test. Welch's test uses the Welch–Satterthwaite formula.
How do I find degrees of freedom for chi-squared?
Goodness of fit: categories − 1 − estimated parameters. Independence: (rows − 1) × (columns − 1).
What is the degrees of freedom in regression?
n − 2 for the residuals of a simple regression, and n minus the number of predictors minus 1 for a multiple regression.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.