How To Find Correlation Coefficient?

Collect paired data points ((x_i, y_i)) for (i=1,dots,n)

Compute means:

(bar{x}=frac{1}{n}sum_{i=1}^n x_i)

(bar{y}=frac{1}{n}sum_{i=1}^n y_i)

Compute deviations:

(d_{x,i}=x_i-bar{x})

(d_{y,i}=y_i-bar{y})

Compute sums:

(S_{xy}=sum_{i=1}^n (x_i-bar{x})(y_i-bar{y}))

(S_{xx}=sum_{i=1}^n (x_i-bar{x})^2)

(S_{yy}=sum_{i=1}^n (y_i-bar{y})^2)

Calculate Pearson correlation coefficient:

(r=frac{S_{xy}}{sqrt{S_{xx},S_{yy}}})

If using an equivalent formula with raw sums:

(r=frac{nsum xy-(sum x)(sum y)}{sqrt{left[nsum x^2-(sum x)^2right]left[nsum y^2-(sum y)^2right]}})

If (S_{xx}=0) or (S_{yy}=0), correlation is undefined

Optionally use software (gives Pearson (r)):

Excel: `=CORREL(x_range, y_range)`

Google Sheets: `=CORREL(x_range, y_range)`

Python: `numpy.corrcoef(x, y)[0,1]`

R: `cor(x, y, method=”pearson”)`

Suggested for You

Trending Today