Home / Linear Regression

Linear Regression Calculator

Paste x,y pairs and get the least-squares line — slope, intercept, correlation coefficient r and R² — instantly and locally.

Why Use This Tool?

Linear regression finds the straight line that best fits your data — the workhorse behind trend lines, forecasting, and 'does X actually relate to Y'. This calculator computes the least-squares slope and intercept, plus the correlation coefficient r and its square R².

R² tells you how much of the variation the line explains: 1.0 is a perfect fit, 0.7 is a strong relationship, 0.2 means your line barely helps. Enter one x,y pair per line, in any order.

How It Works

  1. Paste your data — one x,y pair per line, separated by a space or comma.
  2. Click calculate — slope, intercept, r and R² appear instantly.
  3. Use the equation shown to make predictions inside your data range.

Frequently Asked Questions

How does a linear regression calculator work?

It applies the least-squares method: finding the slope and intercept that minimize the squared vertical distances between your points and the line — the standard formulas from any statistics text.

What does the correlation coefficient r mean?

r measures linear relationship strength from −1 to 1: near ±1 means points hug the line tightly, near 0 means no linear relationship. R² is r squared — the fraction of variance the line explains.

Can I use it to predict values outside my data?

Technically yes, but extrapolation beyond your data range is where regressions mislead — the relationship may not continue. Predictions inside the range are far safer.

Tips & Things to Watch

  • At least 2 points are needed; more points mean a more trustworthy fit.
  • All x values identical can't produce a line — the tool reports it.
  • Outliers drag the line hard — eyeball your data before trusting R².