Guide
Linear regression: line of best fit, R², standard errors and predictions
Regression turns a cloud of points into a line you can read and use. It tells you how much y changes for each unit of x, how well a straight line describes the data and what to expect at a new x. This calculator fits an ordinary least-squares line to pasted x and y values, reports the standard errors and a significance test for the slope, predicts at any x with two kinds of interval and draws the scatter plot with the line and a confidence band.
How the line is fitted
Least squares chooses the slope and intercept that make the sum of the squared vertical distances from the points to the line as small as possible. The slope is the sum of the products of the deviations, Sxy, divided by the sum of squared x-deviations, Sxx, and the intercept is ȳ − slope · x̄, so the line always passes through the mean point. The residual of each point is its y minus the fitted value, and the table lists them for the first forty points.
Entering data
Type one x y pair per line, separated by a space, comma or tab, with at least three points; the page tells you which line has the wrong number of values. Set the confidence level, from 80% to 99.9%, and optionally an x at which to predict y. The page opens on eight points and x = 9. Every x must not be identical, otherwise no line can be fitted, and the message says so.
Reading the results
For the eight sample points the line is y = 1.997619x + 0.035714286. The slope has a standard error of 0.0278004, the intercept 0.140385, and the correlation coefficient is r = 0.99941947, so R² = 0.99883929: 99.88% of the variation in y is explained by x. The slope’s p-value is below 0.0001, the 95% interval for the slope is 1.9295938 to 2.0656443, the standard error of the estimate is 0.18016747 and n = 8 with 6 degrees of freedom. The page also labels the strength of the relation, here very strong and positive.
Predictions and intervals
At x = 9 the line gives 18.014286. The confidence interval for the mean of y at that x is 17.6708 to 18.3578, and the prediction interval for one new observation is 17.4554 to 18.5732, which is wider because it includes the scatter of individual points around the line. The dashed curves in the chart show the confidence band; it is narrowest at the mean of x and widens towards the ends of the data, where the line is less certain.
Worked examples
Height and weight in seven people (150 to 180 cm) give y = 0.81428571x − 70.642857, r = 0.99647913 and R² = 0.99297066, with a prediction of 66.157143 at 168 cm. Ice cream sales against temperature for ten days give y = 28.428184x − 156.74959, r = 0.92924086, R² = 0.86348858 and a slope p-value of 0.0001; at 20 degrees the prediction is 411.81409 with a prediction interval of 280.448 to 543.18, which is wide because the scatter is large. Each sample is a chip on the page.
Residuals and the scatter plot
Always look at the plot. A good fit has points scattered evenly above and below the line. A curve, a fan shape or a few extreme points can hide behind a high R², and R² can be high when a line is the wrong model. A prediction outside the range of your x values triggers a warning, because extrapolation assumes the same relationship holds where you have no data. Download the chart as SVG or PNG for a report.
Limits
The tool fits one straight line to one predictor. It does not do multiple regression, curves, logarithmic or exponential fits, weighted regression or robust methods, and it does not check the assumptions of independence, equal spread and normal errors that the intervals rely on. Correlation does not show cause: both variables may be driven by a third. For more than 40 points only the first 40 residuals are listed, though all are used in the fit.
Related tools
- Standard Error Calculator summarises a single variable before you relate two.
- T-Test Calculator compares group means rather than relating two measurements.
- Average Calculator gives the means that the fitted line passes through.
- Chi-Square Calculator tests relations between categories instead of numbers.
Checked against the current version of the Linear Regression Calculator on .

