Linear Regression Equation Calculator
Compute the best-fit linear regression equation from paired X and Y data using the least squares method. This calculator gives you the slope, intercept, R-squared value, and lets you predict Y for any given X.
Linear regression fits a straight line y = b0 + b1*x through a set of data points by minimizing the sum of squared residuals (the vertical distances between the observed and predicted Y values). The slope b1 tells you how much Y changes for each unit increase in X, and the intercept b0 is the predicted value of Y when X is zero.
The least squares formulas are: b1 = (nSigma(xy) - Sigma(x)Sigma(y)) / (nSigma(x^2) - (Sigma(x))^2) and b0 = y-bar - b1x-bar. These formulas minimize the total squared error, which is the standard optimality criterion for linear models.
The R-squared value tells you how well the line fits the data. An R-squared of 1.0 means the line passes through every point perfectly. In practice, R-squared above 0.7 indicates a good fit for many applications. Use the equation to predict Y for new X values, but be cautious about extrapolating far beyond the range of your data.