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

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

  • 'gt' — Correlation is greater than zero

  • 'lt' — Correlation is less than zero

Using the 'pairwise' option for the 'rows' parameter might return a matrix that is not positive definite. The 'complete' option always returns a positive definite matrix, but in general the estimates will be 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 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.

See Also

corrcoef, partialcorr, corrcov, tiedrank

  


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