Statalist The Stata Listserver


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

Re: st: Joint -pwcorr- and -spearman-


From   n j cox <n.j.cox@durham.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Joint -pwcorr- and -spearman-
Date   Mon, 21 Aug 2006 21:00:10 +0100

Despite your question, doing this synchronously
does not seem especially important to what you
want here. I suppose you could get two
Statas working more or less in unison, but they
would still need to talk to each other.

A recipe for the hybrid matrix is

1. Get pairwise correlation matrix, say -pearson-.

2. Get pairwise Spearman correlation matrix, say -spearman-.

3. Loop over rows and columns one side of the principal
diagonal:

matrix both = pearson
local I = rowsof(pearson)
forval i = 1/`I' {
local j1 = `i' + 1
forval j = `j1'/`I' {
matrix both[`i',`j'] = spearman[`i',`j']
}
}

4.

matrix list both

As each matrix is square, either the number of rows or
the number of columns suffices to indicate the matrix size.

There are no doubt cuter ways to do it, especially in Mata, but this works.

I guess you want this as a compact display, not for further analysis.

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

Herve STOLOWY

Do you know if there is a possibility to run -pwcorr- and -spearman- jointly (i.e., on the same variables at the same time) in order to get the results in only one matrix: with the -pwcorr- results in the lower left triangle and the -spearman- results in the upper right triangle (or the reverse presentation)?
*
* 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