I have to calculate:
gamma=(I-K*A^-1)*OLS;
where I
is the identity matrix, K
and A
are diagonal matrices of the same size, and OLS
is the ordinary least squares estimate of the parameters.
I do this in Matlab using:
gamma=(I-A\K)*OLS;
However I then have to calculate:
gamma2=(I-K^2*A-2)*OLS;
I calculate this in Matlab using:
gamma2=(I+A\K)*(I-A\K)*OLS;
Is this correct?
Also I just want to calculate the variance of the OLS
parameters:
The formula is simple enough:
Var(B)=sigma^2*(Delta)^-1;
Where sigma
is a constant and Delta
is a diagonal matrix containing the eigenvalues.
I tried doing this by:
Var_B=Delta\sigma^2;
But it comes back saying matrix dimensions must agree?
Please can you tell me how to calculate Var(B)
in Matlab, as well as confirming whether or not my other calculations are correct.