Skip to the calculator
Rule Calculator

Correlation Calculator

With number of pairs 10, sum of x 55, sum of y 120, sum of xy 800 and 2 more fields, correlation comes to 0.9559 — correlation r. It is reached in 10 steps, the last of which is 140 / sqrt(82.5 * 260), and each one is printed on the page with its numbers filled in. The formula is the one published by NIST/SEMATECH e-Handbook of Statistical Methods, not an approximation fitted to it.

Pearson correlation from the sums a class is given, with r², the slope it implies, and the sample size at which it stops being noise.

Formula and sources checked · How we check

Number of pairs 10, Sum of x 55, Sum of y 120, Sum of xy 800

0.9559

Correlation r for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.

It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.

Correlation r
0.9559
Mean of x
55 / 105.5
Mean of y
120 / 1012
Σxy − (Σx)(Σy)/n
800 - (55 * 120) / 10140
Σx² − (Σx)²/n
385 - (55 ^ 2) / 1082.5
Σy² − (Σy)²/n
1700 - (120 ^ 2) / 10260
Correlation coefficient r
140 / sqrt(82.5 * 260)0.956
r², the share of variance explained
0.9559042 ^ 20.914
Slope of the line of best fit
140 / 82.51.697
Where that line crosses y
12 - 1.6969697 * 5.52.667
t statistic for r ≠ 0
abs(0.9559042) * sqrt((10 - 2) / (1 - 0.9559042 ^ 2))9.206

Ask about this in the chat

Worked example

Ten pairs with these sums give r = 0.9559: the two variables move together closely. r² of 0.9138 says about 91% of the variation in y is accounted for by x — and the other 9% is not, which is the half of the sentence usually left off. The line through them has slope 1.697.

How to work it out yourself

  1. 1.Collect the five sums the formula needs: n, Σx, Σy, Σxy, Σx² and Σy².
  2. 2.Compute Sxy = Σxy − ΣxΣy/n, and Sxx and Syy the same way with the squares.
  3. 3.r is Sxy over the square root of Sxx times Syy. It always lands between −1 and 1.
  4. 4.Square it for r², the share of the variance in y that the line accounts for.

The formula

  1. Mean of x55 / 10
  2. Mean of y120 / 10
  3. Σxy − (Σx)(Σy)/n800 - (55 * 120) / 10
  4. Σx² − (Σx)²/n385 - (55 ^ 2) / 10
  5. Σy² − (Σy)²/n1700 - (120 ^ 2) / 10
  6. Correlation coefficient r140 / sqrt(82.5 * 260)
  7. r², the share of variance explained0.9559042 ^ 2
  8. Slope of the line of best fit140 / 82.5
  9. Where that line crosses y12 - 1.6969697 * 5.5
  10. t statistic for r ≠ 0abs(0.9559042) * sqrt((10 - 2) / (1 - 0.9559042 ^ 2))

Source: NIST/SEMATECH e-Handbook of Statistical Methods, NIST SP 811 — expressing measurement results

Questions people actually ask

What does the correlation coefficient mean?
How closely the points sit to a straight line, and in which direction. r = 1 is a perfect rising line, −1 a perfect falling one, 0 no linear relationship at all. It says nothing about how steep the line is: a slope of 0.01 and a slope of 100 can both have r = 0.99.
What is the difference between r and r²?
r carries the direction and r² does not — both −0.9 and 0.9 give 0.81. r² is read as the share of the variance in y explained by x, which is why it is the figure quoted in a report. Watch the size of the drop: r = 0.7 sounds strong and explains under half the variance.
Is a correlation of 0.9 significant?
It depends entirely on how many pairs produced it. With 4 points r = 0.9 is unremarkable; with 40 it would be very hard to get by chance. The t statistic above is the test: compare it against a t table with n − 2 degrees of freedom.
Does correlation prove causation?
No, and the failure has three named shapes: the arrow could point the other way, something else could drive both, or the pairing could be coincidence in a small sample. A correlation is a reason to look for a mechanism, not a substitute for finding one.
What if the relationship is curved?
Pearson r will understate it, possibly to zero. A perfect parabola through the origin has r = 0 while being entirely predictable. Plot the points before quoting the coefficient — the classic demonstration is Anscombe’s quartet, four data sets with identical r and nothing else in common.

Related

Put this calculator on your site

Free, no attribution required beyond the link.

<iframe src="https://rulecalculators.com/embed/correlation-coefficient" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Correlation Calculator"></iframe>
Did this answer your question?