Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: How to estimate var-cov matrix from data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How to estimate var-cov matrix from data
Date   Mon, 16 Feb 2004 11:34:18 -0000

In addition, 

. findit covariance matrix 

points to an FAQ by Bill Gould, 
a program -corrmat- by Shannon Driver, 
a program -matcorr- by myself, 
etc. 

Nick 
n.j.cox@durham.ac.uk 

Richard Williams
 
wei liu

> >I have a very easy question to ask. I have two random
> >variables with 1000 observations each. How can I
> >generate the variance-covariance matrix for them? I
> >wanna save this matrix as a matrix variable for
> >further use. Is there a simple way to do so? Can I
> >further generalize this method for higher dimension?
> 
> Try -help mataccum-
> 
> The commands would be something like
> 
> . mat accum cov = x y, noconstant deviations
> (obs=1000)
> 
> . mat cov = cov/(_N-1)
> 
> . mat list cov
> 
> symmetric cov[2,2]
>             x          y
> x  9.0365155
> y  3.0502898   3.982194
> 
> 
> To confirm that you did it right,
> 
> . corr x y, cov
> (obs=1000)
> 
>               |        x        y
> -------------+------------------
>             x |  9.03652
>             y |  3.05029  3.98219
> 
> You can do it with more than 2 variables; and you can make 
> things more 
> complicated by using if, in and weights parameters.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index