Korélasi
Artikel ieu ngeunaan koefisien korelasi antara dua variable acak. Watesan korelasi bisa ogé hartina korelasi silang dua fungsi.

Dina tiori probabiliti jeung statistik, korelasi, disebut ogé koefisien korelasi, nyaéta ukuran numerik ngeunaan kuatna hubungan linier antara dua variabel acak. Dina pamakéan statistik nu ilahar, korelas atawa ko-relasi nujul kana pakaitna dua variabel bebéas. Dina hal nu leuwih lega, aya sababaraha koefisien, ukuran tingkat pakait nu dicokot tina data alam atawa data asli.

gedéna béda korelasi dipaké keur kaayaan nu béda. Nu panghadéna nyaéta korefisien korelasi produk-momen Pearson, nu ditangtukeun ku cara ngabagi kovarian dua variabel ku hasil kali simpangan bakuna. Korelasi mimiti diwanohkeun ku Francis Galton.

Koefisien produk-momen Pearson

Pasipatan Matematika 

Korelasi ρxy antara dua variabel acak X and Y jeung nilai ekspektasi μX jeung μY sarta simpangan baku σX jeung σY dihartikeun:

Anggap μX=E(X), 
σX2=E(X2)-E2(X) tur saperti keur Y, bisa ogé dituliskeun jadi:

Korélasi bisa dihartikeun lamun simpangan baku kawengku tur salah sahijina lain enol.  Rumusan itu dina kateusaruaan Cauchy-Schwarz yén korelasi teu bisa leuwih ti 1 dina nilai mutlakna.

Korelasi sarua jeung 1 lamun mibanda hubungan naek sacara liner, −1 lamun mibanda hubungan turun linier, tur sababaraha nilai di antarana keur sakabéh pasualan, nunjukkeun tingkat sakumaha gumantungna variabel sacara linier. Koefisien nu pangdeukeutna boh kana  −1 atawa 1, mibanda  harti beuki kuat korelasi antara dua variabel eta.

Lamun variabel mandiri mangka korelasina bakal 0, tapi teu salawasna bener sabab koefisien korelasi ngan keur néangan kabébasan linier antara dua variabel. Contona: Anggap variabel acak X mangrupa sebaran seragam dina interval ti −1 ka 1, sarta Y = X2.  Mangka Y satemenna ditangtukeun ku X, sabab kitu X tur Y bisa waé asalna tina dua variabel acak mandiri, tapi korelasi nol; maranéhna taya korelasi. Sanajan kitu, dina kasus basa X tur Y ngahiji normal, mandiri sarua jeung taya korelasi.

Korelasi sampel 

Lamun hiji runtuyan n  tina hasil ngukur X  tur Y  dituliskeun salaku xi  tur yi  nu mana i = 1, 2, ..., n, mangka koefisien korelasi produk-momen Pearson bisa dipaké keur ngiker korelasi X  jeung Y . Koefisien Péarson disebut ogé "koefisien korelasi sampel". Hal ieu husus lamun X  tur Y  duanana kasebar normal. Koefisien korelasi  Péarson jadi estimasi nu hadé keur korelasi X  jeung Y . Koefisien korelasi Péarson ditulis:

nu mana  jeung  nyaéta rata-rata tina xi  jeung yi , sx  jeung sy  nyaéta simpangan baku tina  xi  jeung yi  sarta jumlahna ti i = 1 nepi ka n. Saperti dina korelasi populasi, bisa ditulis salaku

Sakali deui, ieu bener dina korelasi populasi, gedéna nilai mutlak sampel korelasi kudu kurang atawa sarua jeung 1. ngagunakeun rumus di luhur mangrupa hal nu ilahar dipaké dina algoritma tunggal keur ngitung korelasi sampel, hal ieu teu stabil dina itungan sacara numerik (tempo di handap keur nu leuwih jéntré).

Kuadrat koefisien korelasi sampel, disebut ogé koefisien determinasi, nyaéta bagéan tina varian dina yi  nu diitung ku cara fit linier xi  ka yi . Ditulis

nu mana sy|x2  nyaéta kuadrat kasalahan régrési liniér  xi  dina yi  ku sasaruan y = a + bx:

jeung sy2  nyaéta ngan varian y:

Catetan, lamun koéfisien sampel korélasi simetri dina xi  jeung yi , bakal meunang niley nu sarua keur fit yi  ka xi :

Ieu sasaruan méré ide keur dimensi nu leuwih luhur. Saperti nu dijelaskeun di luhur korélasi koéfsien sampel nyaéta bagéan tian itungan varian ku cara nga-fit-keun linear submanifold 1-dimensi kana runtuyan vektor (xi , yi ) 2 dimensi, mangka bisa dihartikeun koefisien korelasi keur fit dina m-dimensi linéar submanifold kana runtuyan vektor n-dimensi. Contona, lamun nga-fit-keun widang z = a + bx + cy  kana runtuyan data (xi , yi , zi ) mangka koefisien korelasi  z  ka x  jeung y  nyaéta

Sebaran koefisien korelasi geus diterangkeun ku R. A. Fisher
jeung A. K. Gayen.

Interpretasi korélasi sacara geometri

Koéfisién korélasi bisa ogé ditempo salaku kosinus sudut antara dua vektor sampel nu dicokot tina dua variabel acak.

Caution: This method only works  with centered data, i.e., data which have been shifted by the sample méan so as to have an average of zero. Some practitioners prefer an uncentered (non-Péarson-compliant) correlation coefficient. See the example below for a comparison.

As an example, suppose five countries are found to have gross national products of 1, 2, 3, 5, and 8 billion dollars, respectively. Suppose these same five countries (in the same order) are found to have 11%, 12%, 13%, 15%, and 18% poverty. Then let x and y be ordered 5-element vectors containing the above data: x = (1, 2, 3, 5, 8) and y = (0.11, 0.12, 0.13, 0.15, 0.18).

By the usual procedure for finding the angle  between two vectors (see dot product), the uncentered correlation coefficient is:

 

Note that the above data were deliberately chosen to be perfectly correlated: y = 0.10 + 0.01 x. The Péarson correlation coefficient must therefore be exactly one. Centering the data (shifting x by E(x) = 3.8 and y by E(y) = 0.138) yields x = (-2.8, -1.8, -0.8, 1.2, 4.2) and y = (-0.028, -0.018, -0.008, 0.012, 0.042), from which

 

as expected.

Interpretation of the size of a correlation

Several authors have offered guidelines for the interpretation of a correlation coefficient.  Cohen (1988), for example, has suggested the following interpretations for correlations in psychological reséarch, in the table on the right.

As Cohen himself has observed, however, all such criteria are in some ways arbitrary and should not be observed too strictly.  This is because the interpretation of a correlation coefficient depends on the context and purposes.  A correlation of 0.9 may be very low if one is verifying a physical law using high-quality instruments, but may be regarded as very high in the social sciences where there may be a gréater contribution from complicating factors.

Non-parametric correlation coefficients
Péarson's correlation coefficient is a parametric statistic and when distributions are not normal it may be less useful than non-parametric correlation methods, such as Chi-square, Point biserial correlation, Spearman's ρ and Kendall's τ.  They are a little less powerful than parametric methods if the assumptions underlying the latter are met, but are less likely to give distorted results when the assumptions fail.

Other measures of dependence among random variables
To get a méasure for more general dependencies in the data (also nonlinéar) it is better to use the correlation ratio which is able to detect almost any functional dependency, or mutual information/total correlation which is capable of detecting even more general dependencies.

The polychoric correlation is another correlation applied to ordinal data that aims to estimate the correlation between théorised latent variables.

Copulas and correlation
The information given by a correlation coefficient is not enough to define the dependence structure between random variables;  to fully capture it we must consider a copula between them. The correlation coefficient completely defines the dependence structure only in very particular cases, for example when the cumulative distribution functions are the multivariate normal distributions. In the case of elliptic distributions it characterizes the (hyper-)ellipses of equal density, however, it does not completely characterize the dependence structure (for example, the a multivariate t-distribution's degrees of freedom determine the level of tail dependence).

Correlation matrices

The correlation matrix of n random variables X1, ..., Xn is the n  ×  n matrix whose i,j entry is corr(Xi, Xj).  If the méasures of correlation used are product-moment coefficients, the correlation matrix is the same as the covariance matrix of the standardized random variables Xi /SD(Xi) for i = 1, ..., n.  Consequently it is necessarily a positive-semidefinite matrix.

The correlation matrix is symmetric because the correlation between  and  is the same as the correlation between  and .

Removing correlation

It is always possible to remove the correlation between zero-méan random variables with a linéar transform, even if the relationship between the variables is nonlinéar.  Suppose a vector of n random variables is sampled m times.  Let X be a matrix where  is the jth variable of sample i.  Let  be an r by c matrix with every element 1.  Then D is the data transformed so every random variable has zero méan, and T is the data transformed so all variables have zero méan, unit variance, and zero correlation with all other variables.

where an exponent of -1/2 represents the matrix square root of the inverse of a matrix.  The covariance matrix of T will be the identity matrix.  If a new data sample x is a row vector of n elements, then the same transform can be applied to x to get the transformed vectors d and t:

Common misconceptions about correlation

Correlation and causality

The conventional dictum that "correlation does not imply causation" méans that correlation cannot be validly used to infer a causal relationship between the variables. This dictum should not be taken to méan that correlations cannot indicate causal relations. However, the causes underlying the correlation, if any, may be indirect and unknown. Consequently, establishing a correlation between two variables is not a sufficient condition to establish a causal relationship (in either direction).

Here is a simple example: hot wéather may cause both crime and ice-créam purchases.  Therefore crime is correlated with ice-créam purchases.  But crime does not cause ice-créam purchases and ice-créam purchases do not cause crime.

A correlation between age and height in children is fairly causally transparent, but a correlation between mood and héalth in péople is less so. Does improved mood léad to improved héalth? Or does good héalth léad to good mood? Or does some other factor underlie both? Or is it pure coincidence? 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.

Correlation and linearity

While Péarson correlation indicates the strength of a linéar relationship between two variables, its value alone may not be sufficient to evaluate this relationship, especially in the case where the assumption of normality is incorrect.

The image on the right shows scatterplots of Anscombe's quartet, a set of four different pairs of variables créated by Francis Anscombe. The four  variables have the same méan (7.5), standard deviation (4.12), correlation (0.81) and regression line (). However, as can be seen on the plots, the distribution of the variables is very different. The first one (top left) seems to be distributed normally, and corresponds to what one would expect when considering two variables correlated and following the assumption of normality. The second one (top right) is not distributed normally; while an obvious relationship between the two variables can be observed, it is not linéar, and the Péarson correlation coefficient is not relevant. In the third case (bottom left), the linéar relationship is perfect, except for one outlier which exerts enough influence to lower the correlation coefficient from 1 to 0.81. Finally, the fourth example (bottom right) shows another example when one outlier is enough to produce a high correlation coefficient, even though the relationship between the two variables is not linéar.

These examples indicate that the correlation coefficient, as a summary statistic, cannot replace the individual examination of the data.

Computing correlation accurately in a single pass
The following algorithm (in pseudocode) will estimate correlation with good numerical stability

 sum_sq_x = 0
 sum_sq_y = 0
 sum_coproduct = 0
 méan_x = x[1]
 méan_y = y[1]
 for i in 2 to N:
     sweep = (i - 1.0) / i
     delta_x = x[i] - méan_x
     delta_y = y[i] - méan_y
     sum_sq_x += delta_x * delta_x * sweep
     sum_sq_y += delta_y * delta_y * sweep
     sum_coproduct += delta_x * delta_y * sweep
     méan_x += delta_x / i
     méan_y += delta_y / i 
 pop_sd_x = sqrt( sum_sq_x / N )
 pop_sd_y = sqrt( sum_sq_y / N )
 cov_x_y = sum_coproduct / N
 correlation = cov_x_y / (pop_sd_x * pop_sd_y)

For an enlightening experiment, check the correlation of {900,000,000 + i for i=1...100} with {900,000,000 - i for i=1...100}, perhaps with a few values modified.  Poor algorithms will fail.

See also 
 Autocorrelation
 Cross-correlation
 Coefficient of determination
 Fraction of variance unexplained
 Kendall's tau
 Pearson product-moment correlation coefficient
 Point-biserial correlation coefficient
 Partial correlation
 Spearman's rank correlation coefficient
 Statistical arbitrage
 Currency correlation

Notes and references

Bacaan saterusna
 Cohen, J., Cohen P., West, S.G., & Aiken, L.S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences. (3rd ed.) Hillsdale, NJ: Lawrence Erlbaum Associates.

Tumbu kaluar
 Understanding Correlation  - Introductory material by a U. of Hawaii Prof.
 Statsoft Electronic Textbook 
 Pearson's Correlation Coefficient - How to calculate it quickly
 Learning by Simulations - The distribution of the correlation coefficient
  Correlation measures the strength of a linear relationship between two variables.

Probability theory
Statistika