Linear Regression Calculator

Best-fit line, R² and residuals

Linear regression calculator — fit the least-squares line y = mx + b to paired data, with slope, intercept, R², residuals and a scatter plot.

How to use Linear Regression Calculator

  1. Paste x, y pairs — one pair per line, at least 3.
  2. Read the slope, intercept, R² and standard error.
  3. Use the line y = mx + b to predict y for any x.

Features

  • Least-squares fit
  • Slope & intercept
  • R² & standard error
  • Residuals table
  • Scatter plot
  • Copy result

Frequently asked questions

What is a linear regression calculator?

A linear regression calculator fits the least-squares straight line ŷ = a + bx to paired (x, y) data. The slope is b = (nΣxy − ΣxΣy) / (nΣx² − (Σx)²) and the intercept is a = ȳ − b·x̄. This tool also reports R², the standard error, a residuals table and a scatter plot of the points with the fitted line.

How do I find the slope and intercept?

Enter your pairs and read them off the result. Worked example from the Pearson guide: hours studied vs exam score (1, 55), (2, 58), (3, 65), (4, 70), (5, 74) gives slope 5 and intercept 49.4, so the line is ŷ = 49.4 + 5x. At 6 hours it predicts 79.4. The copy button gives the same line as 'y = 5x + 49.4, R² = 0.9874'.

What do R² and the correlation coefficient mean?

R² is the share of the variation in y that the line explains, from 0 to 1. The study-hours example scores R² 0.9874, so the line explains 98.74% of the variation; r, the correlation coefficient, is the square root with the slope's sign, about 0.9937 here. The tool's Perfect line preset (10, 20), (20, 40), (30, 60), (40, 80), (50, 100) scores R² 1 — every point sits exactly on y = 2x.

What are residuals and the standard error?

A residual is the gap between an observed y and the line's prediction ŷ at the same x. The tool lists x, y, ŷ and the residual e for every point (first 20 rows when there are more). The standard error is √(Σe² / (n − 2)): 0.8944 for the Positive trend preset and 0 for a perfect fit. Smaller means the points hug the line more tightly.

How many data points do I need?

At least 3 pairs, and at most 200. Each line needs two numbers; values beyond ±1,000,000,000,000 are rejected. If every x is the same, the slope formula divides by zero and the tool shows no fit — a line needs x values that actually vary.

Can I use the line to predict a value?

Yes — plug any x into the fitted line ŷ = a + bx. The Negative trend preset (1, 10), (2, 8), (3, 6), (4, 4), (5, 2) fits ŷ = 12 − 2x, so x = 6 predicts 0. Treat predictions outside your data's range with care: the study-hours line predicts 349.4 at x = 60, far beyond the 1–5 hours measured, and extrapolation like that is unreliable.

Login to use this free online tool. Create a free account to get started.

Featured on Twelve Tools Hunt for Tools Featured on LaunchBuff Launch Llama Tools Launch your MCP Top Web Development Companies in the US - OnToplist.com Designer Listings Listed on SeeWhatNewAI Featured on SubmitMySaas Featured on AI Agents Directory Product Wing SaaS Wheel Featured on Stremit Featured on Thank John We Are Founders SubmitMySaas ShinyLaunch SaaS Tools Dir Featured on SaasHunt Product List Dir Featured on ShowMeBestAI Listed on Best-AI.org Featured on SaaSCity Listed on LaunchPact CodexFuse Solution on goodSaaS Featured on IndieLaunch Featured on BestAIApps AI X Collection Featured on SemiLaunch Listed on AlterBase We Like Tools codexfuse.dev LaunchClash Featured on Next Launch