0
$\begingroup$

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.

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Thanks. (It is giving an intercept and a single slope). $\endgroup$
    – Kyle
    Aug 22, 2020 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.