# Calculating Covariance Matrix (Regression Analysis)

#### garunas

##### New Member
Im having difficulty in trying to compute the Covariance Matrix. I think Im missing out an equation to be honest. Here's what I've been given in the question:

Model: Y = theta_0 + X*theta_1 + (X^2)*theta_2 + epsilon
Design:
Y | 4, 3, 2, 3, 8
X |-2,-1,0, 1, 2

Now the question asks to compute the Covariance Matrix of the standard LSE. I've managed to start the question and found that theta hat = (2, 0.8, 1)^T and here is where Im stuck. I dont know how to go about computing the Covariance Matrix. Any hints from anyone would be amazing! Thank you #### noetsi

##### Fortran must die
My hint would be to plug the raw data into software and ask it for the covariance matrix, but perhaps you lack the raw data #### Dason

##### Ambassador to the humans
Well you can do it by hand and it's not horrible. But they do have the raw data.

#### noetsi

##### Fortran must die
It's really not that hard to do a covariance matrix by hand but I would check my results by also running it in some software. Rounding errors become the biggest problem in most matrix, especially if you move on to a correlation matrix.

#### ledzep

##### Point Mass at Zero
Use the famous formula for working out Covariance Matrix:

[TEX] s^2 * Inv((X'X))[/TEX]

where Inv stands for Inverse
You have got your X and Y matrix there. This is just matrix multiplication.

Might just have be a little careful here as you have a quadratic term in your model. hence, your design matrix should have coeff for squared term which are basically the square of the coeff for x.

X'X inverse is already worked out for LSE.
In fact, it shouldn't be much work as you have already done the hard work when working out the Least Squares Estimates.

Useful Link:

http://www.stat.purdue.edu/~jennings/stat514/stat512notes/topic3.pdf

Last edited: