In the book An introduction to statistical learning with Applications in R
, when testing the relationship between the Response and the Predictors using null hypothesis
, it gives a formula:
$$F = \frac{(TSS - RSS)/p}{RSS/(n-p-1)}$$
where
$$RSS = \sum_{i=1}^{n} (y_i-\hat{y_i})^2$$
$$\hat{y}=\hat{\beta_0} + \hat{\beta_1}x_1 + \dotsb + \hat{\beta_p}x_p$$
$$TSS = \sum_{i=1}^{n} (y_i-\bar{y})^2$$
I googled the F test
and learned that the degree of freedom in F statistic means number of values in the final calculation of a statistic that are free to vary
.(https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics), https://www.khanacademy.org/math/probability/statistics-inferential/anova/v/anova-3-hypothesis-test-with-f-statistic)
But, here I cannot get why in this formula the degree of freedom are p
and (n-p-1)
?