Linear Regression Calculator
Calculate linear regression instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Linear Regression Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: y = mx + b | m = (nΣxy - ΣxΣy) / (nΣx² - (Σx)²) | b = (Σy - mΣx) / n
Worked example — y = 0.6x + 2.2, R² = 0.36
Formula
y = mx + b | m = (nΣxy - ΣxΣy) / (nΣx² - (Σx)²) | b = (Σy - mΣx) / n
Least squares linear regression finds the best-fit line through data points by minimizing the sum of squared residuals.
Worked Examples
Example 1: Simple dataset
Problem:X: 1,2,3,4,5 and Y: 2,4,5,4,5
Solution:m=(5×40-15×20)/(5×55-225)=0.6, b=(20-0.6×15)/5=2.2
Result:y = 0.6x + 2.2, R² = 0.36
Frequently Asked Questions
What is R²?
R² (coefficient of determination) measures how well the regression line fits the data. R²=1 means perfect fit, R²=0 means no linear relationship.
What is the difference between correlation and causation in regression?
Linear regression and R² measure the strength of a linear association between variables, not whether one causes the other. Ice cream sales and drowning rates are correlated (both rise in summer) but one does not cause the other. Always consider confounding variables and domain knowledge before concluding that the x variable causes changes in y.
When is linear regression not appropriate?
Linear regression assumes a linear relationship, homoscedasticity (constant variance of residuals), and independence of observations. It is not appropriate when the relationship is curved (use polynomial regression), when outliers are present and not addressed, when the residuals show clear patterns, or when predicting categorical outcomes (use logistic regression instead).
What is regression analysis and when should I use it?
Regression models the relationship between a dependent variable and one or more independent variables. Linear regression fits a straight line (y = mx + b). Use it to predict outcomes, identify which variables matter most, and quantify relationships. R-squared tells you what percentage of variation is explained by the model.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator · Editorial policy
Related Calculators
🧮Least Squares Regression Line Calculator
Calculate least squares regression line with inputs, formulas, and instant results.
🧮Linear Interpolation Calculator
Calculate linear interpolation with inputs, formulas, and instant results.
🧮Linear Combination Calculator
Calculate linear combination with inputs, formulas, and instant results.
🧮Linear Independence Calculator
Calculate linear independence with inputs, formulas, and instant results.
🧮Regression Equation Calculator
Calculate the regression equation, R-squared, and prediction intervals from data points.
🧮Linear Programming Calculator
linear programming calculator. Get instant, accurate results.
🧮Sum of a Linear Number Sequence Calculator
Calculate sum of alinear number sequence with inputs, formulas, and instant results.
🧮Equation Solver
Solve linear, quadratic, cubic, and polynomial equations with step-by-step solutions.