Advertisement
Hypothesis Testing

Degrees of Freedom Calculator

Use this degrees of freedom calculator to find df for t tests, chi-square tests, ANOVA, correlation, regression, and F tests. Select the test type, enter the required values, and get the answer with a clear step-by-step solution.

Select the test or analysis type first. The required input fields will update automatically.

How to Use the Degrees of Freedom Calculator

This calculator helps you find the correct degrees of freedom for common statistical tests, including:

  • One-sample t-test
  • Paired/dependent sample t-test
  • Independent samples t-test (equal variance assumed)
  • Independent samples t-test (unequal variance assumed)/ Welch’s t-test
  • Chi-square goodness of fit test
  • Chi-square test of independence
  • One-way ANOVA
  • F-test for two variances
  • Pearson’s correlation
  • Simple and multiple linear regression

To use the calculator:

  1. Select the type of test/analysis you’re conducting
  2. Enter the required parameters (this changes based on the selected test)
  3. Click calculate

The calculator will instantly return the correct degrees of freedom for your test. It also provides a clear, step-by-step solution, showing you exactly how the value was computed.

Note. Degrees of freedom are useful when finding critical values for hypothesis testing. For instance, you may need to compute the degrees of freedom for a t-test before using the t critical value calculator.

What Are Degrees of Freedom?

Degrees of freedom, often written as df, tell you how many values are free to vary after certain restrictions have been placed on the data. In many statistics problems, df depends on the sample size and the number of values, groups, or parameters used in the analysis.

How to Find Degrees of Freedom

There is no single formula that can be used to find the degrees of freedom for all statistical tests. This is because the degrees of freedom vary according to the type of test you’re running. The easiest way to find degrees of freedom is to master the formulas for each of these tests and apply the correct one to the correct statistical test.

The table below provides a summary of degrees of freedom formulas for the most common statistical tests.

Test or AnalysisDegrees of Freedom Formula
One-sample t test(df = n – 1)
Paired t test(df = n – 1), where (n) is the number of pairs
Independent samples t test, equal variances(df = n1 + n2 – 2)
Independent samples t test, unequal variancesWelch-Satterthwaite equation
Chi-square goodness-of-fit test(df = k – 1)
Chi-square test of independence(df = (r – 1)(c – 1))
One-way ANOVA(dfbetween = k – 1), (dfwithin = n – k), (dftotal = n – 1)
Pearson correlation(df = n – 2)
Linear regression(dfregression = p), (dfresidual = n – p – 1), (dftotal = n – 1)
F test for two variances(df1 = n1 – 1), (df2 = n2 – 1)

Where:

  • n is the sample size
  • n1 and n2 are the two sample sizes
  • k is the number of categories or groups
  • r is the number of rows
  • c is the number of columns
  • p is the number of predictors

Below are examples showing how to apply each degrees of freedom formula. These examples are designed to help you choose the correct formula based on the statistical test you are running.

Example 1: One-Sample T Test

A researcher collects a sample of 18 students and wants to test whether their average score is different from a known population mean. Find the degrees of freedom for the test.

Solution

For a one-sample t test, df = n – 1.

From the question, n = 18. Therefore,

df = 18 – 1

= 17

Example 2: Paired T Test

A researcher measures the blood pressure of 14 patients before and after a treatment. Find the degrees of freedom for the paired t test.

Solution

For a paired t test, df = n – 1.

Here, n is the number of pairs. Since 14 patients were measured before and after treatment, n = 14 pairs. Therefore, df = 14 – 1

= 13

Example 3: Independent Samples T Test Assuming Equal Variances

A researcher compares exam scores between two independent groups. Group 1 has 12 students, and Group 2 has 10 students. Assuming equal variances, find the degrees of freedom for the independent samples t test.

Solution

For an independent samples t test assuming equal variances, df = n1 + n2 – 2.

From the question, n1 = 12 and n2 = 10.

Therefore, df = 12 + 10 – 2

= 20

What About Welch’s T Test?

For an independent samples t test with unequal variances, we do not use df = n1 + n2 – 2. In this case, we use the Welch-Satterthwaite equation below.

df=(s12n1+s22n2)2(s12n1)2n11+(s22n2)2n21df = \frac{ \left(\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}\right)^2 }{ \frac{\left(\frac{s_1^2}{n_1}\right)^2}{n_1-1} + \frac{\left(\frac{s_2^2}{n_2}\right)^2}{n_2-1} }

Where:

  • s1 is the sample standard deviation for group 1
  • s2 is the sample standard deviation for group 2
  • n1 and n2 are the two sample sizes

Using the formula, it is very likely to get decimal values as the degrees of freedom.

Example 4. Chi-Square Goodness-of-Fit Test

A researcher wants to test whether survey responses are evenly distributed across 5 categories. Find the degrees of freedom for the chi-square goodness-of-fit test.

Solution

For a chi-square goodness-of-fit test, df = k – 1, where k is the number of categories. In this case, there are 5 categories. Hence, k = 5.

Therefore, df = 5 – 1

= 4

Example 5. Chi-Square Test of Independence

A researcher wants to test whether gender is associated with voting preference. The data are arranged in a contingency table with 3 rows and 4 columns. Find the degrees of freedom for the chi-square test of independence.

Solution

For a chi-square test of independence, df = (r – 1)(c – 1), where r is the number of rows and c the number of columns in a contingency table.

From the question, r = 3 and c = 4. Therefore, df = (3 – 1)(4 – 1)

= 2 × 3

= 6

Example 6: One-Way ANOVA

A researcher compares the mean exam scores of students taught using 4 different teaching methods. The total sample size is 36. Find the degrees of freedom for the one-way ANOVA.

Solution

For a one-way ANOVA, you need to find the degrees of freedom for between subjects, within subjects, and total. The formulas for each are:

  • df between = k – 1
  • df within = n – k
  • df total = n – 1

Where n is the total sample size and k the total number of independent groups.

In this case, k = 4 and n = 36. Therefore, we can calculate the degrees of freedom as follows:

df between = 4 – 1

= 3

df within = 36 – 4

= 32

df total = 36 – 1

= 35

Example 7: Pearson Correlation

A researcher collects paired data from 25 students to test the relationship between study time and exam score. Find the degrees of freedom for the Pearson correlation test.

Solution

For Pearson correlation, df = n – 2. From the question, n = 25.

Therefore, df = 25 – 2

= 23

Therefore, the degrees of freedom for Pearson correlation are: df = 23.

Example 8: Linear Regression

A researcher fits a linear regression model using 60 observations and 4 predictors. Find the regression, residual, and total degrees of freedom.

Solution

For linear regression:

  • df regression = p
  • df residual = n – p – 1
  • df total = n – 1

Where p is the number of predictors and n is the total sample size. From the question, n = 60 and p = 4. Therefore, the degrees of freedom are:

  • df regression = 4
  • df residual = 60 – 4 – 1 = 55
  • df total = 60 – 1 = 59

Example 9: F Test for Two Variances

A researcher wants to compare the variances of two independent samples. The first sample has 15 observations, and the second sample has 11 observations. Find the degrees of freedom for the F test.

Solution

For an F test for two variances, the degrees of freedom formulas are:

  • df1 = n1 – 1
  • df2 = n2 – 1

Where n1 and n2 are the sample sizes for each of the groups being compared.

From the question, n1 = 15 and n2 = 11.

Therefore,

  • df1 = 15 – 1 = 14
  • df2 = 11 – 1 = 10

Why Degrees of Freedom Matter

Degrees of freedom are important because many statistical distributions depend on df. For example, you need degrees of freedom when using:

  • the t distribution
  • the chi-square distribution
  • the F distribution

These distributions change shape depending on df. That means the critical value or p-value can change when df changes. For example, a t test with (df = 10) will not always have the same critical value as a t test with (df = 30). This is why you should always report the degrees of freedom, especially when writing the results section of any research paper.

Frequently Asked Questions

What is a degrees of freedom calculator?

This is an online tool that calculates degrees of freedom for statistical tests and models. It selects the correct formula based on the test type and shows the calculation steps.

What does df mean in statistics?

In statistics, df stands for degrees of freedom. It usually describes how many independent pieces of information are available after accounting for restrictions or estimated quantities.

Can degrees of freedom be a decimal?

Yes. Welch’s t-test can produce decimal degrees of freedom because it uses the Welch-Satterthwaite equation. This is normal and is commonly reported by statistical software.

Advertisement
Joseph Mburu

About This Calculator

Prepared by Joseph Mburu · Updated on

Joseph is an applied statistician and data analyst with over 6 years of experience helping students, researchers, and professionals solve statistics and data analysis problems. He holds a degree in Applied Statistics and a Master’s degree in Data…

We aim to keep our calculators accurate, easy to use, and helpful for learning. Always check that your inputs match the assumptions of the method you are using.