Advertisement

📈 Regression Calculator

Calculate simple linear regression (y = mx + b) from paired X and Y data. Get the slope, intercept, R², and make predictions for any X value.

Linear Regression Formulas

Slope
m = [n Σxy − (Σx)(Σy)] / [n Σx² − (Σx)²]
Intercept
b = (Σy − m × Σx) / n
R² (coefficient of determination)
R² = 1 − SSR / SST

How to Use Linear Regression

  1. 1
    Enter Paired Data
    Input X values (independent variable) and corresponding Y values (dependent variable) in comma-separated format.
  2. 2
    Review the Equation
    The regression line y = mx + b gives you the best linear fit. m is the slope (rate of change) and b is where the line crosses the Y axis.
  3. 3
    Evaluate R²
    R² ranges from 0 to 1. Higher values mean the line explains more of the variance in Y. An R² of 0.9 means 90% of variation is captured.
  4. 4
    Make Predictions
    Enter any X value in the prediction box to calculate the expected Y using y = mx + b. Only interpolate within your data range for reliable predictions.

Worked Example

X = 1, 2, 3, 4, 5 — Y = 2, 4, 5, 4, 5

n=5 | Σx=15 | Σy=20 | Σxy=64 | Σx²=55
m = [5×64 − 15×20] / [5×55 − 15²] = 20/50 = 0.4
b = (20 − 0.4×15) / 5 = (20 − 6) / 5 = 2.8
Equation: y = 0.4x + 2.8
Predict x=6: y = 0.4×6 + 2.8 = 5.2

Frequently Asked Questions

Linear regression finds the best-fit straight line through a set of data points, described by y = mx + b. It minimises the sum of squared differences between observed Y values and the predicted values on the line.

The slope (m) represents how much Y changes for a one-unit increase in X. A slope of 2 means every time X goes up by 1, Y is expected to go up by 2.

R² (coefficient of determination) is the proportion of variance in Y explained by X. R²=0.8 means 80% of the variation in Y is captured by the linear model. R²=1 is a perfect fit.

Substitute your X value into the equation y = mx + b. For reliable predictions, stay within the range of your original data (interpolation). Predictions beyond your data range (extrapolation) are less reliable.

Related Calculators