Linear Regression Calculator
Line of best fit, with r² and the standard error.
Line of best fit, with r² and the standard error. Least-squares regression finds the line minimising the squared vertical distances to your points.
Line of best fit
y = 1x + 1.3333
r² = 0.84 · very strong fit
r² is the share of variation in y explained by x, and it is literally r squared — which is where over-claiming usually starts. A correlation of 0.92 sounds very strong, but it accounts for only 84% of the variation. The other 16% is something else. And none of this establishes causation: a strong fit is equally consistent with x causing y, y causing x, or a third factor driving both.
How the Linear Regression Calculator works
Least-squares regression finds the line minimising the squared vertical distances to your points. It returns the equation, r², and the standard error — which is the spread of the points around the line and the figure that tells you how much to trust a prediction.
Also known as: line of best fit calculator · least squares regression calculator · regression equation calculator · slope and intercept from data
Where to go next
The Linear Regression question rarely arrives on its own. These are the ones that usually come with it:
- Correlation Calculator — Pearson's r, and the r² that deflates it.
- Slope Calculator — Slope, intercept and the line's equation from two points.
- Percentage Calculator — Every common percentage question in one place.
- Age Calculator — Exact age in years, months, days, and total units.
Frequently asked questions
What is linear regression?
Fitting the straight line that best predicts one variable from another, by minimising the sum of squared vertical distances from the points to the line.
What does the slope mean?
How much y changes for each one-unit increase in x. A slope of 2 means y rises by 2 for every 1 that x rises.
What does r² tell me?
The share of variation in y explained by x. An r² of 0.49 means about half the variation is accounted for and half is something else.
Why least squares?
Squaring makes all errors positive and penalises large misses disproportionately, which yields a unique solution with a closed form. It is also sensitive to outliers for exactly the same reason.
Put this calculator on your own site
Free to use, on any site, commercial or not. Paste this where you want it to appear. It is a plain iframe, so it works in WordPress, Squarespace, Wix, Webflow, Ghost and anything else that accepts HTML.
<iframe src="https://www.thecalclibrary.com/embed/linear-regression-calculator" width="100%" height="640" style="border:1px solid #e2e8f0;border-radius:12px" loading="lazy" title="Linear Regression Calculator"></iframe>
<p style="font:13px/1.5 system-ui,sans-serif;margin:6px 0 0;color:#64748b">Powered by <a href="https://www.thecalclibrary.com/linear-regression-calculator" style="color:#64748b">Linear Regression Calculator</a> from The Calc Library</p>The only condition is that the credit line below the frame stays in place. That one line is what pays for the tool being free — it is how anyone else finds it.
Related calculators
Correlation Calculator
Pearson's r, and the r² that deflates it.
OpenSlope Calculator
Slope, intercept and the line's equation from two points.
OpenPercentage Calculator
Every common percentage question in one place.
OpenAge Calculator
Exact age in years, months, days, and total units.
Open