Three related statistical coefficients in Matlab to realize

Original link: https://blog.csdn.net/cherish_now_forever/article/details/75233282

In the multivariate analysis, we often use the correlation coefficient. There are three commonly used correlation coefficients: Pearson correlation coefficient, Kendall correlation coefficient and Spearman correlation coefficient.

A, Pearson correlation coefficient

Pearson correlation coefficient is a method of calculating linear correlation of the British statistician Pearson raised in the 20th century.

Be understood in terms of linear mathematical university level, it is a bit more complicated, can be seen as a vector cosine angle between the two sets of data.

Pearson correlation constraints

  • 1 linear relationship between two variables
  • 2 variable is a continuous variable
  • 3 variables are in line with normal distribution and the bivariate distribution is also consistent with the normal distribution
  • 4 two independent variables

 

Pearson correlation coefficients apply to:

(1) a linear relationship between two variables, are continuous data.

(2) two variables are generally normal or near-normal monomodal distribution.

(3) the observed values ​​for these variables are paired, each pair are independent observations.

Two, Kendall correlation coefficient

Kendall correlation coefficient is Maurice Kendall named, and its value is often expressed by the Greek letter τ (tau). Kendall correlation coefficient indicative of correlation is used to reflect categorical variables, classification applies to the two classification variables are ordered, Kendall correlation coefficients in the range between -1 to 1, when τ 1, showing two random variables have the same rank correlation; is -1 when τ represents random variables has two opposite rank correlation; is 0 when τ represents two random variables are independent.

Three, Spearman correlation coefficients

Spearman rank correlation coefficient, also known as rank correlation coefficient, Charles Spearman named after it, and its value is often expressed by the Greek letter ρ (rho). It is linearly related to the size of the rank analysis using two variables, Spearman rank correlation coefficient used to estimate the two variables X, a correlation between the Y, where the correlation between variables can be described using a monotonic function. If the two sets of values ​​of two variables of the same two elements do not exist, then, when one of the variables can be expressed (i.e., the same trend two variables) is a monotonic function of good another variable, ρ between two variables can reach +1 or -1.

Four, Matlab program

1.X and Y is a vector of values ​​of two variables consisting of

Pearson correlation coefficient: corr (X, Y, 'type', 'Pearson')

Kendall correlation: corr (X, Y, 'type', 'Kendall')

Spearman correlation: corr (X, Y, 'type', 'Spearman')

2.X is a data matrix, as variable values

Pearson correlation coefficient: corr (X, 'type', 'Pearson')

Kendall correlation: corr (X, 'type', 'Kendall')

Spearman correlation: corr (X, 'type', 'Spearman')

Guess you like

Origin blog.csdn.net/weixin_44719615/article/details/102760890