Correlation Coefficient Calculator
Compute Pearson r and Spearman's ρ with significance tests, Fisher confidence intervals, and scatter plots. Enter paired values as comma- or space-separated numbers.
Or enter paired data in a table
§1How this was calculated
- Working steps appear here as you enter data.
§2The formula
- r
- Pearson correlation coefficient (ranges from −1 to +1).
- xᵢ, yᵢ
- Individual data points.
- x̄, ȳ
- Mean of X and Y respectively.
- Σ
- Sum.
Significance test (t-test)
- t
- Test statistic, compared to the t-distribution.
- n
- Number of data pairs.
- df
- Degrees of freedom (n − 2).
Fisher z confidence interval
- z'
- Fisher z-transformed correlation.
- SE
- Standard error of the z-transform (requires n > 3).
The 95% confidence interval is z' ± 1.96 · SE, back-transformed to the r scale using r = (e^(2z') − 1) / (e^(2z') + 1).
§3Worked example
Suppose you measure study hours (X) and exam scores (Y) for 5 students:
| X (hours) | Y (score) | xᵢ − x̄ | yᵢ − ȳ | (xᵢ − x̄)(yᵢ − ȳ) |
|---|---|---|---|---|
| 1 | 50 | −2 | −14 | 28 |
| 2 | 60 | −1 | −4 | 4 |
| 3 | 68 | 0 | 4 | 0 |
| 4 | 75 | 1 | 11 | 11 |
| 5 | 82 | 2 | 18 | 36 |
x̄ = 3, ȳ = 64, Σ(xᵢ − x̄)(yᵢ − ȳ) = 79, Σ(xᵢ − x̄)² = 10, Σ(yᵢ − ȳ)² = 792
r = 79 / √(10 × 792) = 79 / 89.03 ≈ 0.887. This is a strong positive correlation: as study hours increase, exam scores tend to increase together.
t = 0.887 × √3 / √(1 − 0.787) = 1.537 / 0.459 ≈ 3.35, df = 3. From a t-table, p ≈ 0.036, so the correlation is statistically significant at α = .05.
§4What r, r², and the p-value each tell you
r: strength and direction of linear association
r ranges from −1 (perfect negative correlation) through 0 (no linear correlation) to +1 (perfect positive correlation). It measures only linear association. Interpretation depends on your field:
- In social sciences, |r| ≥ 0.3 is often called "moderate" and |r| ≥ 0.5 is "strong", but many researchers criticize these thresholds as arbitrary.
- In physical sciences and engineering, correlations below 0.7–0.8 are often too weak to be useful.
- In medicine, weak correlations (|r| = 0.2–0.4) can still be clinically important if the sample is large.
Always plot your data. A correlation of 0.8 could hide one influential outlier or a nonlinear relationship.
r²: proportion of shared variance
r² (the coefficient of determination) tells you the proportion of variance in one variable that is explained by the other. If r = 0.7, then r² = 0.49, meaning 49% of variance is shared—and 51% is not. This often feels surprisingly small and is a humbling reminder that correlation is not prediction.
The p-value: evidence against H₀
The p-value is the probability of observing a correlation this extreme or more extreme if there were no linear relationship in the population (if H₀: ρ = 0 were true). A p-value below 0.05 is conventionally taken as evidence to reject H₀, but this says nothing about the size or practical importance of the effect—a large sample can make tiny correlations "significant".
§5Correlation is not causation—and three ways it goes wrong
1. Confounding
Ice cream sales and drowning deaths are strongly correlated. Neither causes the other—both are driven by a third variable, seasonal temperature. Always ask: what else might explain this association?
2. Reverse causation
If depression and insomnia correlate, does depression cause insomnia, does insomnia cause depression, or do both share a cause? Observational correlation cannot answer this. Use the temporal order (which came first?) and experimental design to infer direction.
3. Selection bias
If you measure the correlation of study time and GPA only in the students who attend tutoring, you may bias the result. Correlations in select groups can differ from the population at large.
Gold standard: Randomized controlled trials. If that is not possible, use domain knowledge to propose the causal pathway and justify why confounding is unlikely.
§6Pearson vs Spearman: which to use
| Pearson r | Spearman ρ (rho) |
|---|---|
| Assumes data are continuous and the relationship is linear. | Makes no assumption about the form; tests monotonic (always up or always down) association. |
| Sensitive to outliers. | Robust to outliers (uses ranks, not raw values). |
| Use when: data are normally distributed or the relationship looks linear on a scatter plot. | Use when: the relationship is monotonic but curved, or data contain outliers, or variables are ordinal (e.g., Likert scales, rankings). |
On Spearman's significance test
Spearman's p-value uses the same t-test formula as Pearson, applied to the ranks. This approximation works well for n ≥ 30, but for small samples the true p-value can differ; consider it a rough guide.
§7Outliers can create or destroy a correlation
A single data point far from the trend can shift r by 0.2 or more. Always:
- Plot the scatter graph (provided above).
- Check for points that lie far from the regression line.
- Verify whether they are data entry errors. If not, report the correlation both with and without the outlier and explain why it matters.
If outliers dominate your correlation, consider Spearman ρ (which is rank-based) or reporting the correlation separately for subgroups.
§8How to report a correlation in APA style
In-text example:
Study hours were strongly correlated with exam performance, r(103) = 0.72, p < .001, 95% CI [0.60, 0.81].
Format:
- r = the correlation coefficient (to 2–3 decimals).
- n in parentheses (or df = n − 2 for the t-test).
- p = the two-tailed p-value; write p < .001 if p is very small.
- 95% CI [lower, upper] = the Fisher confidence interval (optional but increasingly expected).
For Spearman, use ρ (rho) instead of r:
Ranking preference and salary were moderately correlated, ρ(48) = 0.51, p = .003.
§9Frequently asked questions
Is 0.7 a strong correlation?
It depends on your field. In social sciences, |r| ≥ 0.5 is often called "strong". In engineering or physical sciences, 0.7 might be considered modest because tighter correlations are more predictive. In medicine, a correlation of 0.4 can be clinically meaningful. Always contextualize with domain knowledge and plot your data.
What if my correlation is exactly −1 or +1?
A perfect correlation means all points lie exactly on a line. The confidence interval and significance test become undefined because the denominator of the t-test (1 − r²) is zero. This is rare in real data and usually signals that one variable is a linear function of the other.
Can I use correlation if my sample size is very small (n < 10)?
Yes, but interpret with caution. The confidence interval will be wide, meaning your estimate is uncertain. A correlation of 0.5 from n = 6 is not reliable—repeat the study to confirm. For n < 3, you cannot compute the confidence interval at all (Fisher z requires n > 3).
Why do I need the 95% confidence interval?
The p-value tells you whether H₀ is plausible; the CI tells you the range of plausible values for ρ in the population. A correlation of 0.3 from a huge sample might be significant but have a narrow CI [0.25, 0.35]; the same r from n = 10 might be non-significant with a wide CI [−0.20, 0.75].
What if my two variables have different scales (e.g., income in dollars and age in years)?
Correlation is scale-invariant—it does not matter whether you measure income in dollars or thousands of dollars. The numerator and denominator both scale together, so r stays the same. This is different from regression slope, which does depend on scale.
Can I test whether two correlations are significantly different from each other?
Yes, using a test of the difference between two r values (beyond the scope here, but Fisher z-transforms make this tractable). If you have two separate correlations from different groups and want to know whether they differ, consult a statistics textbook or run a sensitivity analysis: compute both with and without the groups combined.
Sources
- Pearson correlation coefficient — Wikipedia
- Spearman's rank correlation coefficient — Wikipedia
- Fisher transformation — Wikipedia
- Altman, D. G., & Bland, J. M. (1983). Measurement in medicine: the analysis of method comparison studies. The Statistician, 32(3), 307–317.
- Kline, R. B. (2004). Beyond Significance Testing: Reforming Data Analysis Methods in Behavioral Research. Washington: American Psychological Association.