Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

corr - Linear or rank correlation

Syntax

RHO = corr(X)
RHO = corr(X,Y,...)
[RHO,PVAL] = corr(...)
[...] = corr(...,param1,val1,param2,val2,...)

Description

RHO = corr(X) returns a p-by-p matrix containing the pairwise linear correlation coefficient between each pair of columns in the n-by-p matrix X.

RHO = corr(X,Y,...) returns a p1-by-p2 matrix containing the pairwise correlation coefficient between each pair of columns in the n-by-p1 and n-by-p2 matrices X and Y.

[RHO,PVAL] = corr(...) also returns PVAL, a matrix of p-values for testing the hypothesis of no correlation against the alternative that there is a nonzero correlation. Each element of PVAL is the p-value for the corresponding element of RHO. If PVAL(i, j) is small, say less than 0.05, then the correlation RHO(i, j) is significantly different from zero.

[...] = corr(...,param1,val1,param2,val2,...) specifies additional parameters and their values. The following table lists the valid parameters and their values.

ParameterValues
'type'
  • 'Pearson' (the default) computes Pearson's linear correlation coefficient

  • 'Kendall' computes Kendall's tau

  • 'Spearman' computes Spearman's rho

'rows'
  • 'all' (the default) uses all rows regardless of missing values (NaNs)

  • 'complete' uses only rows with no missing values

  • 'pairwise'computes RHO(i,j) using rows with no missing values in column i or j

'tail'

— The alternative hypothesis against which to compute p-values for testing the hypothesis of no correlation

  • 'both' — Correlation is not zero (the default)

  • 'right' — Correlation is greater than zero

  • 'left' — Correlation is less than zero

Using the 'pairwise' option for the 'rows' parameter may return a matrix that is not positive definite. The 'complete' option always returns a positive definite matrix, but in general the estimates are based on fewer observations.

corr computes p-values for Pearson's correlation using a Student's t distribution for a transformation of the correlation. This correlation is exact when X and Y are normal. corr computes p-values for Kendall's tau and Spearman's rho using either the exact permutation distributions (for small sample sizes), or large-sample approximations.

corr computes p-values for the two-tailed test by doubling the more significant of the two one-tailed p-values.

References

[1] Gibbons, J.D. (1985) Nonparametric Statistical Inference, 2nd ed., M. Dekker.

[2] Hollander, M. and D.A. Wolfe (1973) Nonparametric Statistical Methods, Wiley.

[3] Kendall, M.G. (1970) Rank Correlation Methods, Griffin.

[4] Best, D.J. and D.E. Roberts (1975) "Algorithm AS 89: The Upper Tail Probabilities of Spearman's rho", Applied Statistics, 24:377-379.

See Also

corrcoef, partialcorr, corrcov, tiedrank

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS