Least Squares Regression Calculator

Paste x,y data and fit a straight line or polynomial trendline. The tool reports the equation, coefficients with standard errors, R², adjusted R², RMSE, residual spread, per-point fitted values, and optional predictions — entirely in your browser.

Try:
Regression result

About this tool

Least-squares regression finds the curve that minimises the sum of squared residuals between your observed y values and the model's fitted values. Paste two columns of data (x,y), choose a polynomial degree, and the calculator returns the fitted equation plus the diagnostics you need to judge the model.

The default is ordinary straight-line regression:

x,y
1,2
2,4
3,5
4,4
5,5

With degree 1, the output begins:

y = 0.6000·x + 2.2000

and includes R², adjusted R², Pearson r, RMSE, residual standard error, coefficient estimates with standard errors, and residual min/median/max. Add values in Predict at x values (for example 6, 7) to evaluate the fitted model at new points.

Set degree 2 for a quadratic, degree 3 for a cubic, or any degree up to 10 when you have enough distinct data points. Use Separate y values when your x and y series are copied from different spreadsheet columns. Use Output to switch from the readable text report to CSV tables or structured JSON.

Limits and edge cases

FAQ

What is least-squares regression?

It is the standard method for fitting a line or curve by minimising the total squared vertical distance between the data points and the model. Squaring makes large misses count more than small misses and gives a deterministic closed-form fit for linear-in-the-coefficients models such as polynomials.

When should I use polynomial degree greater than 1?

Use degree 2 or 3 only when the scatterplot clearly bends and you have enough points to support the extra coefficients. Higher degrees can fit the sample very closely while behaving badly between or beyond points. If you only need a straight trendline equation and R², leave the degree at 1.

Why did the tool say the fit is rank-deficient?

The chosen degree is not identifiable from the x values you supplied. Common causes are too few distinct x values, duplicate x coordinates with a high-degree polynomial, or x values so large that powers of x become numerically unstable. Lower the degree, add more spread-out points, or centre/scale x before fitting.

What is the difference between RMSE and residual standard error?

RMSE is sqrt(RSS / n), so it averages residual size over all points. Residual standard error is sqrt(RSS / df) where df subtracts the number of fitted coefficients; it is the usual regression estimate of noise scale and grows when the model spends more degrees of freedom on coefficients.

Can I force the fitted line through zero?

Yes. Turn off Fit intercept to fit through the origin. Do this only when the domain demands that x = 0 implies y = 0; otherwise it can bias the slope and make R² harder to compare with ordinary intercept models.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool least-squares-regression "x,y
1,2
2,4
3,5
4,4
5,5"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/least-squares-regression/?data=x%2Cy%0A1%2C2%0A2%2C4%0A3%2C5%0A4%2C4%0A5%2C5&y_values=2%2C%204%2C%205%2C%204%2C%205&degree=1&header=auto&intercept=true&predict_x=6%2C%207&decimals=4&format=text

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.