Correlation Coefficient Calculator

Paste two columns of paired values to measure how strongly they move together. The calculator gives Pearson’s r (or Spearman’s rank correlation rho) with its p-value, a Fisher z confidence interval, r², the covariance and a scatter plot of your data, and writes the result as an APA sentence.

Coefficient

For a straight-line relationship between two continuous variables.

Paste each variable as a column from Excel, or type numbers separated by spaces or commas. The first X pairs with the first Y, and so on. Edit the names above each box.

Hypothesis
Confidence level

Load a worked example

Pearson correlation coefficient (r)

0.978

A strong positive correlation, p < .001 (two-tailed), from 10 pairs. 95% CI 0.909 to 0.995.

12013014015040506070Age (years)Systolic BP (mmHg)
Pearson r
0.9785
r² (shared variance)
0.9574
95.7%
p-value
9.16 × 10−7
two-tailed
t statistic
13.409
df = 8
95% CI for r
0.909 to 0.995
Fisher z
Pairs (n)
10
Mean of X
56.1
SD 12.41
Mean of Y
134.8
SD 11.40
Covariance
138.5

Report it like this

There was a strong positive correlation between age and systolic BP, r(8) = .98, 95% CI [.91, .995], p < .001, n = 10.

How to use the calculator

  1. Paste the two variables into the X and Y boxes, one value per pair in the same order. Columns copied from Excel work as they are. Rename the variables above the boxes so the plot and the sentence use your names.
  2. Choose Pearson or Spearman. Pearson’s r measures a straight-line relationship between two continuous variables. Spearman’s rho correlates the ranks, so it suits ordinal scales, outliers and relationships that rise or fall steadily without being straight.
  3. Look at the scatter plot before trusting the number: one outlier or a curved pattern can produce a misleading r.
  4. Copy the report sentence.

Correlation coefficient formula

r = Σ(x − x̄)(y − ȳ) / √[Σ(x − x̄)² · Σ(y − ȳ)²]

Pearson’s r is the covariance of X and Y divided by the product of their standard deviations. It runs from −1 (a perfect falling line) through 0 (no linear relationship) to +1 (a perfect rising line). Spearman’s rho applies the same formula to the ranks of the values, with tied values given the average of the ranks they span.

The p-value tests whether the population correlation is 0, using t = r√(n − 2) / √(1 − r²) with n − 2 degrees of freedom. The confidence interval for Pearson’s r uses Fisher’s transformation, z = atanh(r) with standard error 1 / √(n − 3), back-transformed to the r scale, so it is not symmetric around r. Results match SciPy’s pearsonr and spearmanr.

Worked examples

  • Age and systolic blood pressure (the default): for 10 adults aged 35 to 74, r = 0.978, 95% CI 0.909 to 0.995, t(8) = 13.41, p < .001. r² = 0.957, so age accounts for about 96% of the variation in blood pressure in this small sample. Spearman’s rho for the same data is 0.976.
  • Two judges ranking 8 posters: the ranks differ only by swaps of neighbours, and Spearman’s rho = 0.905, p = .002.
  • Sleep and reaction time: for 9 people, more sleep goes with faster reactions, r = −0.962, 95% CI −0.992 to −0.827.

How to interpret r

Cohen’s (1988) conventions for the size of a correlation in the behavioural sciences are the most widely quoted:

Cohen’s conventions for the size of a correlation
|r|Strength
Below 0.10Negligible
0.10 to 0.29Weak (small)
0.30 to 0.49Moderate (medium)
0.50 and aboveStrong (large)

r² is the share of the variance in one variable that is linearly explained by the other. A correlation, however strong, does not show that one variable causes the other: both may depend on a third variable, such as age. A correlation is also not a measure of agreement; two methods can correlate at r = 0.99 while one reads consistently 10% higher. To predict one variable from the other and get the equation of the line, use the linear regression calculator.

How to report a correlation

APA style gives r to two decimals without a leading zero, with the degrees of freedom (n − 2) in brackets, a confidence interval and the p-value:

There was a strong positive correlation between age and systolic blood pressure, r(8) = .98, 95% CI [.91, .995], p < .001.

For Spearman’s rho, write rs(8) = .98. Say which coefficient you used and why, and show the scatter plot if the journal allows figures. If you already have r from a paper, the p-value calculator gives its p-value from r and the number of pairs.

Questions

How do you calculate the correlation coefficient?
Subtract each variable’s mean from its values, multiply the paired deviations and add them up, then divide by the square root of the product of the two sums of squared deviations. The result, Pearson’s r, always lies between −1 and 1.
What is a good correlation coefficient?
By Cohen’s conventions, |r| of 0.10 is small, 0.30 medium and 0.50 large. What counts as good depends on the field: test-retest reliability usually needs r above 0.80, while a correlation of 0.30 between a lifestyle factor and a health outcome can be important.
When should I use Spearman instead of Pearson?
Use Spearman’s rank correlation when the data are ranks or ordinal scores, when there are outliers, or when the relationship rises or falls consistently but not in a straight line. Use Pearson when both variables are continuous and the scatter plot looks roughly linear.
How do I get the p-value for a correlation?
Convert r to t = r√(n − 2) / √(1 − r²) and find the two-tailed probability in the t distribution with n − 2 degrees of freedom. For r = 0.45 with 30 pairs, t = 2.67 and p = 0.013. This calculator does this automatically.
What is the difference between r and r²?
r gives the direction and strength of the linear relationship. r², the coefficient of determination, is the proportion of the variance in one variable that the other explains. r = 0.5 means r² = 0.25, or 25% of the variance.
Does correlation imply causation?
No. A correlation shows that two variables vary together, not that one causes the other. The link may come from a confounding variable, from reverse causation or from chance, especially when many correlations are tested.

Sources