What the Coefficient of Correlation Measures
The coefficient of correlation is a number between −1 and +1 that tells you how strongly two variables move together. If one goes up when the other goes up, the correlation is positive. If one goes up when the other goes down, the correlation is negative. A correlation of 0 means the two variables have no linear relationship.
The most common version is the Pearson correlation coefficient, written as r. It measures whether the relationship between two variables is a straight line. If you plot the data points on a graph and they form a tight line, the correlation will be close to +1 or −1. If the points scatter randomly, the correlation will be close to 0.
Correlation is not the same as causation. A high correlation between two variables does not mean one causes the other—only that they tend to move together in a predictable way.
Key Takeaways
- The Pearson correlation coefficient ranges from −1 to +1, where +1 is a perfect positive relationship, −1 is a perfect negative relationship, and 0 means no linear relationship.
- You calculate it by finding how far each data point is from its variable's average, multiplying those distances for each pair, summing the products, and dividing by the standard deviations of both variables.
- The formula is r = Σ[(x − x̄)(y − ȳ)] / √[Σ(x − x̄)² × Σ(y − ȳ)²], where x̄ and ȳ are the averages of each variable.
- Most spreadsheet programs and statistical software calculate correlation automatically, so you rarely need to do the arithmetic by hand.
- A correlation of 0.7 or higher (or −0.7 or lower) is usually considered strong; 0.3 to 0.7 is moderate; below 0.3 is weak.
The Formula and What Each Part Means
The Pearson correlation coefficient uses this formula:
r = Σ[(x − x̄)(y − ȳ)] / √[Σ(x − x̄)² × Σ(y − ȳ)²]
Breaking this down: x and y are your two variables. x̄ (x-bar) is the average of all x values, and ȳ (y-bar) is the average of all y values. For each data point, you subtract the average from the actual value—this is called the deviation. You multiply the deviations for x and y together, then add all those products. That sum goes in the numerator.
The denominator is the square root of the product of two sums. The first sum is the squared deviations of x; the second is the squared deviations of y. This denominator is sometimes called the standard deviation product and it scales the numerator so the final result always falls between −1 and +1.
Step-by-Step Calculation by Hand
If you have a small dataset, you can calculate correlation manually. Suppose you want to find the correlation between hours studied and test scores for five students.
| Student | Hours Studied (x) | Test Score (y) |
|---|---|---|
| A | 2 | 65 |
| B | 3 | 72 |
| C | 4 | 78 |
| D | 5 | 85 |
| E | 6 | 90 |
Step 1: Find the averages. x̄ = (2 + 3 + 4 + 5 + 6) / 5 = 4. ȳ = (65 + 72 + 78 + 85 + 90) / 5 = 78.
Step 2: Calculate deviations and their products. For each row, subtract the average from the value, then multiply the x deviation by the y deviation.
| Student | x − x̄ | y − ȳ | (x − x̄)(y − ȳ) |
|---|---|---|---|
| A | −2 | −13 | 26 |
| B | −1 | −6 | 6 |
| C | 0 | 0 | 0 |
| D | 1 | 7 | 7 |
| E | 2 | 12 | 24 |
Step 3: Sum the products. Σ[(x − x̄)(y − ȳ)] = 26 + 6 + 0 + 7 + 24 = 63.
Step 4: Calculate squared deviations. Square each deviation, then sum them separately for x and y.
| Student | (x − x̄)² | (y − ȳ)² |
|---|---|---|
| A | 4 | 169 |
| B | 1 | 36 |
| C | 0 | 0 |
| D | 1 | 49 |
| E | 4 | 144 |
Σ(x − x̄)² = 4 + 1 + 0 + 1 + 4 = 10. Σ(y − ȳ)² = 169 + 36 + 0 + 49 + 144 = 398.
Step 5: explore the formula. r = 63 / √(10 × 398) = 63 / √3980 = 63 / 63.09 ≈ 0.998. This is a very strong positive correlation, which makes sense: as hours studied increase, test scores increase almost perfectly.
Using Spreadsheet Software to Calculate Correlation
In Microsoft Excel, use the CORREL function. Type =CORREL(range1, range2), where range1 is the cells containing your first variable and range2 is the cells containing your second variable. For the example above, you would type =CORREL(A2:A6, B2:B6) and press Enter. Excel returns the correlation coefficient when ready.
Google Sheets uses the same function: =CORREL(A2:A6, B2:B6). LibreOffice Calc also supports CORREL. Some spreadsheets also offer PEARSON, which is identical to CORREL for basic use.
If you are working with large datasets or need more statistical detail, statistical software like R, Python (using libraries such as NumPy or Pandas), SPSS, or Stata all calculate correlation with a single command. These tools also provide p-values, which tell you whether the correlation is statistically significant or could have occurred by chance.
Interpreting the Strength of a Correlation
A correlation coefficient is just a number; what matters is what it tells you about the relationship. The closer r is to +1 or −1, the stronger the linear relationship. The closer it is to 0, the weaker.
A rough guide: correlations above 0.7 or below −0.7 are usually considered strong. Correlations between 0.3 and 0.7 (or −0.3 and −0.7) are moderate. Correlations below 0.3 (and above −0.3) are weak. These thresholds are not hard rules—the context of your data matters. In some fields, a correlation of 0.5 is considered strong; in others, it is weak.
Remember that correlation measures only linear relationships. Two variables can have a strong curved or non-linear relationship and still show a correlation near 0. Always plot your data on a scatter graph to see the actual pattern before relying on the number alone.
When Correlation Can Mislead You
A high correlation does not prove that one variable causes the other. Ice cream sales and drowning deaths are highly correlated, but ice cream does not cause drowning—both increase in summer. This is called spurious correlation.
Correlation is also sensitive to outliers—extreme values that do not fit the overall pattern. A single unusual data point can pull the correlation up or down significantly. If you notice one point far away from the others on a scatter plot, investigate whether it is a data entry error or a genuine unusual case.
Correlation also assumes both variables are measured on a continuous scale (like height, temperature, or test scores). If one variable is categorical (like gender or color), use a different measure such as Cramér's V or Spearman's rank correlation instead.
Frequently Asked Questions
What is the difference between Pearson and Spearman correlation?
Pearson correlation measures linear relationships between two continuous variables. Spearman correlation ranks the data first, then measures the relationship between the ranks. Use Spearman when your data is not normally distributed, contains outliers, or when one or both variables are ordinal (ranked categories like "low, medium, high").
Can correlation be negative?
Yes. A negative correlation means that as one variable increases, the other tends to decrease. For example, the correlation between exercise frequency and resting heart rate is negative—more exercise usually means a lower resting heart rate. A correlation of −0.8 is just as strong as +0.8; the sign only indicates direction.
What does a correlation of 0 mean?
A correlation of 0 means there is no linear relationship between the two variables. They do not move together in a predictable straight-line pattern. This does not mean they are unrelated—they could have a curved relationship or be influenced by other factors.
Do I need to calculate correlation by hand?
No. Any spreadsheet or statistical software will calculate it for you in seconds. Hand calculation is useful only for understanding how the formula works or when you have very few data points and no access to a computer.
What sample size do I need for a reliable correlation?
There is no fixed rule, but correlations based on fewer than 30 data points are often unreliable. Larger samples give more stable results. If you have fewer than 10 data points, treat the correlation as exploratory only and do not draw firm conclusions.