Regression Calculator

Perform linear regression analysis on x,y data. Fits a linear regression model (y = mx + b) to paired x,y data, computing slope, intercept, coefficient of…

Fits a linear regression model (y = mx + b) to paired x,y data, computing slope, intercept, coefficient of determination (R²), and the regression equation.

What Is Linear Regression?

Linear regression fits a straight line y = mx + b to observed (x, y) data by minimizing the sum of squared residuals — the vertical distances between data points and the fitted line. This Ordinary Least Squares (OLS) method produces the best linear unbiased estimator under the Gauss-Markov assumptions.

The slope (m) represents the change in y for a one-unit increase in x. The intercept (b) is the predicted y when x = 0. The coefficient of determination (R²) measures the proportion of variance in y explained by the model, ranging from 0 (no explanatory power) to 1 (perfect fit).

Linear regression assumes a linear relationship, constant variance of residuals (homoscedasticity), independence of observations, and approximately normal residuals. Violation of these assumptions can lead to biased or inefficient estimates.

Formula: y = mx + b m = [nΣxᵢyᵢ − ΣxᵢΣyᵢ] / [nΣxᵢ² − (Σxᵢ)²] b = ȳ − m·x̄ R² = 1 − Σ(yᵢ − ŷᵢ)² / Σ(yᵢ − ȳ)²

Example Calculation

Data: (1,2), (2,4), (3,5), (4,4), (5,5). n=5, Σx=15, Σy=20, Σxy=66, Σx²=55. m = (5×66 − 15×20)/(5×55 − 225) = (330−300)/(275−225) = 30/50 = 0.6. b = 4 − 0.6×3 = 2.2. Equation: y = 0.6x + 2.2. R² = 0.6.

When to Use This Calculator

Common Mistakes to Avoid

How to Interpret Results

Related Standards & References

Frequently Asked Questions

What does R² tell me and what is a 'good' value?

R² indicates the fraction of variance in the dependent variable explained by the model. In physical sciences, R² > 0.95 is common. In social sciences and economics, R² = 0.3-0.7 may be acceptable. A high R² does not prove causation, and a low R² does not mean the relationship is unimportant — it may just mean other factors are at play.

Can I use linear regression for non-linear data?

Not directly. If the relationship is curved, consider polynomial regression, logarithmic transformation (log-linear models), or other non-linear approaches. Plotting residuals vs. fitted values will reveal non-linearity: a pattern in the residuals indicates the linear model is inadequate.