Least squares regression calculator
Fit a line to paired values and inspect residuals and R². Your inputs stay on your device.
Set up your task
Starting local processing
Ready. Processing stays in this browser.
2 Your result
Your result updates in this browser. Check your input if the result looks unexpected.
How to use Least squares regression calculator
Fit a line to paired values and inspect residuals and R². The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.
- Check the example inputs: x values, y values.
- Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.
- Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.
Supported inputs and limits
Enter two lists of up to 64 real numbers in matching observation order. Use at least two distinct x values.
How it works
A least-squares line estimates a response y from a predictor x. It minimises the sum of squared vertical gaps between the observations and the fitted line. The slope describes the fitted change in y per unit x. The intercept is the estimate when x equals zero.
Residuals expose where the model is under or over the observed values. The fitted line passes through the paired means when the model includes an intercept. R² compares residual variation with variation around the response mean. A tidy fit can still hide patterns in residuals or depend heavily on a single outlier.
Example
Run the pre-filled example. Its first result is “Slope: 2 · Intercept: 1”.
- x values
- 1 2 3
- y values
- 3 5 7
Slope: 2 · Intercept: 1 Sum of squared residuals: 0 R²: 1 Residuals: 0, 0, 0
Questions about Least squares regression calculator
Can the line be used to predict far beyond the input range?
A fitted line can be evaluated there, but the observed data do not show whether the relationship continues outside their range.
Why must x vary?
The slope formula divides by the sum of squared x deviations from their mean. A constant x column makes that denominator zero.
Keep x unchanged and make all three y values equal to 4.
The fitted line has slope zero and intercept four. R² is undefined because there is no response variation to explain.
Related tools
Last updated