# What are the degrees of freedom for "linear regression t-test" with one binary variable?

Quick, simple question.

I read that DF = n-2 when doing "a linear regression t-test" with a continuous independent variable. (Testing that the slope is 0). https://stattrek.com/regression/slope-test.aspx

I want to manually run through this with a single binary independent variable.

Is DF still n-2?

BTW, the "linear regression t-test" proceeds with t = b1/SE, which are provided from lm() - using R.

The general rule is that you subtract a degree of freedom for each coefficient that is estimated before calculating the standard deviation. So for a one sample t-test you estimate a single mean so $$df=n-1$$. In simple linear regression you estimate a single slope and y-intercept, so $$df=n-2$$.
A single binary predictor is usually coded as an indicator variable (0/1), so your regression most likely estimates an intercept (mean for baseline level) and a single slope (difference in means), so that would be 2 parameters estimated and $$df=n-2$$. If you use a categorical predictor with more than 2 categories, then that will spend more degrees of freedom.