How to calculate the prediction interval given the variance-covariance matrix in a multiple linear model?

1.9k Views Asked by At

Given this matrix I'm trying to manually compute the prediction interval for when UNEM=7.5 HGRAD=17109 and INC=3350.The definition for the prediction interval I'm using is:

enter image description here

My question is from the data given how do I get S^2 and exactly what part of the formula is given by the variance-covariance matrix.

The other data given in the earlier part of the question is below:

enter image description here

2

There are 2 best solutions below

2
On BEST ANSWER

The $S^2$ you refer to is given by $$ S^2 = \frac{1}{n - p} \lVert Y - X \hat{\beta} \rVert^2 $$ where $Y$ is our observed values, $X$ is the model matrix and $X\hat{\beta} = X(X^TX)^{-1}X^T \beta$ are our fitted values of $Y$. This value is useful since it is an unbiased estimate of the true variance $\sigma^2$.

As for how to calculate $S^2$, $S$ is given in the model summary as the residual standard error (in your case 670.4). You don't calculate it from the variance-covariance matrix, and it is accessed in your code as summary(Model1)$sigma (it's often denoted by $\tilde{\sigma}$ instead of $S$, hence the name).

0
On
vcov(lm.object) 

Gives you the covariance matrix of the coefficients, i.e., $s^2(X'X)^{-1}$. As for the prediction define $x_0 = (1, 7.5, 17109, 3350)^T$, and then

sd.pred = sqrt( lm.object$sigma ^ 2 + t( x_0 ) %*% vcov(lm.object) %*% x_0  )