Free online tools

Linear Regression Calculator

Paste x and y values to fit a straight line with an intercept. Add a new x to evaluate the fitted line, then check the residuals for the original data.

Enter your values

Enter up to 1,000 pairs, one per line, without a header. Separate x and y with a comma, semicolon, space or spreadsheet tab. Use decimal points and omit thousands separators.

Clear this field to fit the line and report residuals only.

This tool processes your input in your browser.

Result

Fit a line to the observed points

Ordinary least squares chooses the slope and intercept that minimize the sum of squared vertical residuals. For the five example pairs, the fitted line is ŷ = 1.3 + 0.9x. In this model, a one-unit increase in x corresponds to a 0.9-unit increase in fitted y.

Use residuals to inspect the fit

A residual is observed y minus fitted y. At x = 3 in the example, the actual y is 5 and the fitted y is 4, so the residual is 1. R² is 0.81, indicating that the fitted line accounts for 81% of the observed variation in y about its mean. The result also includes the root mean squared residual, using the number of pairs as its divisor.

Evaluate a target x within the observed range when possible

The fitted y at x = 4.5 is 5.35 for the example. An x above 5 or below 1 extends the fitted line past the observations and is marked as extrapolation. Predictions are point estimates based on this line. A curved pattern or a single influential observation can make the line a poor predictor.

Frequently asked questions

What happens if all x values are equal?

There is no independent variation in x to estimate a unique slope, so the calculator asks for at least two different x values.

What happens if all y values are equal?

When x varies, the fitted line is horizontal and its intercept equals the common y value. R² is undefined here because observed y has zero total variation.

Can I copy the residual table into a spreadsheet?

Yes. The columns are separated by tabs, one observation per row. The result text area contains just the table. The copy button also includes the equation and summary.