In simple linear regression, the error sum of squares is given by
$$ \text{SSE} = \sum_{i=1}^n(y_i - \hat{y_i})^2 \\ \hat{\sigma}^2 = s^2 = \dfrac{\text{SSE}}{n-2} $$ where $n-2$ is the degrees of freedom.
Question:
1. Why n-2?
Answers elsewhere:
- Most stop with telling us, n-2 because, we need to estimate $\beta_1,\beta_0$ before calculating $\hat{y}$ (source)
- An answer here, suggests, assuming errors are normally distribution ($\varepsilon \sim N(0,\sigma^2)$), the residual sum of squares will have a chi-squared distribution with n-2 df as below. $$\begin{aligned} \text{SSE} \sim \sigma^2 \text{Chi-Sq(df=n-2)} \end{aligned}$$ Here is the proof of above which again involves matrices and I was lost at orthogonal transformation. In another one here, in hat-matrix.
What did I do? 1. With hope of simpler proof, just like proving unbiased estimator of sample variance as shown here, I attempted as below, but stuck after few steps.
$$\begin{aligned} E(s^2) &= E\bigg(\dfrac{1}{n-2}\sum_{i=1}^n(y_i - \hat{y_i})^2\bigg) \\ &= E\bigg(\dfrac{1}{n-2}\sum_{i=1}^n(y_i^2 + \hat{y_i}^2 - 2y_i\hat{y_i})\bigg) \\ \end{aligned}$$
For any random variable X, $$ E\bigg( \sum_{i=1}^2 X_i \bigg) = E\bigg( X_1 + X_2 \bigg) = E(X_1) + E(X_2) = \sum_{i=1}^2 E(X_i) $$ That is, the expectation permeates in to the summation because $E(X+Y) = E(X) + E(Y)$.
Using same technique,
$$\begin{aligned} E(s^2) &= E\bigg(\dfrac{1}{n-2}\sum_{i=1}^n(y_i^2 + \hat{y_i}^2 - 2y_i\hat{y_i})\bigg) \\ &=\dfrac{1}{n-2} \sum_{i=1}^n \big( \ E(y_i^2) + E(\hat{y_i}^2) - 2E(y_i\hat{y_i}) \ \big) & \text{(1) stuck} \end{aligned}$$
I am stuck after this step. I wanted to show above ends up as $\sigma^2$., thus proving $s^2$ of SSE as unbiased.
Is it a duplicate Q?: I am learning these as part of "Intro to statistics" in Udacity, which is extremely limited in giving a mathematical background (its just basic intuition + formula => apply without understanding system) so I have been using few books 1, 2 as reference and during gaps, will use SE. Topics completed so far (Distributions, MLE, CI, Hypo.Testing) did not require matrices/vectors/quadratic forms yet because so far have been only dealing with single RVs (univariate?), (and chi-squared not yet covered). The books are "Introductory". However, many of the proofs I find here are using vectors/matrices which I find difficult to grasp, so with a hope of simpler answer for "introductory" student I am posting this Q, hopefully thus, also making it not a duplicate.