Linear Regression Calculator
Line of best fit, with r² and the standard error.
Work out Linear Regression. Line of best fit, with r² and the standard error. Shows the working, not just the answer.
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
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>The only condition is that the credit line stays visible. It sits inside the frame, so you do not have to do anything to keep 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.
OpenStandard Deviation Calculator
Sample or population, said out loud rather than picked for you.
Open