TapCub is live — analytics, insights and live chat, free on one platform

Free tool Linear regression and correlation calculator, with the formula

Paste two columns of numbers, x and y, straight from a spreadsheet. You get the least-squares line, how strongly the two move together (Pearson r and R²), whether the slope is distinguishable from zero (standard error, t, p), predictions with honest intervals, Spearman’s rank correlation, and a scatter plot so you can see whether a straight line makes sense at all.

  • Line, r, R², p-value
  • Scatter plot
  • Runs locally
Calculator

Paste x and y

Results update as you type. A header row becomes the axis names; a label in front of the two numbers is ignored.

One pair per line, x first. Separate with a comma, tab or space; two columns copied from Excel or Google Sheets work as is. Use thousands separators only in tab-separated data.

Optional. Several values can be separated by commas.

For the intervals.

Regression equation

y = 22.4637x + 75.58 R² = 0.824202

Least squares, the same line as an Excel linear trendline.

Results

r = 0.9079: a strong positive linear relationship (p < 0.0001). Strong is not the same as causal.

Pearson r

0.90786

Strength and direction, −1 to 1.

R²

0.8242

Share of the variance in y explained by the line.

Slope b

22.464

Change in y per one unit of x.

Intercept a

75.58

Fitted y at x = 0.

p-value

< 0.0001

Two-tailed, for slope = 0 (same as r = 0).

Pairs (n)

12

Standard error of slope

3.2807

Standard error of intercept

13.56

t statistic

6.847

df = 10

Residual standard error

14.724

Typical distance of a point from the line.

95% CI for the slope

15.154 ~ 29.774

95% CI for r

0.69722 ~ 0.97419

Fisher z transformation.

F statistic

46.883

t² for simple regression.

Spearman ρ

0.88112

Rank correlation.

p-value for ρ

0.0002

t approximation.

Scatter plot

Each dot is one pair; the line is the least-squares fit; diamonds are your predictions.

Scatter plot with least-squares line12 points with the fitted line y = 75.58 + 22.4637x.DataFitted linePrediction100125150175200225123456Ad spend ($k)Ordersx = 5 → ŷ = 187.898

Predictions

The confidence interval is for the average y at that x; the prediction interval is for a single new observation, which is always wider.

xPredicted yConfidence interval (mean)Prediction intervalNote
5187.898175.592 ~ 200.205152.859 ~ 222.938

Calculation, step by step

Both forms of the correlation formula, with your numbers.

StepCalculation
Number of pairsn = 12
Meansx̄ = 47.1 ÷ 12 = 3.925 ȳ = 1965 ÷ 12 = 163.75
Sums of squares and cross-productsSxx = Σ(x − x̄)² = 20.1425 Syy = Σ(y − ȳ)² = 12332.3 Sxy = Σ(x − x̄)(y − ȳ) = 452.475
Pearson correlation coefficientr = Sxy ÷ √(Sxx·Syy) = 452.475 ÷ √(20.1425 × 12332.3) = 0.907856
Same r, computational formr = (nΣxy − ΣxΣy) ÷ √{[nΣx² − (Σx)²][nΣy² − (Σy)²]} Σx = 47.1, Σy = 1965, Σxy = 8165.1, Σx² = 205.01, Σy² = 334101
Slopeb = Sxy ÷ Sxx = 452.475 ÷ 20.1425 = 22.4637
Intercepta = ȳ − b·x̄ = 163.75 − 22.4637 × 3.925 = 75.58
Coefficient of determinationR² = r² = 0.824202 SSE = Σ(y − ŷ)² = 2167.99
Residual standard error, slope standard errors = √(SSE ÷ (n − 2)) = √(2167.99 ÷ 10) = 14.7241 SE(b) = s ÷ √Sxx = 3.28074
t-test for the slope (and for r)t = b ÷ SE(b) = 22.4637 ÷ 3.28074 = 6.84714 df = n − 2 = 10 p < 0.0001
Spearman’s rho (no ties)ρ = 1 − 6Σd² ÷ [n(n² − 1)] = 1 − 6 × 34 ÷ (12 × 143) = 0.881119

Residuals

Observed minus fitted. Residual ÷ s beyond ±2 is highlighted; a pattern here means a straight line is the wrong model.

#xyFitted ŷResidualResidual ÷ s
12.1126122.7543.246250.220
23.4148151.957−3.95656−0.269
31.8109116.015−7.01465−0.476
44.6171178.913−7.91299−0.537
53.9186163.18822.81161.549
65.2183192.391−9.39121−0.638
72.7152136.23215.7681.071
84.1150167.681−17.6811−1.201
96214210.3623.637830.247
103128142.971−14.9711−1.017
115.5191199.13−8.13032−0.552
124.8207183.40623.59431.602
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Version v1.0Updated Update history

Reading the result

What the regression says about ad spend and orders

The default data: 12 weeks of ad spend (in thousands of dollars) and orders.

The line

y = 22.46x + 75.58: each extra $1,000 of spend goes with about 22.5 more orders a week. The intercept, 75.6, is the line’s value at zero spend, but the data start at $1,800, so treat it as part of the line rather than as a forecast of a week with no ads.

r and R²

r = 0.908 is a strong positive linear relationship. R² = 0.824 means the line accounts for 82% of the week-to-week variation in orders; the other 18% is everything else: seasonality, promotions, chance.

Standard error, t and p

The slope’s standard error is 3.28, so t = 22.46 ÷ 3.28 = 6.85 with 10 degrees of freedom and p = 0.00004. The 95% confidence interval for the slope, 15.2 to 29.8 orders per $1,000, excludes zero by a wide margin.

Prediction

At $5,000 the line predicts 188 orders. The average week at that spend is likely between 176 and 200 (confidence interval), but a single week could land anywhere from 153 to 223 (prediction interval). Plan with the wider one.

None of this shows that ads caused the orders. If the budget is raised in weeks that are busy anyway, spend and orders rise together without one driving the other. To measure the effect, change spend on purpose and compare, or look at attribution per order.

How to use it

Paste, look, then read the numbers

No button to press; results refresh as you type.

  1. 1

    Paste two columns

    x first, y second, one pair per line. Copying two adjacent columns from a spreadsheet gives tab-separated text, which works directly. A header row becomes the axis names.

  2. 2

    Look at the scatter plot first

    If the dots curve, fan out or hinge on one point, r and the p-value describe the wrong model. The Anscombe buttons load two classic datasets with exactly the same r as a tidy one.

  3. 3

    Read, predict, copy

    Read r and R² for strength, the slope and its interval for size, then enter x values to predict. Copy the steps table if you need to show your working.

Correlation and regression formulas

One sum of cross-products, two questions

Everything starts from the means and three sums: Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)² and Sxy = Σ(x − x̄)(y − ȳ). The Pearson correlation scales Sxy to the range −1 to 1; the least-squares slope divides it by Sxx. The t-test for the slope and the t-test for r give the same t and p.

  • Pearson r = Sxy ÷ √(Sxx · Syy); computational form r = (nΣxy − ΣxΣy) ÷ √{[nΣx² − (Σx)²][nΣy² − (Σy)²]}
  • Slope b = Sxy ÷ Sxx; intercept a = ȳ − b·x̄; R² = r² in simple regression
  • Residual standard error s = √(SSE ÷ (n − 2)); SE(b) = s ÷ √Sxx; t = b ÷ SE(b) = r√(n − 2) ÷ √(1 − r²), df = n − 2
  • Confidence interval for the mean at x₀: ŷ ± t* · s · √(1/n + (x₀ − x̄)² ÷ Sxx); prediction interval adds 1 under the root
  • Spearman’s ρ is Pearson r computed on ranks; with no ties, ρ = 1 − 6Σd² ÷ [n(n² − 1)]
  • Verbal labels follow Cohen’s (1988) conventions: |r| ≈ 0.1 small, 0.3 medium, 0.5 large. They are a rough guide, not a law
  • Checked against the NIST StRD reference dataset Norris (certified slope, intercept, standard errors and R²)

Pearson correlation coefficient

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

Default data: r = 0.908

Least-squares line

b = Sxy ÷ Sxx, a = ȳ − b·x̄

y = 22.46x + 75.58

t-test for the slope

t = b ÷ SE(b), df = n − 2

22.46 ÷ 3.28 = 6.85, p = 0.00004

Worked example

Anscombe’s quartet: same numbers, different stories

In 1973 the statistician Francis Anscombe published four small datasets with practically identical regression output. Only the scatter plots tell them apart. Datasets II and III are one click away above.

Regression results for Anscombe’s four datasets (11 points each)
DatasetSlopeInterceptrWhat the scatter plot shows
I0.5003.000.816A straight-line trend with scatter: the model fits
II0.5003.000.816A smooth curve: a straight line is the wrong shape
III0.5003.000.816A perfect line except one point that tilts it
IV0.5003.000.817Ten points at x = 8 and one far away that creates the whole slope

Source: F. J. Anscombe, “Graphs in Statistical Analysis”, The American Statistician 27(1), 1973. The calculator reproduces these figures; the residual table and scatter plot reveal the differences.

Common mistakes

How correlations get over-read

The formulas are exact. The interpretation is where most reports go wrong.

Reading correlation as causation

Spend and orders, traffic and revenue, page speed and conversion often move together because something else drives both. A strong r is a reason to run a test, not a conclusion.

Skipping the scatter plot

A curve, a fan shape or a single influential point can produce a high r. Anscombe’s quartet is the classic demonstration: four datasets, one r, four different pictures.

Predicting far outside the data

A line fitted between $1,800 and $6,000 says nothing reliable about $20,000. Diminishing returns are the rule in marketing, not the exception.

Treating a low p as a strong relationship

With thousands of points, r = 0.05 can be “significant” and still explain 0.25% of the variation. Report r or R² alongside p.

FAQ

Linear regression and correlation questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is the linear regression formula, and how do I calculate it by hand?

The least-squares line is ŷ = a + b·x, with slope b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² = Sxy ÷ Sxx and intercept a = ȳ − b·x̄. Default data (12 weeks of ad spend and orders): x̄ = 3.925, ȳ = 163.75, Sxy = 452.475, Sxx = 20.1425, so b = 452.475 ÷ 20.1425 = 22.464 and a = 163.75 − 22.464 × 3.925 = 75.58: ŷ = 22.46x + 75.58, and $5k predicts about 188 orders. Unlike r, the slope has units (orders per $1k) and changes if you swap x and y.

How do you calculate the correlation coefficient r?

Subtract the mean from every x and every y, multiply the paired deviations and add them up (Sxy), then divide by the square root of Σ(x − x̄)² × Σ(y − ȳ)². Equivalently, r = (nΣxy − ΣxΣy) ÷ √{[nΣx² − (Σx)²][nΣy² − (Σy)²]}. The steps table shows both with your numbers.

What counts as a strong correlation?

Common labels follow Cohen (1988): around 0.1 is small, 0.3 medium and 0.5 or more large, in either direction. In fields with very precise measurements, 0.9 may count as weak. Always look at the scatter plot: the label describes a straight-line relationship only.

What is the difference between r and R²?

r is the correlation, from −1 to 1, and carries the direction. R² is the share of variance in y explained by the line, from 0 to 1. In simple linear regression R² = r², so r = 0.9 explains 81% of the variance and r = 0.5 only 25%.

How is the p-value calculated?

From the t-test for the slope: t = b ÷ SE(b), with n − 2 degrees of freedom, two-tailed. It tests whether the true slope (and therefore the true correlation) is zero. It assumes independent points and roughly normal, equal-spread residuals around the line.

Should I use Pearson or Spearman?

Pearson measures a straight-line relationship between the values. Spearman measures whether y tends to rise (or fall) as x rises, using ranks, so it tolerates outliers and curves that keep one direction. If the two differ a lot, look at the scatter plot: an outlier or a curve is usually why.

Does correlation imply causation?

No. A third factor can drive both (season, promotions, company size), the causation can run the other way, or the pattern can be chance across many comparisons. Correlation is a reason to investigate, ideally with a controlled experiment such as an A/B test.

How do I do linear regression in Excel or Google Sheets?

SLOPE(y, x), INTERCEPT(y, x), CORREL(x, y) or PEARSON, RSQ(y, x) and STEYX(y, x) for the residual standard error; LINEST(y, x, TRUE, TRUE) returns the standard errors too, and FORECAST(x, y, x) predicts. Note the argument order: y comes first in SLOPE and INTERCEPT.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

Next step

From a relationship to a test

A correlation says two metrics move together. The next step is usually to compare groups directly or to test a change.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics