help corsp

Title

corsp -- Pearson and Spearman correlation matrix

Syntax

corsp varlist [if] [in] [ , options ]

by is allowed

Description

corsp displays a correlation matrix of the variables in
varlist. By default, Pearson's correlation coefficients are shown
in the lower triangle, including the diagonal, while Spearman's rank
correlations appear above the diagonal. Optionally, corsp
calculates Kendall's tau.

Type corsp without arguments to replay results.

Options

pw calculates pairwise correlation coefficients. By default,
casewise deletion is used.

lower(coef) and upper(coef) specify which coefficents
are shown below and above the diagonal. The available coefficients
are

r Pearson correlation coefficient

rho Spearman's rank correlation coefficient

taua Kendall's tau_a rank correlation coefficient

taub Kendall's tau_b rank correlation coefficient

switch displays coefficents specified in lower()
above the diagonal and those specified in upper() in
the lower triangle.

sig reports p-values below each correlation coefficient.

print(#) specifies the significant level of coefficients to
be displayed. Coefficients with larger p-values are left blank.

bonferroni calculates Bonferroni-adjusted p-values.

sidak calculates Sidak-adjusted p-values.

returnrp returns the results matrix with coefficients and
p-values combined.

Examples

Load example dataset

. sysuse auto

Calculate Pearson and Spearman correlation matrix

. corsp price mpg rep78

Calculate pairwise correlations

. corsp price mpg rep78 , pw

Replay results, this time with Pearson correlatios
above the diagonal

. corsp , lower(rho) upper(r)

Calculate Spearman's and Kendall's rank correlations
with Bonferroni-adjusted p-values

. corsp price mpg rep78 , lower(rho) upper(taua) sig bonferroni

Saved results

corsp saves the following in r():

Macros

r(cmd) corsp

r(lower) coef from lower()

r(upper) coef from upper()

Matrices

r(R) correlation coefficients

r(P) two-sided p-values (possibly adjusted)

r(Nobs) number of observations used

r(C) correlation coefficients (Pearson)

r(Rho) correlation coefficients (Spearman)

r(Tau_a) correlation coefficients (Kendall)

r(Tau_b) correlation coefficients (Kendall)

r(C_p) two-sided p-values (possibly adjusted)

r(Rho_p) two-sided p-values (possibly adjusted)

r(Tau_a_p) two-sided p-values (possibly adjusted)

r(Tau_b_p) two-sided p-values (possibly adjusted)

r(RP) coefficients and p-values (returnrp only)

Acknowledgments

Alina Sigel reported a bug on
Statalist.

This problem was suggested by Ahmed Abdalla on
Statalist
and an anonymous poster on
Stata-Forum.

Author

Daniel Klein, University of Kassel, klein.daniel.81@gmail.com

Also see

Online: correlate, spearman

if installed: corrtbl