Linear Regression Calculator
A linear regression calculator is a statistical analysis tool that models the relationship between an independent variable and a dependent variable. The calculator processes a set of data pairs to compute the line of best fit using the least squares method, outputting the regression equation in the form y equals ax plus b. It also calculates the correlation coefficient, the coefficient of determination (R-squared), and residuals. Data analysts and researchers use this tool to predict future trends and verify mathematical models.
Add paired x and y values and the calculator returns the best-fit line y = mx + b, the slope and intercept, the Pearson r and r squared, and an optional predicted y for a chosen x.
Quick Answer
Find the line of best fit for your data points. Enter your coordinate pairs to calculate the linear regression equation and regression metrics.
Leave blank to skip the prediction. · e.g. 6
Need at least two distinct x values. The slope is undefined if every x is the same (zero variance in x).
5 pairs · r² = 0.9971
y = 1.47x + 0.53
r = 0.9985
Examples
Pairs (1,2), (2,3.5), (3,5), (4,6.2), (5,8)
y ≈ 1.46x + 0.58, r² ≈ 0.991
Pairs (10,20), (20,30), (30,40), (40,50)
y = x + 10 exactly, r = 1
Pairs (1,5), (2,4), (3,6), (4,5), (5,7)
y = 0.5x + 4.1, r² ≈ 0.625
How it works
Find the means of x and y. Compute the deviations from each mean for every pair. The slope is the sum of cross-products divided by the sum of squared x-deviations. The intercept comes from the means.
Slope (m) · Σ((x − x̄)(y − ȳ)) ÷ Σ(x − x̄)²
Intercept (b) · ȳ − m × x̄
Prediction · ŷ = mx + b
r² is the proportion of variance in y explained by the line.
Related statistics calculators
- Correlation coefficient calculator for r alone without fitting a line.
- Mean, median, mode calculator for basic descriptive statistics on x or y individually.
- Variance calculator for variance on each variable.
- Standard deviation calculator for the spread underlying the slope and r.
- Scientific calculator for general arithmetic and prediction follow-ups.
- System of equations calculator for the exact-solution counterpart when the model passes through every point.
- RREF calculator for the matrix view of the same linear system.
- All education calculators.
Related Calculators
More tools from Education



