In statistics, correlation or dependence is any statistical relationship, whether causal or not, between two random variables or bivariate data. Although in the broadest sense, "correlation" may indicate any type of association, in statistics it usually refers to the degree to which a pair of variables are linearly related. Familiar examples of dependent phenomena include the correlation between the height of parents and their offspring, and the correlation between the price of a good and the quantity the consumers are willing to purchase, as it is depicted in the so-called demand curve.
Correlations are useful because they can indicate a predictive relationship that can be exploited in practice. For example, an electrical utility may produce less power on a mild day based on the correlation between electricity demand and weather. In this example, there is a causal relationship, because extreme weather causes people to use more electricity for heating or cooling. However, in general, the presence of a correlation is not sufficient to infer the presence of a causal relationship (i.e., correlation does not imply causation).
Formally, random variables are dependent if they do not satisfy a mathematical property of probabilistic independence. In informal parlance, correlation is synonymous with dependence. However, when used in a technical sense, correlation refers to any of several specific types of mathematical relationship between the conditional expectation of one variable given the other is not constant as the conditioning variable changes; broadly correlation in this specific sense is used when
E(Y|X=x)
x
\rho
r
See main article: Pearson product-moment correlation coefficient.
The most familiar measure of dependence between two quantities is the Pearson product-moment correlation coefficient (PPMCC), or "Pearson's correlation coefficient", commonly called simply "the correlation coefficient". It is obtained by taking the ratio of the covariance of the two variables in question of our numerical dataset, normalized to the square root of their variances. Mathematically, one simply divides the covariance of the two variables by the product of their standard deviations. Karl Pearson developed the coefficient from a similar but slightly different idea by Francis Galton.[4]
A Pearson product-moment correlation coefficient attempts to establish a line of best fit through a dataset of two variables by essentially laying out the expected values and the resulting Pearson's correlation coefficient indicates how far away the actual dataset is from the expected values. Depending on the sign of our Pearson's correlation coefficient, we can end up with either a negative or positive correlation if there is any sort of relationship between the variables of our data set.
The population correlation coefficient
\rhoX,Y
X
Y
\muX
\muY
\sigmaX
\sigmaY
where
\operatorname{E}
\operatorname{cov}
\operatorname{corr}
(-1,1)
If the variables are independent, Pearson's correlation coefficient is 0. However, because the correlation coefficient detects only linear dependencies between two variables, the converse is not necessarily true. A correlation coefficient of 0 does not imply that the variables are independent.
For example, suppose the random variable
X
Y=X2
Y
X
X
Y
X
Y
Even though uncorrelated data does not necessarily imply independence, one can check if random variables are independent if their mutual information is 0.
Given a series of
n
(Xi,Yi)
i=1,\ldots,n
\rhoX,Y
X
Y
rxy \overset{\underset{def
where
\overline{x}
\overline{y}
X
Y
sx
sy
X
Y
Equivalent expressions for
rxy
\begin{align} rxy&=
\sumxiyi-n\bar{x | |
\bar{y}}{n |
s'xs'y}\\[5pt] &=
n\sumxiyi-\sumxi\sumyi | ||||||||||||||
|
~\sqrt{n\sum
2-(\sum | |
y | |
i |
2}}. \end{align} | |
y | |
i) |
s'x
s'y
X
Y
If
x
y
rxy
Consider the joint probability distribution of and given in the table below.
0 | 0 | 0 | ||
---|---|---|---|---|
1 | 0 |
For this joint distribution, the marginal distributions are:
P(X=x)= \begin{cases} | 1 |
3 |
& forx=0\\
2 | |
3 |
& forx=1\end{cases}
P(Y=y)= \begin{cases} | 1 |
3 |
& fory=-1\\
1 | |
3 |
& fory=0\\
1 | |
3 |
& fory=1\end{cases}
This yields the following expectations and variances:
\muX=
2 | |
3 |
\muY=0
2 | |
\sigma | |
X |
=
2 | |
9 |
2 | |
\sigma | |
Y |
=
2 | |
3 |
Therefore:
\begin{align} \rhoX,Y&=
1 | |
\sigmaX\sigmaY |
E[(X-\muX)(Y-\muY)]\\[5pt] &=
1 | |
\sigmaX\sigmaY |
\sumx,y{(x-\muX)(y-\muY)P(X=x,Y=y)}\\[5pt] &=
3\sqrt{3 | |
See main article: Spearman's rank correlation coefficient and Kendall tau rank correlation coefficient.
Rank correlation coefficients, such as Spearman's rank correlation coefficient and Kendall's rank correlation coefficient (τ) measure the extent to which, as one variable increases, the other variable tends to increase, without requiring that increase to be represented by a linear relationship. If, as the one variable increases, the other decreases, the rank correlation coefficients will be negative. It is common to regard these rank correlation coefficients as alternatives to Pearson's coefficient, used either to reduce the amount of calculation or to make the coefficient less sensitive to non-normality in distributions. However, this view has little mathematical basis, as rank correlation coefficients measure a different type of relationship than the Pearson product-moment correlation coefficient, and are best seen as measures of a different type of association, rather than as an alternative measure of the population correlation coefficient.[7] [8]
To illustrate the nature of rank correlation, and its difference from linear correlation, consider the following four pairs of numbers
(x,y)
(0, 1), (10, 100), (101, 500), (102, 2000).
As we go from each pair to the next pair
x
y
x
y
y
x
The information given by a correlation coefficient is not enough to define the dependence structure between random variables.[9] The correlation coefficient completely defines the dependence structure only in very particular cases, for example when the distribution is a multivariate normal distribution. (See diagram above.) In the case of elliptical distributions it characterizes the (hyper-)ellipses of equal density; however, it does not completely characterize the dependence structure (for example, a multivariate t-distribution's degrees of freedom determine the level of tail dependence).
Distance correlation[10] [11] was introduced to address the deficiency of Pearson's correlation that it can be zero for dependent random variables; zero distance correlation implies independence.
The Randomized Dependence Coefficient[12] is a computationally efficient, copula-based measure of dependence between multivariate random variables. RDC is invariant with respect to non-linear scalings of random variables, is capable of discovering a wide range of functional association patterns and takes value zero at independence.
For two binary variables, the odds ratio measures their dependence, and takes range non-negative numbers, possibly infinity: . Related statistics such as Yule's Y and Yule's Q normalize this to the correlation-like range . The odds ratio is generalized by the logistic model to model cases where the dependent variables are discrete and there may be one or more independent variables.
The correlation ratio, entropy-based mutual information, total correlation, dual total correlation and polychoric correlation are all also capable of detecting more general dependencies, as is consideration of the copula between them, while the coefficient of determination generalizes the correlation coefficient to multiple regression.
The degree of dependence between variables and does not depend on the scale on which the variables are expressed. That is, if we are analyzing the relationship between and, most correlation measures are unaffected by transforming to and to, where a, b, c, and d are constants (b and d being positive). This is true of some correlation statistics as well as their population analogues. Some correlation statistics, such as the rank correlation coefficient, are also invariant to monotone transformations of the marginal distributions of and/or .
Most correlation measures are sensitive to the manner in which and are sampled. Dependencies tend to be stronger if viewed over a wider range of values. Thus, if we consider the correlation coefficient between the heights of fathers and their sons over all adult males, and compare it to the same correlation coefficient calculated when the fathers are selected to be between 165 cm and 170 cm in height, the correlation will be weaker in the latter case. Several techniques have been developed that attempt to correct for range restriction in one or both variables, and are commonly used in meta-analysis; the most common are Thorndike's case II and case III equations.[13]
Various correlation measures in use may be undefined for certain joint distributions of and . For example, the Pearson correlation coefficient is defined in terms of moments, and hence will be undefined if the moments are undefined. Measures of dependence based on quantiles are always defined. Sample-based statistics intended to estimate population measures of dependence may or may not have desirable statistical properties such as being unbiased, or asymptotically consistent, based on the spatial structure of the population from which the data were sampled.
Sensitivity to the data distribution can be used to an advantage. For example, scaled correlation is designed to use the sensitivity to the range in order to pick out correlations between fast components of time series.[14] By reducing the range of values in a controlled manner, the correlations on long time scale are filtered out and only the correlations on short time scales are revealed.
The correlation matrix of
n
X1,\ldots,Xn
n x n
C
(i,j)
cij:=\operatorname{corr}(Xi,X
|
i,Xj)}{\sigma
Xi |
\sigma | |
Xj |
Xi/\sigma(Xi)
i=1,...,n
\sigma
\sigma
The correlation matrix is symmetric because the correlation between
Xi
Xj
Xj
Xi
A correlation matrix appears, for example, in one formula for the coefficient of multiple determination, a measure of goodness of fit in multiple regression.
In statistical modelling, correlation matrices representing the relationships between variables are categorized into different correlation structures, which are distinguished by factors such as the number of parameters required to estimate them. For example, in an exchangeable correlation matrix, all pairs of variables are modeled as having the same correlation, so all non-diagonal elements of the matrix are equal to each other. On the other hand, an autoregressive matrix is often used when variables represent a time series, since correlations are likely to be greater when measurements are closer in time. Other examples include independent, unstructured, M-dependent, and Toeplitz.
In exploratory data analysis, the iconography of correlations consists in replacing a correlation matrix by a diagram where the "remarkable" correlations are represented by a solid line (positive correlation), or a dotted line (negative correlation).
In some applications (e.g., building data models from only partially observed data) one wants to find the "nearest" correlation matrix to an "approximate" correlation matrix (e.g., a matrix which typically lacks semi-definite positiveness due to the way it has been computed).
In 2002, Higham[15] formalized the notion of nearness using the Frobenius norm and provided a method for computing the nearest correlation matrix using the Dykstra's projection algorithm, of which an implementation is available as an online Web API.[16]
This sparked interest in the subject, with new theoretical (e.g., computing the nearest correlation matrix with factor structure[17]) and numerical (e.g. usage the Newton's method for computing the nearest correlation matrix[18]) results obtained in the subsequent years.
Similarly for two stochastic processes
\left\{Xt\right\}t\inl{T
\left\{Yt\right\}t\inl{T
See also: Normally distributed and uncorrelated does not imply independent. The conventional dictum that "correlation does not imply causation" means that correlation cannot be used by itself to infer a causal relationship between the variables.[20] This dictum should not be taken to mean that correlations cannot indicate the potential existence of causal relations. However, the causes underlying the correlation, if any, may be indirect and unknown, and high correlations also overlap with identity relations (tautologies), where no causal process exists. Consequently, a correlation between two variables is not a sufficient condition to establish a causal relationship (in either direction).
A correlation between age and height in children is fairly causally transparent, but a correlation between mood and health in people is less so. Does improved mood lead to improved health, or does good health lead to good mood, or both? Or does some other factor underlie both? In other words, a correlation can be taken as evidence for a possible causal relationship, but cannot indicate what the causal relationship, if any, might be.
The Pearson correlation coefficient indicates the strength of a linear relationship between two variables, but its value generally does not completely characterize their relationship.[21] In particular, if the conditional mean of
Y
X
\operatorname{E}(Y\midX)
X
\operatorname{E}(Y\midX)
The adjacent image shows scatter plots of Anscombe's quartet, a set of four different pairs of variables created by Francis Anscombe.[22] The four
y
These examples indicate that the correlation coefficient, as a summary statistic, cannot replace visual examination of the data. The examples are sometimes said to demonstrate that the Pearson correlation assumes that the data follow a normal distribution, but this is only partially correct.[4] The Pearson correlation can be accurately calculated for any distribution that has a finite covariance matrix, which includes most distributions encountered in practice. However, the Pearson correlation coefficient (taken together with the sample mean and variance) is only a sufficient statistic if the data is drawn from a multivariate normal distribution. As a result, the Pearson correlation coefficient fully characterizes the relationship between variables if and only if the data are drawn from a multivariate normal distribution.
If a pair
(X,Y)
\operatorname{\boldsymbollE}(X\midY)
Y
\operatorname{\boldsymbollE}(Y\midX)
X~.
\rhoX,Y
X
Y ,
X
Y
\operatorname{\boldsymbollE}(Y\midX)=\operatorname{\boldsymbollE}(Y)+\rhoX,Y ⋅ \sigmaY ⋅
X-\operatorname{\boldsymbollE | |
(X) }{ |
\sigmaX} ,
where
\operatorname{\boldsymbollE}(X)
\operatorname{\boldsymbollE}(Y)
X
Y ,
\sigmaX
\sigmaY
X
Y ,
The empirical correlation
r
\rho~.
\rho
where
FHyp
This density is both a Bayesian posterior density and an exact optimal confidence distribution density.[23] [24]