A colleague wanted display of correlations from correlate with fewer decimal places. The best answer I could come up with was pushing the resulting matrix through matrix list.
The header text -- here symmetric rho[4.4] -- could be suppressed with an option noheader.
A similar trick should work with commands for rank correlations.
The code for pwcorr could be hacked to allow a user-specified format. But in that case, as in the others, I agree with my colleague's implication that there should be an option on the official commands to do this directly. Am I missing something simpler?
Incidentally, corrci from the Stata Journal has such an option, and several others, but there are always users unwilling or unable to install community-contributed commands.
Code:
* You can pick up the correlation result as a matrix and display the elements as you wish. Or you can push that into your own matrix, which is not so ephemeral.
. sysuse auto, clear
(1978 automobile data)
. corr length-gear_ratio
(obs=74)
| length turn displa~t gear_r~o
-------------+------------------------------------
length | 1.0000
turn | 0.8643 1.0000
displacement | 0.8351 0.7768 1.0000
gear_ratio | -0.6964 -0.6763 -0.8289 1.0000
. mat li r(C), format(%9.2f)
symmetric r(C)[4,4]
length turn displacement gear_ratio
length 1.00
turn 0.86 1.00
displacement 0.84 0.78 1.00
gear_ratio -0.70 -0.68 -0.83 1.00
. mat rho = r(C)
. mat list rho, format(%3.2f)
symmetric rho[4,4]
length turn displacement gear_ratio
length 1.00
turn 0.86 1.00
displacement 0.84 0.78 1.00
gear_ratio -0.70 -0.68 -0.83 1.00
A similar trick should work with commands for rank correlations.
The code for pwcorr could be hacked to allow a user-specified format. But in that case, as in the others, I agree with my colleague's implication that there should be an option on the official commands to do this directly. Am I missing something simpler?
Incidentally, corrci from the Stata Journal has such an option, and several others, but there are always users unwilling or unable to install community-contributed commands.
Code:
SJ-21-3 pr0041_4 . . . . . . . . . . . . . . . . . Software update for corrci
(help corrci, corrcii if installed) . . . . . . . . . . . . N. J. Cox
Q3/21 SJ 21(3):847
improves explanation of the format() option and fixes a bug
concerning saving results to a new dataset
SJ-20-4 pr0041_3 . . . . . . . . . . . . . . . . . Software update for corrci
(help corrci, corrcii if installed) . . . . . . . . . . . . N. J. Cox
Q4/20 SJ 20(4):1028--1030
corrects code for a bias correction used if (and only if) the
fisher option is specified
SJ-17-3 pr0041_2 . . . . . . . . . . . . . . . . . Software update for corrci
(help corrci, corrcii if installed) . . . . . . . . . . . . N. J. Cox
Q3/17 SJ 17(3):779
new options added
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
. corrci length-gear_ratio
(obs=74)
correlations and 95% limits
length turn 0.864 0.792 0.913
length displacement 0.835 0.750 0.893
length gear_ratio -0.696 -0.798 -0.556
turn displacement 0.777 0.667 0.854
turn gear_ratio -0.676 -0.784 -0.530
displacement gear_ratio -0.829 -0.889 -0.741
. corrci length-gear_ratio, format(%3.2f)
(obs=74)
correlations and 95% limits
length turn 0.86 0.79 0.91
length displacement 0.84 0.75 0.89
length gear_ratio -0.70 -0.80 -0.56
turn displacement 0.78 0.67 0.85
turn gear_ratio -0.68 -0.78 -0.53
displacement gear_ratio -0.83 -0.89 -0.74
* corrci has other options, including matrix output and saving to a dataset

Comment