Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Storing a correlation matrix


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Storing a correlation matrix
Date   Tue, 18 Apr 2006 16:50:50 +0100

-makematrix- can do this with the -listwise- option. 
-makematrix- is downloadable from SSC. 

Here is a dopey example. 

. sysuse auto, clear 
(1978 Automobile Data)

. makematrix , from(r(rho)) listwise : corr price-rep78

            price         mpg       rep78
price           1
  mpg  -.46859669           1
rep78   .00655327   .40234039           1

Making a matrix from the sample sizes shows the
underlying mess: 

. makematrix , from(r(N)) listwise : corr price-rep78

       price    mpg  rep78
price     74
  mpg     74     74
rep78     69     69     69

There are, naturally, options for saving the matrix, 
and so forth. 

-makematrix- was discussed in the Stata Journal: 

SJ-3-4  pr0011  . . . . . . . .  Speaking Stata: Problems with tables, Part II
        Q4/03   SJ 3(4):420--439                                 (no commands)
        reviews three user-written commands (tabcount, makematrix,
        and groups) as different approaches to tabulation problems

Marcello is an Associate Editor of the Stata Journal, 
and so should have a copy... 

Note that neither SSC, nor the author of -makematrix-, 
nor the Editors of the Stata Journal are to be held 
responsible for the eigenconsequences, positive
or negative, definite or indefinite, of matrices
based on varying subsets of the data. 

Nick 
[email protected] 

Marcello Pagano
 
> Bill Gould in 1999 answered the question of how to store pairwise 
> correlations of a varlist in a matrix--basically calculate the 
> covariance matrix and then convert it into a correlation matrix.  The 
> problem with that answer is that it does not use all the 
> data--basically 
> the difference between -corr-and -pwcorr-.  Does anyone have a better 
> answer, one that uses all the data, like -pwcorr- does?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index