corrcoef

Correlation coefficients

๐Ÿ“ Syntax

  • R = corrcoef(M)

๐Ÿ“ฅ Input argument

  • M - a vector or matrix

๐Ÿ“ค Output argument

  • R - Correlation coefficients of M.

๐Ÿ“„ Description

R = corrcoef(M) returns the matrix of correlation coefficients forM, where the columns ofM represent random variables and the rows represent observations.

The Pearson correlation coefficient between variables XX

and YY

is: rXY=cov(X,Y)ฯƒXฯƒY=โˆ‘i=1n(xiโˆ’xห‰)(yiโˆ’yห‰)โˆ‘i=1n(xiโˆ’xห‰)2โˆ‘i=1n(yiโˆ’yห‰)2r_{XY} = \frac{\text{cov}(X,Y)}{\sigma_X \sigma_Y} = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=1}^n (x_i - \bar{x})^2 \sum_{i=1}^n (y_i - \bar{y})^2}}

where xห‰\bar{x}

and yห‰\bar{y}

are the sample means, and ฯƒX\sigma_X

, ฯƒY\sigma_Y

are the standard deviations.

The correlation coefficient ranges from -1 to +1, where -1 indicates perfect negative correlation, +1 indicates perfect positive correlation, and 0 indicates no linear correlation.

๐Ÿ’ก Example

๐Ÿ”— See also

cov, mean.

๐Ÿ•” History

Version
๐Ÿ“„ Description

1.0.0

initial version

Last updated

Was this helpful?