I would like to create a full covariance matrix and then invert the matrix.
Say that I compute the covariance as follows:
This produces:
My main problem is how to instead get it to compute the matrix such that each cell is filled in. In other words, I would like to create a full covariance matrix instead of the lower triangular matrix.
And then would this be the correct way to invert the matrix?
This produces:
Say that I compute the covariance as follows:
Code:
sysuse auto2, clear corr price mpg headroom trunk weight length, covariance
Code:
| price mpg headroom trunk weight length -------------+------------------------------------------------------ price | 8.7e+06 mpg | -7996.28 33.472 headroom | 285.721 -2.02536 .715707 trunk | 3965.67 -14.3924 2.39559 18.2962 weight | 1.2e+06 -3629.43 317.873 2234.66 604030 length | 28360.3 -102.514 9.72556 69.2025 16370.9 495.79
And then would this be the correct way to invert the matrix?
Code:
matrix a = r(C) matrix b = invsym(a) matrix list b
Code:
symmetric b[6,6] price mpg headroom trunk weight length price 1.858e-07 mpg .00001593 .08966729 headroom .00013193 .00988956 2.5935193 trunk -.00002065 .00125248 -.31581775 .15498871 weight -8.212e-07 .00027199 -.00069926 .00020868 .00002079 length .00002008 .00827906 .01079437 -.02088888 -.00059878 .02505605
Comment