Correlation Coefficient Calculator

Enter your x and y values to measure how closely they follow a straight line.

Numbers separated by commas, spaces or new lines.

One y for each x, in the same order.

Try

Result

You enteredx={1, 2, 3, 4, 5}y={2, 4, 5, 4, 5}x = \left\{ 1,\ 2,\ 3,\ 4,\ 5 \right\} \quad y = \left\{ 2,\ 4,\ 5,\ 4,\ 5 \right\}

r=0.774597\displaystyle r = 0.774597

r²

0.6\displaystyle 0.6

Exact

155\displaystyle \frac{\sqrt{15}}{5}

Strength

strongpositive\displaystyle strong positive
Show the work
  1. Means of x and y

    Each value is measured from the mean of its own variable, so the means come first. There are n=5n = 5 pairs.

    xˉ=155=3yˉ=205=4\begin{gathered} \bar{x} = \frac{15}{5} = 3 \\ \bar{y} = \frac{20}{5} = 4 \end{gathered}
  2. Sums of squares and products

    SxxS_{xx} measures how spread out the x values are, SyyS_{yy} how spread out the y values are, and SxyS_{xy} how x and y move together: it is positive when they rise together and negative when one rises as the other falls.

    Using Sxy=∑(x−xˉ)(y−yˉ)S_{xy} = \sum \left(x - \bar{x}\right)\left(y - \bar{y}\right)

    Sxx=(1−3)2+(2−3)2+(3−3)2+(4−3)2+(5−3)2=10Syy=(2−4)2+(4−4)2+(5−4)2+(4−4)2+(5−4)2=6Sxy=(1−3)(2−4)+(2−3)(4−4)+(3−3)(5−4)+(4−3)(4−4)+(5−3)(5−4)=6\begin{gathered} S_{xx} = \left(1 - 3\right)^2 + \left(2 - 3\right)^2 + \left(3 - 3\right)^2 + \left(4 - 3\right)^2 + \left(5 - 3\right)^2 = 10 \\ S_{yy} = \left(2 - 4\right)^2 + \left(4 - 4\right)^2 + \left(5 - 4\right)^2 + \left(4 - 4\right)^2 + \left(5 - 4\right)^2 = 6 \\ S_{xy} = \left(1 - 3\right)\left(2 - 4\right) + \left(2 - 3\right)\left(4 - 4\right) + \left(3 - 3\right)\left(5 - 4\right) + \left(4 - 3\right)\left(4 - 4\right) + \left(5 - 3\right)\left(5 - 4\right) = 6 \end{gathered}
  3. Pearson correlation coefficient

    Dividing the shared movement by the geometric mean of the two spreads makes r a pure number between -1 and 1, whatever the units of x and y.

    r=SxySxxSyy=610×6=660≈0.774597\begin{aligned} r &= \frac{S_{xy}}{\sqrt{S_{xx} S_{yy}}} \\ &= \frac{6}{\sqrt{10 \times 6}} \\ &= \frac{6}{\sqrt{60}} \approx 0.774597 \end{aligned}
  4. Strength of a correlation

    The sign of r gives the direction and its size the strength: ∣r∣|r| of at least 0.7 is strong, at least 0.4 moderate, at least 0.1 weak, and below that there is no linear correlation. Here ∣r∣≈0.774597|r| \approx 0.774597, which is strong positive.

  5. Result

    So r≈0.774597r \approx 0.774597, which means a strong positive linear correlation.

Worked examples