What is the Pearson correlation coefficient?
The Pearson correlation coefficient, written as \(r\), measures how strongly two numerical variables move together in a straight-line (linear) fashion. It always falls between -1 and +1. A value near +1 means the variables rise together, near -1 means one rises as the other falls, and near 0 means little or no linear relationship. This tool is universal — it applies to any paired numeric data, in any field.
How to use this calculator
Enter your X values and your Y values, separated by commas or spaces. Each X must be paired with the Y in the same position, so both lists should have the same number of entries. Click calculate to get \(r\), plus the coefficient of determination (\(r^2\)), the least-squares regression slope and intercept, and the covariance.
The formula explained
For each data point you compute the deviation of x from its mean \((x - \bar{x})\) and of y from its mean \((y - \bar{y})\). The numerator sums the products of these deviations. The denominator is the square root of the product of the summed squared deviations of each variable. Dividing standardises the result so it is unit-free and bounded between -1 and +1.
$$ r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \, \sum (y_i - \bar{y})^2}} $$where
$$ \left\{ \begin{aligned} x_i &= \text{X values} \\ y_i &= \text{Y values} \\ \bar{x} &= \tfrac{1}{n}\textstyle\sum x_i,\quad \bar{y} = \tfrac{1}{n}\textstyle\sum y_i \end{aligned} \right. $$
Worked example
Take X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5. The means are \(\bar{x} = 3\) and \(\bar{y} = 4\). The sum of cross-products \(\sum (x - \bar{x})(y - \bar{y}) = 6\), \(\sum (x - \bar{x})^2 = 10\), and \(\sum (y - \bar{y})^2 = 6\). So
$$ r = \frac{6}{\sqrt{10 \times 6}} = \frac{6}{\sqrt{60}} \approx 0.7746 $$indicating a fairly strong positive linear relationship.
Interpreting Your Correlation Coefficient
The Pearson coefficient \(r\) always lies between \(-1\) and \(+1\). The sign gives the direction: positive means Y tends to rise as X rises, and negative means Y tends to fall as X rises. The magnitude \(|r|\) shows how closely the points follow a straight line. A value of 0 means no linear relationship, which is not the same as no relationship at all.
| |r| | Common descriptor |
|---|---|
| 0.00 – 0.19 | Very weak |
| 0.20 – 0.39 | Weak |
| 0.40 – 0.59 | Moderate |
| 0.60 – 0.79 | Strong |
| 0.80 – 1.00 | Very strong |
These cut-offs are a rule of thumb, and conventions differ by field. Cohen's widely cited benchmarks for behavioural science treat 0.1 as small, 0.3 as medium and 0.5 as large. Physics and engineering often expect |r| above 0.95, while social science and medicine may consider much lower values meaningful. Judge a value against the norms of your discipline.
Variance explained: \(r^2\), the coefficient of determination, is the proportion of the variance in Y accounted for by a linear relationship with X. For example, \(r = 0.775\) gives \(r^2 \approx 0.60\), so about 60% of the variation in Y is linearly associated with X. Note that \(r^2\) has no sign.
Caveats
- Outliers: one extreme point can raise or lower r sharply. Always inspect a scatter plot.
- Non-linear relationships: a perfect U-shaped or curved relationship can give r near 0.
- Restricted range: if you only sample a narrow band of X values, r is usually smaller than it would be over the full range.
- Small samples: with few pairs, r can be large purely by chance. With n = 3, for example, almost any value is possible. Significance testing or confidence intervals help here.
- Anscombe's quartet: four different datasets that share almost identical summary statistics (r ≈ 0.816, same means and variances, same fitted line) but look completely different when plotted. This shows that r alone is never enough.
- Correlation does not imply causation: a strong r can arise from a confounding variable, reverse causation or coincidence.
Key Terms and Definitions
- Correlation coefficient (r)
- A unitless number from −1 to +1 that measures the strength and direction of the linear relationship between two variables.
- Coefficient of determination (r²)
- The square of r. It is the share of the variance in Y that is linearly explained by X, ranging from 0 to 1.
- Covariance
- A measure of how two variables vary together, in units of X times units of Y. The sample covariance divides \(S_{xy}\) by \(n-1\). The population covariance divides by \(n\).
- Regression slope
- The change in predicted Y for a one-unit increase in X: \(b = S_{xy}/S_{xx}\).
- Intercept
- The predicted value of Y when X = 0: \(a = \bar{y} - b\bar{x}\).
- Least-squares line
- The straight line \(\hat{y} = a + bx\) that minimises the sum of squared vertical distances between the observed points and the line.
- Paired data
- Observations where each X value is matched with a Y value from the same subject or case. Both lists must have the same length.
- Outlier
- A data point far from the general pattern. It can strongly distort r, the slope and the intercept.
- Linear vs monotonic relationship
- A linear relationship follows a straight line. A monotonic relationship consistently rises or consistently falls but not necessarily at a constant rate, so it may be curved.
- Spearman's rank correlation
- The alternative to Pearson's r for monotonic but non-linear data, or data with outliers or ordinal values. It is computed on the ranks of the values rather than the raw values.
FAQ
What does \(r^2\) tell me? It is \(r\) squared and represents the fraction of variation in Y explained by the linear relationship with X. An \(r\) of 0.7746 gives \(r^2 \approx 0.6\), meaning about 60% of the variance is explained.
Does correlation prove causation? No. A high \(r\) shows two variables move together but does not establish that one causes the other.
What if \(r\) is exactly 0? There is no linear association, though a non-linear relationship may still exist that Pearson \(r\) cannot detect.