Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: summarize correlation matrix


From   "Cohen, Elan" <cohened@upmc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: summarize correlation matrix
Date   Fri, 18 May 2012 17:59:56 +0000

Thank you all for your wise words and cautious notes.  Unfortunately, I'm just the programmer in this case. 

For any interested, here's how I converted a correlation matrix into a Stata variable.


sysuse auto, clear
ds, has(type numeric)
keep `r(varlist)'
corr
mat C = r(C)
clear
svmat C
// Only keep lower half
forv i=1/`c(k)' {
	qui replace C`i' = . in 1/`i'
}
g i = _n
reshape long C, i(i) j(junk)
drop i junk
drop if mi(C)
su C, d


- Elan


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Friday, May 18, 2012 11:47
To: 'statalist@hsphsun2.harvard.edu'
Subject: st: RE: summarize correlation matrix

-corrci- (SJ) makes this easy. -corrci- was written primarily to support confidence interval calculation for correlations but has an option to save a correlation matrix to a dataset. The analyses allowed by -corrci- raise the question of whether you should be summarizing correlations on a z scale, not an r scale. 

See 

SJ-10-4 pr0041_1  . . . . . . . . . . . . . . . . . Software update for corrci
        (help corrci, corrcii if installed) . . . . . . . . . . . .  N. J. Cox
        Q4/10   SJ 10(4):691
        update to fix corrci so that it always saves r-class results

SJ-8-3  pr0041  .  Speaking Stata: Corr. with confidence, Fisher's z revisited
        (help corrci, corrcii if installed) . . . . . . . . . . . .  N. J. Cox
        Q3/08   SJ 8(3):413--439
        reviews Fisher's z transformation and its inverse, the
        hyperbolic tangent, and reviews their use in inference
        with correlations

The suggestion is that you read the paper in SJ 8-3 ( which is accessible at http://www.stata-journal.com/sjpdf.html?articlenum=pr0041 ) 

but download the updated software from the files for SJ 10-4. 

All that said, I am not sure quite what useful information is given by some of these numbers. I think of problems in which showing the overall distribution of the correlations is of some descriptive value, which was precisely why I provided that option, but the standard deviation? Also, if correlations are generally weak, then either you are summarizing noise or you are asking the wrong questions about relationships! 

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


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Cohen, Elan
Sent: 18 May 2012 16:21
To: statalist@hsphsun2.harvard.edu
Subject: st: summarize correlation matrix

I have a large correlation matrix after running -corr- on my dataset.  I'd now like to summarize that matrix, i.e. get the mean, sd, plot a histogram of the p*(p-1)/2 correlation values (where p is the number of variables).  I'm not quite savvy enough in Mata and it's proving difficult in standard Stata programming.  I'd greatly appreciate an answer using either.

Thank you,

- Elan


--
Elan D Cohen, MS
Center for Research on Health Care Data Center
University of Pittsburgh 
cohened@upmc.edu 



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index