Skip to content
Tezmy Tools

Linear Regression Calculator

Line of best fit, correlation and predictions from your x and y data

Separate x and y with a space, comma or tab. You can paste two columns from a spreadsheet.

Line of best fit

y = 2.02x − 0.02

R² = 0.99821, so about 99.8% of the variation in y is explained by x

2.02Slope (m)
-0.02Intercept (b)
0.9991 (very strong positive link)Correlation (r)
6Points used
0.17889Typical error of the fit
3.5, 7.05Mean of x, mean of y
16212.2
xyFitted yResidual
12.120.1
23.94.02-0.12
36.26.040.16
47.88.06-0.26
510.110.080.02
612.212.10.1

A strong link does not prove that x causes y. Check the scatter plot for curves and outliers, which a straight line can hide.

Runs in your browser. Nothing is uploaded.

About the Linear Regression Calculator

Linear Regression Calculator fits a straight line to your data by the method of least squares. Paste pairs of numbers, one x and y pair per line, or two columns copied from a spreadsheet, and the tool returns the equation of the line of best fit, the slope, the intercept, the correlation coefficient r, the coefficient of determination R², the typical size of the errors and a table of fitted values and residuals. A scatter plot draws your points with the line so you can see whether a straight line really suits the data. Enter a new x value to predict y, with a warning if the x is outside your data. Your data is worked out in your browser and is never uploaded.

Updated September 2026

How to use the Linear Regression Calculator

  1. 1Type or paste your data with one x and y pair on each line. A space, comma or tab can separate them.
  2. 2Read the equation of the line, the slope, the intercept, r and R².
  3. 3Look at the scatter plot to check that a straight line is a fair description.
  4. 4Enter an x value to predict y for it.
  5. 5Copy the equation, or use the residual table to look for points that do not fit.

What a line of best fit gives you

When two measurements go up and down together, such as advertising spend and sales, study hours and exam marks, or temperature and ice-cream orders, a line drawn through the scatter of points is the simplest summary. The slope tells you how much y changes when x goes up by one, the intercept tells you the value of y when x is zero and the correlation tells you how tightly the points hug the line.

With the equation you can estimate values you have not measured, provided the new x is inside the range of the data you fitted.

Reading the results

  • Slope: the change in y for each one-unit rise in x.
  • Intercept: the fitted value of y when x is zero, which may not make sense in the real world.
  • r: closeness to a straight line, from −1 to 1.
  • R²: the share of the variation in y explained by x.
  • Typical error: how far points usually sit from the line, in the units of y.

Checking that a line is appropriate

Always look at the scatter plot. A high R² can hide a curved pattern, and a single outlier can pull the line and change the slope. If the points bend, consider transforming the data, for example by taking logarithms, or use a different kind of model. Remove a suspicious point only when you know it is a mistake, not because it is inconvenient.

The residual table lists each point's error. Large residuals identify unusual points worth a second look.

Related tools

Slope Calculator finds the slope between two points, Standard Deviation Calculator describes the spread of a single list, Confidence Interval Calculator shows how uncertain an average is, Average Calculator gives means and medians and Percentage Calculator works out changes between values.

Features

  • Least-squares line of best fit
  • Slope, intercept, correlation r and R²
  • Plain-language strength of the relationship
  • Scatter plot with the fitted line
  • Prediction for any x, with a warning outside the data range
  • Table of fitted values and residuals
  • Paste two columns from a spreadsheet
  • Runs in your browser

Frequently asked questions

What is linear regression?

Linear regression finds the straight line that best describes how y changes with x. The best line is the one that makes the total of the squared vertical distances between the points and the line as small as possible. The result is an equation y = mx + b that you can use to predict y.

How do I find the line of best fit?

The slope is the sum of the products of each x and y deviation from their means, divided by the sum of the squared x deviations. The intercept is the mean of y minus the slope times the mean of x. The tool does this for you as soon as you paste your data.

What do r and R² mean?

The correlation r goes from −1 to 1 and shows how closely the points follow a straight line, and in which direction. R² is r squared and shows the share of the variation in y that the line explains. An R² of 0.85 means about 85 percent is explained by x.

Does a high correlation prove that x causes y?

No. Two things can move together because of a third cause, by coincidence or because the link runs the other way. Regression describes a pattern in the data and does not prove a cause.

How many points do I need?

Two points fit a line exactly, but they tell you nothing about reliability. For any real conclusions, use at least ten points and look at the plot. The tool needs at least two points and at least two different x values.

Is it safe to predict outside my data range?

It is risky. A straight line that fits well between x = 1 and 10 may be wrong at x = 100, because real relationships often curve or level off. The tool warns you when a predicted x is outside the range of your data.

What are residuals?

A residual is the difference between an actual y value and the value the line predicts for that x. Small, random residuals suggest a good fit. Residuals that grow, or that follow a curve, show that a straight line is not the right model.

Related tools