corr
Linear or rank correlation
Description
[
specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntaxes. For example,
rho
,pval
] = corr(___,Name,Value
)'Type','Kendall'
specifies computing Kendall's tau
correlation coefficient.
Examples
Input Arguments
Output Arguments
More About
Tips
The difference between corr(X,Y)
and the MATLAB® function corrcoef(X,Y)
is that
corrcoef(X,Y)
returns a matrix of correlation coefficients for
two column vectors X
and Y
. If
X
and Y
are not column vectors,
corrcoef(X,Y)
converts them to column vectors.
Algorithms
When you specify the Weights
name-value argument,
corr
calculates the Pearson correlation by weighting the
variance and covariance calculations. For the Spearman correlation (which is based on
ranks), corr
calculates weighted ranks as proposed by [5]. To calculate the
Kendall correlation (which is based on counts of permutations),
corr
extends the weighted counts algorithm in [6] to account for
ties.
References
[1] Gibbons, J.D. Nonparametric Statistical Inference. 2nd ed. M. Dekker, 1985.
[2] Hollander, M., and D.A. Wolfe. Nonparametric Statistical Methods. Wiley, 1973.
[3] Kendall, M.G. Rank Correlation Methods. Griffin, 1970.
[4] Best, D.J., and D.E. Roberts. "Algorithm AS 89: The Upper Tail Probabilities of Spearman's rho." Applied Statistics, 24:377-379.
[5] Bailey, Paul, and Ahmad Emad (2023). wCorr: Weighted Correlations. R package version 1.9.7, https://american-institutes-for-research.github.io/wCorr.
[6] Van Doorn, Johnny, et al. "Using the Weighted Kendall Distance to Analyze Rank Data in Psychology." The Quantitative Methods for Psychology, vol. 17, no. 2, June 2021, pp. 154–65.
Extended Capabilities
Version History
Introduced before R2006aSee Also
corrcoef
| partialcorr
| corrcov
| tiedrank