Skip to main content
Data analysis100% FreeInstant

Linear Regression Calculator: Line of Best Fit

This free linear regression calculator fits a straight line through your data. Enter pairs of x and y values and get the equation, slope, intercept, correlation, R squared and a prediction for any x.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

Linear regression draws the best straight line through a cloud of points. It is used to spot trends, forecast sales, calibrate instruments and teach statistics.

Enter your pairs, one per line, and read the line and its quality.

How to Use This Tool

  1. Enter one x and y pair per line, separated by a space or comma.
  2. Optionally enter an x to predict.
  3. Press Calculate.
  4. Read the equation, R squared and the prediction.

How the Calculation Works

The slope is b = (n Σxy − Σx Σy) ÷ (n Σx² − (Σx)²) and the intercept is a = (Σy − b Σx) ÷ n. The correlation r measures the strength of the linear link, R squared is r², and the standard error of the estimate shows the typical distance of the points from the line.

Worked Example

The points (1, 2), (2, 4), (3, 5), (4, 4), (5, 5) give y = 2.2 + 0.6x, with r = 0.7746 and R squared = 0.6. At x = 6 the prediction is 5.8.

Common Uses

  • Trend lines and forecasts.
  • Science and lab work.
  • Business analysis.
  • Homework and teaching.

Tips and Common Mistakes

  • Look at the points as well as R squared.
  • Outliers can pull the line a lot.
  • Do not extend far beyond your data.

Next, you may need the correlation calculator, confidence interval calculator, percentile calculator, standard deviation calculator.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

A method of finding the straight line y = a + bx that best fits a set of points, by minimising the sum of the squared vertical distances to the line.
The share of the variation in y that the line explains. 1 is a perfect fit and 0 means the line explains nothing.
No. A strong fit shows a relationship, not that x causes y.
You can, but it is risky. Predictions are most reliable inside the range of the x values you used.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.