Linear Regression Calculator

Least-squares best-fit line

CalculatorsFreeNo Signup
4.8(769 reviews)
All Tools

Loading tool...

About Linear Regression Calculator

A linear regression calculator using the least-squares method. Computes slope (m), intercept (b), R² (coefficient of determination), Pearson correlation (r), standard error, and predicts y for new x values. Shows residuals for each data point. All calculations are client-side. Essential for statistics, data science, and experimental analysis.

Linear Regression Calculator Features

  • y=mx+b
  • R² value
  • Pearson r
  • Residuals
  • Prediction
Linear regression finds the best-fit line y = mx + b that minimizes the sum of squared residuals. Slope m = (nΣxy−ΣxΣy)/(nΣx²−(Σx)²). Intercept b = ȳ − mx̄. R² measures goodness of fit (0 to 1). Pearson r = √R² with the sign of m.

How to Use

Enter data points:

  • X values: Comma-separated
  • Y values: Comma-separated
  • Result: Best-fit equation

R² Interpretation

  • R² = 1: perfect linear fit
  • R² > 0.9: strong correlation
  • R² > 0.7: moderate correlation
  • R² < 0.3: weak correlation

Prediction

Once you have y=mx+b, plug in any x to predict y. Reliable within the data range; extrapolation beyond is less trustworthy.

Step-by-Step Instructions

  1. 1Enter x values.
  2. 2Enter y values.
  3. 3View best-fit equation.
  4. 4Check R² and correlation.
  5. 5Predict y for new x.

Linear Regression Calculator — Frequently Asked Questions

What does R² mean?+

R² is the proportion of variance in y explained by x. R²=0.85 means 85% of y's variation is predicted by the linear model. The remaining 15% is unexplained.

What if my data isn't linear?+

Check the residuals. If they show a pattern (curved, not random), a nonlinear model may be better. Try polynomial regression or log transformation.

How many data points do I need?+

Minimum 3 for a meaningful regression, but 10+ is recommended. More data gives more reliable estimates and narrows confidence intervals.

Share this tool: