Oftentimes we would like to display Pearson correlations below the diagonal and Spearman correlations above the diagonal. Two built-in commands, pwcorr
and spearman
, can do the job. However, we have to manually combine Stata output tables when producing the correlation table in the manuscript, which is time-consuming.
I find this fantastic module written by Daniel Klein. His command will return one table that combines Pearson and Spearman correlations and needs the fewest further edits. Thanks Daniel and please find his work here.
A sample command is as follows:
corsp varlist, pw sig
To install Daniel’s module, type ssc install corsp
in Stata’s command window.
A good technical comparison of Pearson and Spearman correlations can be found here.
Dear Professor Chen,
Thank you very much for providing this useful Stata command for preparing the correlations matrix. I just have one follow-up question. You may notice that sometimes we are required to show the significance (i.e. p-value) of the correlation coefficients. Can you kindly advise how I can modify the command in order to show the significance?
Thank you in advance. You help is much appreciated.