Open navigation
OpenOpen workspace

Relationship between two numeric variables

Correlation calculator

Published by crosstabs.com · Last updated ·
How results are checkedNamed statistical review pending. Selected automated reference cases are published on the validation page.

中文版

Result on the sample data

.78r

Customers who rate value for money higher are more satisfied (p < .001)

r² = .62 · Spearman ρ = .78 · Kendall τ-b = .60 · n = 60

Synthetic sample · same data as “Use sample data”

A correlation coefficient measures how closely two numeric variables move together, from −1 (perfectly opposite) through 0 (no relationship) to +1. Pearson's r measures straight-line association; Spearman's ρ and Kendall's τ-b use ranks, so they capture any consistently increasing or decreasing pattern and resist outliers. Report r with its confidence interval — and look at the scatter plot, because a single number can hide curves, clusters and outliers.

Run this on your own data — free, no signup

Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Calculate online

Paste two columns (x and y) from a spreadsheet or open a data file — it is read in your browser and never uploaded — to get all three coefficients and a scatter plot with a data table. If you only have a published r, enter r and n; to test whether two groups have different correlations, use the comparison tab.

Paste two columns from a spreadsheet; a header row names the variables. Rows with a missing value in either column are dropped.

Pearson correlation

r(58) = 0.784

A very strong positive linear relationship (95% CI [0.662, 0.866]); x and y share r² = 0.615 of their variance. Statistically significant at α = .05.

p < .001 · n = 60

Correlation coefficients

Correlation coefficients
CoefficientEstimatep (two-sided)95% CI
Pearson r0.784p < .001[0.662, 0.866]
r²0.615
t test of r (df = 58)t = 9.630p < .001
Spearman ρ0.777p < .001
Kendall τ-b0.599p < .001

More on Kendall's tau-b and tau-c for ordinal tables

Scatter plot

406080100246810Value for money (0–10)Overall satisfaction (0–100)Least-squares lineValue for money (0–10) 4.3 · Overall satisfaction (0–100) 51Value for money (0–10) 5.3 · Overall satisfaction (0–100) 52Value for money (0–10) 7.3 · Overall satisfaction (0–100) 82Value for money (0–10) 6.9 · Overall satisfaction (0–100) 68Value for money (0–10) 2.8 · Overall satisfaction (0–100) 43Value for money (0–10) 5.3 · Overall satisfaction (0–100) 65Value for money (0–10) 5.2 · Overall satisfaction (0–100) 47Value for money (0–10) 3.5 · Overall satisfaction (0–100) 60Value for money (0–10) 6.4 · Overall satisfaction (0–100) 68Value for money (0–10) 4.3 · Overall satisfaction (0–100) 50Value for money (0–10) 8.7 · Overall satisfaction (0–100) 77Value for money (0–10) 7 · Overall satisfaction (0–100) 63Value for money (0–10) 6.4 · Overall satisfaction (0–100) 50Value for money (0–10) 5.8 · Overall satisfaction (0–100) 62Value for money (0–10) 5.8 · Overall satisfaction (0–100) 59Value for money (0–10) 7.7 · Overall satisfaction (0–100) 74Value for money (0–10) 5.8 · Overall satisfaction (0–100) 78Value for money (0–10) 3.3 · Overall satisfaction (0–100) 47Value for money (0–10) 6.2 · Overall satisfaction (0–100) 66Value for money (0–10) 4.8 · Overall satisfaction (0–100) 67Value for money (0–10) 7.1 · Overall satisfaction (0–100) 67Value for money (0–10) 8.3 · Overall satisfaction (0–100) 83Value for money (0–10) 4.3 · Overall satisfaction (0–100) 68Value for money (0–10) 9.2 · Overall satisfaction (0–100) 76Value for money (0–10) 5.7 · Overall satisfaction (0–100) 71Value for money (0–10) 2.2 · Overall satisfaction (0–100) 31Value for money (0–10) 4.9 · Overall satisfaction (0–100) 63Value for money (0–10) 3.5 · Overall satisfaction (0–100) 40Value for money (0–10) 3.2 · Overall satisfaction (0–100) 58Value for money (0–10) 4 · Overall satisfaction (0–100) 51Value for money (0–10) 6.6 · Overall satisfaction (0–100) 71Value for money (0–10) 6.1 · Overall satisfaction (0–100) 67Value for money (0–10) 7.8 · Overall satisfaction (0–100) 82Value for money (0–10) 1.9 · Overall satisfaction (0–100) 53Value for money (0–10) 4.9 · Overall satisfaction (0–100) 54Value for money (0–10) 4 · Overall satisfaction (0–100) 58Value for money (0–10) 4.9 · Overall satisfaction (0–100) 61Value for money (0–10) 5.4 · Overall satisfaction (0–100) 70Value for money (0–10) 6.4 · Overall satisfaction (0–100) 65Value for money (0–10) 6 · Overall satisfaction (0–100) 71Value for money (0–10) 2.5 · Overall satisfaction (0–100) 48Value for money (0–10) 5.9 · Overall satisfaction (0–100) 64Value for money (0–10) 4.9 · Overall satisfaction (0–100) 58Value for money (0–10) 7 · Overall satisfaction (0–100) 69Value for money (0–10) 7.7 · Overall satisfaction (0–100) 73Value for money (0–10) 7.2 · Overall satisfaction (0–100) 70Value for money (0–10) 4.9 · Overall satisfaction (0–100) 74Value for money (0–10) 6.5 · Overall satisfaction (0–100) 72Value for money (0–10) 4.9 · Overall satisfaction (0–100) 54Value for money (0–10) 6.9 · Overall satisfaction (0–100) 63Value for money (0–10) 3.8 · Overall satisfaction (0–100) 64Value for money (0–10) 5 · Overall satisfaction (0–100) 68Value for money (0–10) 8.4 · Overall satisfaction (0–100) 100Value for money (0–10) 7.8 · Overall satisfaction (0–100) 79Value for money (0–10) 7.3 · Overall satisfaction (0–100) 79Value for money (0–10) 7.1 · Overall satisfaction (0–100) 93Value for money (0–10) 5.6 · Overall satisfaction (0–100) 62Value for money (0–10) 5 · Overall satisfaction (0–100) 52Value for money (0–10) 9.9 · Overall satisfaction (0–100) 94Value for money (0–10) 6.9 · Overall satisfaction (0–100) 59
n = 60 · Least-squares line
Show the plotted data as a table
Scatter plot
RowValue for money (0–10)Overall satisfaction (0–100)
14.351
25.352
37.382
46.968
52.843
65.365
75.247
83.560
96.468
104.350
118.777
12763
136.450
145.862
155.859
167.774
175.878
183.347
196.266
204.867
217.167
228.383
234.368
249.276
255.771
262.231
274.963
283.540
293.258
30451
316.671
326.167
337.882
341.953
354.954
36458
374.961
385.470
396.465
40671
412.548
425.964
434.958
44769
457.773
467.270
474.974
486.572
494.954
506.963
513.864
52568
538.4100
547.879
557.379
567.193
575.662
58552
599.994
606.959

Pearson, Spearman or Kendall?

Use Pearson's r for two roughly continuous variables with a linear relationship and no extreme outliers; r² is then the share of variance the two variables share. Use Spearman's ρ when the relationship is monotonic but curved, when the data are ranks or short rating scales, or when outliers would dominate r. Kendall's τ-b (with a tie correction) is the more conservative rank measure and is better behaved in small samples with many ties; its values are typically smaller than ρ for the same data.

For two ordinal variables already tabulated into a crosstab, the Kendall's tau calculator works directly on the table and adds tau-c for rectangular tables.

The method

Formula

Definition

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

where

t = r√(n − 2) / √(1 − r²)
the test of ρ = 0, with n − 2 degrees of freedom
Fisher z
z = atanh(r) has standard error 1/√(n − 3); the interval tanh(z ± z₀.₉₇₅/√(n − 3)) is the confidence interval for ρ
Spearman ρ
Pearson's r computed on the ranks of x and y (average ranks for ties)
Kendall τ-b
(C − D) / √[(n₀ − n₁)(n₀ − n₂)] — concordant minus discordant pairs, corrected for ties
two correlations
z = (atanh r₁ − atanh r₂) / √(1/(n₁ − 3) + 1/(n₂ − 3)), for independent samples

Worked example

Worked example

The sample data is synthetic: 60 customers rated value for money (0–10) and overall satisfaction (0–100). Pearson's r = .784, t(58) = 9.63, p < .001, with 95% CI [.66, .87]. The two ratings share r² = .62 of their variance.

The rank coefficients tell the same story — Spearman's ρ = .78 and Kendall's τ-b = .60 (both p < .001) — so the result is not driven by a few extreme points.

In a second synthetic group of 70 returning customers the correlation is weaker, r = .34. Fisher's test of the difference gives z = 3.87, p < .001: value for money is more closely tied to satisfaction among new customers.

Using it well

When to use it

Use it when

  • Use: Two numeric measurements on the same respondents (ratings, scores, spend, time).
  • Use: Describing the strength and direction of a relationship before modelling it.
  • Use: Checking whether a relationship differs between two independent segments.
  • Use: Rank coefficients: ordinal scales, skewed data or outliers.

Not the right tool when

  • Avoid: Inferring causation — correlated variables may share a cause, or the direction may run the other way.
  • Avoid: Curved (non-monotonic) relationships — r can be near 0 even when y depends strongly on x.
  • Avoid: Two categorical variables — use Cramér's V or another association measure for crosstabs.
  • Avoid: Correlations from the same sample that share a variable — they are dependent, and Fisher's two-sample test does not apply.

How to interpret it

Rule of thumb

The sign gives the direction and the size the strength: by Cohen's rough convention |r| around .1 is small, .3 medium and .5 large, but what matters depends on the field. The p-value tests only whether ρ = 0 — with large samples tiny correlations become significant — so read the confidence interval for the plausible range of the true correlation. r² is the proportion of variance in one variable linearly associated with the other.

Questions

Frequently asked questions

What is a good correlation coefficient?

There is no universal threshold. Cohen suggested |r| ≈ .1 small, .3 medium and .5 large for behavioural research, but in survey work two ratings of the same experience often correlate above .5, while a correlation of .2 between an attitude and later behaviour can be meaningful. Judge it against the confidence interval and comparable studies.

How is the confidence interval for r calculated?

With Fisher's z transformation: z = atanh(r) is approximately normal with standard error 1/√(n − 3). The calculator builds the interval on the z scale and transforms the limits back with tanh, so the interval is asymmetric around r and stays inside −1 to 1.

Should I use Pearson or Spearman correlation?

Use Pearson for roughly linear relationships between continuous variables without extreme outliers. Use Spearman (or Kendall) for ranks, short ordinal scales, skewed data, outliers or curved but monotonic relationships. If both give similar values, report Pearson; if they differ, look at the scatter plot to see why.

How do I test whether two correlations are different?

For correlations from two independent groups, transform each with Fisher's z and compare: z = (atanh r₁ − atanh r₂) / √(1/(n₁ − 3) + 1/(n₂ − 3)). The comparison tab does this and also gives Zou's (2007) confidence interval for the difference. Correlations from the same sample need a dependent-correlation test instead.

What does r squared mean?

r² is the share of the variance in one variable that is linearly associated with the other — for example r = .5 means r² = .25, or 25% shared variance. It is also the R² of a simple linear regression of y on x.

Sources and next steps

References & further reading

  1. [1]Fisher, R. A. (1915). Frequency distribution of the values of the correlation coefficient in samples from an indefinitely large population. Biometrika, 10(4), 507–521.
  2. [2]Spearman, C. (1904). The proof and measurement of association between two things. American Journal of Psychology, 15(1), 72–101.
  3. [3]Kendall, M. G. (1938). A new measure of rank correlation. Biometrika, 30(1–2), 81–93.
  4. [4]Zou, G. Y. (2007). Toward using confidence intervals to compare correlations. Psychological Methods, 12(4), 399–413.
  5. [5]SciPy — scipy.stats.pearsonrdocs.scipy.org

Try it on your own data — free, no signup

Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.

Open the workspace →

← All calculators & guides