About Least Squares Regression Line Calculator
This calculator finds the least squares regression line, the straight line that makes the sum of the squared vertical errors as small as possible. It opens on advertising spend against sales and shows every step. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
The slope is the cross deviation sum Sxy divided by Sxx, and the intercept makes the line pass through the point of means. The steps panel writes both with your numbers and the equation is typeset in KaTeX.
Below the result you get r, r², the standard error of the estimate, a t test for the slope and a residual plot, so you can judge the fit as well as compute it.
How to use Least Squares Regression Line Calculator
- Paste two columns from a spreadsheet or type one x, y pair per line. A text first line is used as the axis names.
- Choose the model: linear, polynomial, exponential or logarithmic. For a polynomial, pick the degree.
- Read the equation and the statistics table. For the line, the slope p-value tests whether x helps predict y at all.
- Type an x value in the prediction box to get the predicted y and, for the linear model, its intervals.
- Check the residual plot. Residuals should scatter randomly around zero. A curve or a funnel means the model is wrong or the spread changes.
- Open the comparison table to see which model has the highest R², and look at adjusted R² before trusting a high degree.
Features
- Least squares line with slope, intercept, r, r², standard error of the estimate and of the slope.
- t test and p-value for the slope, with confidence intervals for slope and intercept.
- Prediction interval for one new point and confidence interval for the mean response.
- Polynomial regression of degree 2 to 6, exponential y = a·e^(bx) and logarithmic y = a + b·ln x.
- Model comparison table with R² and adjusted R².
- Equation in KaTeX, scatter plot with fitted curve and prediction band, and PNG download.
- Residual plot and a residuals table with fitted values.
- Step by step working for the least squares line, copyable as LaTeX.
The regression line
The line has slope m and intercept b, written ŷ = b + mx.
m = Σ(x − mean x)(y − mean y) / Σ(x − mean x)²
b = mean y − m × mean xWorked examples
Ad spend 1 to 8 against sales (8 points) gives ŷ = 0.1714 + 1.979x
r² = 0.9946, so the line explains 99.5% of the variation in sales. Each extra unit of spend adds about 1.98 to sales.
Privacy: how it works
- Everything is calculated by code running in your browser tab. Your data is not sent to Ulkaa or to any other server, and there is nothing to sign in to.
Tips
- A high R² does not prove a good model. Look at the residual plot as well.
- Prefer the lowest degree that fits. Adjusted R² drops when an extra term adds nothing.
- For the exponential model, R² is measured on the original y, so it can be compared fairly with the line.
- If the points form a curve that rises and levels off, try the logarithmic model.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your data are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your data are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
Why is it called least squares?
Because the line is chosen to make the sum of the squared residuals, the vertical gaps between points and line, as small as possible.
Does the line always pass through the means?
Yes. The least squares line always passes through the point (mean x, mean y).
What is a residual?
A residual is the observed y minus the y the line predicts. The residuals table lists all of them and they always add up to zero.
More Linear Regression Calculator pages
- Linear Regression CalculatorPaste x, y data to fit a least squares line and compare it with polynomial, exponential and logarithmic models.
- Line of Best Fit CalculatorPaste your points to see the best fit line on a scatter plot, with its equation and predictions.
- Polynomial Regression CalculatorPaste x, y data to fit a quadratic, cubic or higher degree curve, up to degree 6.
- Exponential Regression CalculatorPaste x, y data to fit y = a·e^(bx) and see the growth factor per step.