Regression Calculator

Fitting a Line Through Scattered Points

Correlation tells you two variables move together; simple linear regression goes a step further and produces an actual equation for predicting one from the other. It finds the line that minimizes the total squared vertical distance between itself and every data point — the "least squares" line — which is why it's the default starting point for prediction whenever a relationship looks roughly linear.

The Formula

slope (b1) = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)²
intercept (b0) = ȳ − b1 × x̄
Regression Equation: y = b1x + b0

The slope tells you how much y changes per one-unit increase in x; the intercept is the predicted y when x is zero. R² (the square of the correlation coefficient) reports what fraction of the variation in y the line accounts for.

Worked Example

Linear regression, x = 1,2,3,4,5 and y = 2,4,5,4,5
EquationPredicted y at x = 6
y = 0.6x + 2.20.6005.8

R² = 0.60 means the linear trend accounts for 60% of the variation in y; the remaining 40% is scatter the straight line doesn't explain. Extrapolating to x = 6, outside the original data range, carries more uncertainty than predicting within it.

Where This Matters

  • Forecasting — projecting sales, costs, or demand forward based on a historical linear trend.
  • Scientific calibration — converting an instrument reading into a real-world quantity using a fitted line from known reference points.
  • Real estate and pricing — estimating how price changes with square footage, age, or another single continuous factor.
  • Trend analysis — quantifying the rate of change in a metric over time (the slope) rather than just eyeballing a chart.
Note: A regression line is only as good as the linear assumption behind it. Always check R² and, ideally, plot the data — a low R² means the straight-line model is a poor fit regardless of how confident the slope and intercept look.

How to Use This Calculator

  1. Enter your X values, separated by commas.
  2. Enter your Y values, separated by commas, matched in order to the X values.
  3. Optionally enter a value to predict Y at a specific X.
  4. Select Calculate to get the regression equation, R², and (if requested) the prediction.

Related Calculations

Check the strength of the relationship first with the Correlation Calculator. To measure how far individual points sit from this fitted trend, use the Standard Deviation Calculator on the residuals.