ANOVA Calculations in Multiple Linear Regression

The sum of squares for the analysis of variance in multiple linear regression is obtained using the same relations as those in simple linear regression, except that the matrix notation is preferred in the case of multiple linear regression. In the case of both the simple and multiple linear regression models, once the observed and fitted values are available, the sum of squares are calculated in an identical manner. The difference between the two models lies in the way the fitted values are obtained. In a simple linear regression model, the fitted values are obtained from a model having only one predictor variable. In multiple linear regression analysis, the model used to obtained the fitted values contains more than one predictor variable.

Total Sum of Squares
Recall from Simple Linear Regression Analysis on simple linear regression that the total sum of squares, $$SS_r\,\!$$, is obtained using the following equation:


 * $$\begin{align}SS_r = & \sum_{i=1}^n (y_i-\bar{y})^2 \\

= & \sum_{i=1}^n y_i^2-\frac{\left(\sum_{i=1}^n y_i\right)^2}{n}\end{align}\,\!$$

The first term, $$\sum_{i=1}^n y_i^2\,\!$$, can be expressed in matrix notation using the vector of observed values, y, as:


 * $$\sum_{i=1}^n y_i^2 = y'y\,\!$$

If represents an n x n square matrix of ones, then the second term, $$\left(\sum_{i=1}^n y_i\right)^2 ln\,\!$$, can be expressed in matrix notation as:


 * $$\frac{\left(\sum_{i=1}^n y_i\right)^2}{n}=(\frac{1}{n} y'Jy\,\!$$

Therefore, the total sum of squares in matrix notation is: (31)


 * $$\begin{align}SS_r = & y'y - (\frac{1}{n}) y'Jy \\

= & y'[I-(\frac{1}{n})J]y\end{align}\,\!$$

where I is the identity matrix of order.

Model Sum of Squares
Similarly, the model sum of squares or the regression sum of squares, $$SS_R\,\!$$, can be obtained in matrix notation as:


 * $$\begin{align}SS_R= & \sum_{i=1}^n \hat{y}_i^2-\frac{\left(\sum_{i=1}^n y_i\right)^2}{n} \\

= & \hat{y}'\hat-\frac{1}{n} y'Jy \\ & y'[H-\frac{1}{n}J]y\end{align}\,\!$$

where $$H\,\!$$ is the hat matrix and is calculated using $$H=X(X'X)^{-1}X'\,\!$$.

Error Sum of Squares
The error sum of squares or the residual sum of squares, $$SS_E\,\!$$, is obtained in the matrix notation from the vector of residuals, $$e\,\!$$, as:


 * $$\begin{align}SS_E= & e'e \\

= &(y-\hat{y})'(y-\hat{y}) \\ = & y'(I-H)y\end{align}\,\!$$

Mean Squares
Mean squares are obtained by dividing the sum of squares with their associated degrees of freedom. The number of degrees of freedom associated with the total sum of squares, $$SS_r\,\!$$, is ($$n-1\,\!$$) since there are n observations in all, but one degree of freedom is lost in the calculation of the sample mean, $$\bar{y}\,\!$$. The total mean square is:


 * $$MS_r=\frac{SS_r}{n-1}\,\!$$

The number of degrees of freedom associated with the regression sum of squares, $$SS_R\,\!$$, is $$k\,\!$$. There are (k+1) degrees of freedom associated with a regression model with (k+1) coefficients, $$\beta_0\,\!$$, $$\beta_1\,\!$$, $$\beta_2\,\!$$.... $$\beta_k\,\!$$. However, one degree of freedom is lost because the deviations, ($$\hat{y}_i-\bar{y}\,\!$$), are subjected to the constraints that they must sum to zero ($$\sum_{i=1}^n (\hat{y}_i-\bar{y})^2=0\,\!$$). The regression mean square is:


 * $$MS_R=\frac{SS_R}{k}\,\!$$

The number of degrees of freedom associated with the error sum of squares is, as there are observations in all, but  degrees of freedom are lost in obtaining the estimates of $$\beta_0\,\!$$, $$\beta_1\,\!$$, $$\beta_2\,\!$$...$$\beta_k\,\!$$. to calculate the predicted values,. The error mean square is:

The error mean square, $$MS_E\,\!$$, is an estimate of the variance, $$\sigma^2\,\!$$, of the random error terms, $$\epsilon_i\,\!$$.


 * $$\hat{\sigma}^2=MS_E\,\!$$

Calculation of the Statistic $$F_0\,\!$$
Once the mean squares $$MS_R\,\!$$ and $$MS_E\,\!$$ are known, the statistic to test the significance of regression can be calculated as follows:


 * $$F_0=\frac{MS_R}{MS_E}\,\!$$