# Sum of Squared Error Chi-Square distribution degree of freedom in Multilinear Regression

In this link it says that $$Y$$ variables has zero covariance (because covariance matrix has only diagonal terms) which implies they are independent.

Actually in linear regression $$Y$$ takes its expectation values from linear function of $$X$$ variables whereas takes its variance from error terms. Also $$Y$$ is normally distributed because of the fact that errors are normally distributed.

So, if $$Y$$ variables has zero covariance then errors must be zero covariance which means they are independent. Then in parallel with last answer sum of $$(Y_i-\hat{Y}_i)^2$$ divided by $$\sigma^2$$ which means sum of error squared divided by $$\sigma^2$$ must be chi-square with $$n$$ degrees of freedom. Why do we have $$n-p-1$$ dgf afterwards?

Could you help me overcome that contradiction?

You see, $$\frac{\sum_{i=1}(Y-\hat{Y_i})^2}{\sigma^2}$$ is a function of $$\hat{Y}_i$$, a value that's obtained from a model with $$p+1$$ parameters (you have a constant plus a $$p$$ $$x_i$$ variables in $$X$$).
From a statistical intuition point of view, it's natural to expect you'd subtract these number of parameters from the total number of observations $$n$$, hence giving you $$n-(p+1)$$ degress of freedom.
• My point is: in regression we accept that error terms are normally distributed and independent. Then if we we divide square of errors by $\sigma^2$, those are converted to standard normal distributed and still independent. In short each $\frac{(Y-\hat{Y_i})^2}{\sigma^2}$ must be independent and chi square must have n degree of freedom. This is my confusion. Could you help me? Also if we have n-p-1 degree of freedom then it means our error terms actually does not fully independent right? Mar 30, 2019 at 14:48
• By the way if error terms are not independent, covariance matrix of $Y$ should not have only diagonal terms as it set in the given link before right? Mar 30, 2019 at 14:59
• For instance in this link "slide10" it is expressed that error vector is multivariate normal and if we assume that errors are uncorrelated then errors must have independent normal distribution because of multivariate normal distribution assumption. As a result of that each $\frac{(Y-\hat{Y_i})^2}{\sigma^2}$ must be independent standard normal. Therefore sum of them must equal to chi square distribution with n degree of freedom. What do you think about that? Mar 31, 2019 at 11:06
• You are mixing the observed and predicted values. The expression for the error is a function of $Y$ and $\hat{Y}$. Apr 2, 2019 at 20:21