Linear Regression Calculator

Enter x and y values (comma-separated) with equal counts. At least 2 pairs required.

Linear Regression — Formula

Regression line y = bx + a

b = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)²   (slope)
a = ȳ − b×x̄   (intercept)

R² (coefficient of determination)

R² = 1 − SSᵣᵉᵗ / SSᵗᵒᵗ  —  ranges 0–1. Closer to 1 = better fit.

Related Calculators

Understanding Linear Regression

Linear regression finds the best-fit straight line through a set of data points, minimising the sum of squared vertical distances from each point to the line (the least squares method). The result is the equation y = mx + b, where m is the slope (how much y changes per unit of x) and b is the y-intercept (the value of y when x = 0). The R² value (coefficient of determination) tells you what proportion of variance in y is explained by x — R² = 1.0 means a perfect fit, R² = 0 means x explains nothing about y.

Linear Regression Applications

Linear regression is one of the most widely used tools in statistics, data science, and business analytics. Common examples include predicting house prices from square footage, forecasting sales from advertising spend, estimating crop yield from rainfall, and modelling how exam scores relate to study hours. It is the foundation of more complex models like multiple regression, polynomial regression, and neural networks.

R² valueInterpretation
0.0 – 0.3Weak relationship
0.3 – 0.7Moderate relationship
0.7 – 1.0Strong relationship

Interpreting Linear Regression Output

Linear regression finds the best-fit line ŷ = a + bx through a scatter plot of data points. The slope (b) tells you how much y changes for a one-unit increase in x — a positive slope means the variables increase together; negative means they move oppositely. The y-intercept (a) is the predicted y when x = 0 (meaningful only if x = 0 is plausible in context). The R² (coefficient of determination) ranges from 0 to 1 and represents the proportion of variance in y explained by x.

An R² of 0.85 means 85% of the variation in the outcome is explained by the predictor. R² = 1 indicates a perfect linear fit; R² = 0 means x has no linear predictive value. Always plot your data — a high R² can still mask non-linear patterns or outlier distortion (Anscombe's Quartet). Use regression for forecasting sales from ad spend, predicting weight from height, estimating energy use from temperature, or analyzing time-series trends.

Regression Output Reference

MetricMeaningGood Value
Slope (b)Δy per unit ΔxDepends on context
Intercept (a)y when x=0Depends on context
Variance explained> 0.7 for most uses
p-valueSignificance of slope< 0.05 to reject H₀
Std ErrorAccuracy of estimateSmaller is better
Have Feedback or a Suggestion? Contact Us
Top