Linear Regression Calculator

Calculate the least squares regression line (ŷ = mx + b) for any dataset

The linear regression calculator finds the least squares regression line ŷ = mx + b from x,y data pairs. Get slope, intercept, r², and predictions for new x values.

Linear Regression Calculator (ŷ = mx + b)

How to Use the Linear Regression Calculator

Linear regression finds the best-fit straight line through a set of data points, minimizing the sum of squared vertical distances from each point to the line.

Interpreting the Equation

For ŷ = 0.7x + 0.6: the slope 0.7 means for each 1-unit increase in x, y increases by 0.7 units on average. The intercept 0.6 is the predicted y when x = 0. Predictions are most reliable within the range of your data (interpolation), less so outside (extrapolation).

R² Interpretation

R² = 0.75 means the regression line explains 75% of the variability in y values. The remaining 25% is unexplained variance from other factors. R² close to 1 means an excellent fit; close to 0 means the linear model explains little variance.

Making Predictions

Enter an x value in the prediction field to get the estimated y. If studying hours vs test score gives ŷ = 4x + 55: for x=8 hours, predicted score = 4×8+55 = 87. Remember predictions have uncertainty — this is the expected average, not a guaranteed result.

Frequently Asked Questions

What is linear regression?

Linear regression finds the best-fit line ŷ = mx + b through a set of data points, minimizing the sum of squared vertical distances (residuals). The slope m = r × (Sy / Sx) and intercept b = ȳ − m × x̄. The line passes through the centroid (x̄, ȳ) of the data.

How do you interpret the regression slope?

The slope m is the change in y for each one-unit increase in x. If studying hours vs test score regression gives slope = 4, each additional study hour is associated with 4 more points. The intercept b is the predicted y when x = 0 (may or may not be meaningful depending on context).

Is this calculator free?

Yes, completely free with no signup required. All calculations run in your browser.

Is my data private?

Yes. All calculations run locally. Nothing is transmitted.

What is r² in regression?

R² (coefficient of determination) = r² where r is the Pearson correlation. It represents the proportion of variance in y explained by the regression model. R² = 0.75 means the line explains 75% of the variability in y. R² = 1 is a perfect fit. R² = 0 means the line explains nothing.