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]

From |
Red Owl <[email protected]> |

To |
<[email protected]> |

Subject |
RE: RE: st: Pearson/Spearman Correlation Matrix |

Date |
Sun, 12 Jan 2014 12:10:48 -0500 |

Ahmed, You asked two questions, which I'll answer in sequence. First, you asked about how to modify my suggested code or how to use Daniel Klein's -corsp- program (which more efficiently and more generally implements the same strategy that I followed in my code). I would suggest you just use Daniel Klein's -corsp-, which I copy for you now from http://www.stata.com/statalist/archive/2014-01/msg00352.html: **** Begin Daniel Klein's -corsp- Program Code ***** *! version 1.0.0 09oct2013 pr corsp ,rclass vers 9.2 syntax varlist(min = 2 num) [if] [in] marksample touse qui cou if (`touse') if !(r(N)) err 2000 loc nvars : word count `varlist' tempname R rho qui cor `varlist' mat `R' = r(C) qui spearman `varlist' mat `rho' = r(Rho) forv c = 1/`nvars' { forv r = `= `c' + 1'/`nvars' { mat `R'[`r', `c'] = `rho'[`r', `c'] } } matlist `R' ret mat R = `R' end **** End Daniel Klein's Program Code ***** To apply Daniel's -corsp- program do the following: (1) Load your data set and then install Daniel's program by copying his code. (2) Then run his program by entering -corsp X1 X2 X3 X4 X5 X6 X7- Second, you asked about how to report p-values for the correlations and about differences between Stata's commands -corr- and -pwcorr-. As you will read in the help files for those two commands, -corr- applies listwise (also called casewise) deletion of missing values, whereas -pwcorr- by default applies pairwise deletion of missing values unless you add the option -listwise-. If you have complete data, there will be no difference between the two sets of results with the defaults for -corr- and -pwcorr-. If you wonder why Daniel chose to use -corr- to obtain the Pearson r results with -corsp-, I believe he did that because -pwcorr- does not output a complete r matrix in the r class results. If you want to get the p-values for the Pearson r's reported in Daniel's -corsp-, you can do the following: (1) Make sure you are using listwise deletion of missing values and the same sample in both -pwcorr- and -spearman-. (2) Run -pwcorr X1 X2 X3 X4 X5 X6 X7, listwise sig- to obtain p-values for the Pearson r results. (3) Run -spearman X1 X2 X3 X4 X5 X6 X7, stats(p)- to obtain p-values for the Spearman rho results. Hope that helps. Red Owl [email protected] * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**RE: RE: st: Pearson/Spearman Correlation Matrix***From:*"Abdalla, Ahmed" <[email protected]>

- Prev by Date:
**RE: st: Pearson/Spearman Correlation Matrix** - Next by Date:
**RE: RE: st: Pearson/Spearman Correlation Matrix** - Previous by thread:
**RE: st: Pearson/Spearman Correlation Matrix** - Next by thread:
**RE: RE: st: Pearson/Spearman Correlation Matrix** - Index(es):