Degrees of freedom t test or confidence interval

Find the degrees of freedom for a particular *t* test or confidence interval ($CI$) below:

Test/$CI$ | Degrees of freedom |

One sample $t$ test/$CI$ | $N - 1$. Here $N$ is the sample size. |

Paired sample $t$ test/$CI$ | $N - 1$. Here $N$ is the number of difference scores. |

Two sample $t$ test/$CI$ - equal variances not assumed |
For hand calculations, it is common to use the smaller of $n_1 - 1$ and $n_2 - 1$ as an approximation for the degrees of freedom. Here $n_1$ is the sample size of group 1, and $n_2$ is the sample size of group 2. Computer programs use the following formula for the degrees of freedom: $$df = \dfrac{\Bigg(\dfrac{s^2_1}{n_1} + \dfrac{s^2_2}{n_2}\Bigg)^2}{\dfrac{1}{n_1 - 1} \Bigg(\dfrac{s^2_1}{n_1}\Bigg)^2 + \dfrac{1}{n_2 - 1} \Bigg(\dfrac{s^2_2}{n_2}\Bigg)^2}$$ Here $s^2_1$ is the sample variance in group 1, and $s^2_2$ is the sample variance in group 2. |

Two sample $t$ test/$CI$ - equal variances assumed |
$n_1 + n_2 - 2$. Here $n_1$ is the sample size of group 1, and $n_2$ is the sample size of group 2. |

$t$ test for the Pearson correlation coefficient |
$N - 2$. Here $N$ is the sample size (number of pairs). |

$t$ test for the Spearman correlation coefficient (Spearman's rho) |
$N - 2$. Here $N$ is the sample size (number of pairs). |

$t$ test/$CI$ within one way ANOVA setting (multiple comparisons/contrasts) |
$N - I$. Here $N$ is the total sample size and $I$ is the number of groups. |

$t$ test/$CI$ for a single regression coefficient (in OLS regression) |
$N - K - 1$. Here $N$ is the total sample size and $K$ is the number of independent variables. |