📈 Regression Calculator
Fit a least-squares line to paired data: slope, intercept, R², predicted y, and residual context.
Linear Regression — Predict y from x with a Line
BrainyCalculators editorial insight — unique to this tool
Simple linear regression fits ŷ = mx + b to minimize squared errors — a SaaS founder might regress monthly ad spend (x) on new signups (y) to forecast next quarter. R² tells you what fraction of variance in y is explained by x; R² = 0.72 means 72% of signup swings track spend linearly. Regression extends correlation by giving intercept, slope, and point predictions, not just strength.
When to use this calculator
Use when you need to predict or interpolate one variable from another and assume a linear relationship. For only measuring association strength, Correlation is enough.
| Reference | Value | Context |
|---|---|---|
| Slope m | Δy per unit Δx | Interpretation key |
| R² = 0.80 | 80% explained | Good fit heuristic |
| Residual check | Pattern in errors | Linearity assumption |
| Extrapolation risk | Outside data range | Often unreliable |
Not what you need? For curved relationships, simple linear regression misleads — consider polynomial tools. For r without prediction, use Correlation.
Only measuring association, not fitting a line?
This page fits a regression line. For correlation coefficient without prediction, use the Correlation Calculator →
Predict Y for a given X
| # | x | y | ŷ (predicted) | Residual (y−ŷ) | Residual² |
|---|
What is Linear Regression?
Linear regression fits y = mx + b to a set of (x, y) points by minimizing squared errors. It outputs slope, intercept, correlation strength, and predicted values for new x.
Use this page when you have two numeric columns and want a predictive line. It models trend; it does not merely report whether two variables move together without a line fit.
For Pearson correlation without fitting a line, use the Correlation Calculator. For slope between exactly two points, use the Slope Calculator.
Linear Regression Formulas
How to Use Linear Regression
-
1Enter Paired DataInput X values (independent variable) and corresponding Y values (dependent variable) in comma-separated format.
-
2Review the EquationThe regression line y = mx + b gives you the best linear fit. m is the slope (rate of change) and b is where the line crosses the Y axis.
-
3Evaluate R²R² ranges from 0 to 1. Higher values mean the line explains more of the variance in Y. An R² of 0.9 means 90% of variation is captured.
-
4Make PredictionsEnter any X value in the prediction box to calculate the expected Y using y = mx + b. Only interpolate within your data range for reliable predictions.
Worked Example
X = 1, 2, 3, 4, 5 — Y = 2, 4, 5, 4, 5
How the Regression Calculator Works
Formula, assumptions, and calculation steps for this statistics tool.
Formula Used
y = mx + b, where m = covariance(x, y) / variance(x)
Methodology
Statistics calculators organize sample data, apply the selected descriptive or inferential formula, and report the statistic with interpretation.
Calculation Steps
- Enter raw values or summary statistics.
- Clean separators and count the sample size.
- Apply the relevant statistic, probability, or confidence formula.
- Display the result with context such as degrees of freedom, percentile, or strength.
Assumptions and Limits
- Samples should be representative of the population being studied.
- Normality or independence assumptions apply only where the selected method requires them.
- Rounded results may differ slightly from spreadsheet software.
Frequently Asked Questions
Linear regression finds the best-fit straight line through a set of data points, described by y = mx + b. It minimises the sum of squared differences between observed Y values and the predicted values on the line.
The slope (m) represents how much Y changes for a one-unit increase in X. A slope of 2 means every time X goes up by 1, Y is expected to go up by 2.
R² (coefficient of determination) is the proportion of variance in Y explained by X. R²=0.8 means 80% of the variation in Y is captured by the linear model. R²=1 is a perfect fit.
Substitute your X value into the equation y = mx + b. For reliable predictions, stay within the range of your original data (interpolation). Predictions beyond your data range (extrapolation) are less reliable.
Real-World Applications
Common Mistakes
R² Interpretation Quick Reference
| R² Value | Interpretation | Typical Context |
|---|---|---|
| 0.0 – 0.2 | Very weak / no linear relationship | Complex social science data |
| 0.2 – 0.4 | Weak relationship | Behavioural / economic data |
| 0.4 – 0.7 | Moderate relationship | Many real-world business problems |
| 0.7 – 0.9 | Strong relationship | Engineering, physical sciences |
| 0.9 – 1.0 | Very strong / near-perfect fit | Calibration curves, physical laws |
References
- Galton, F. "Regression Towards Mediocrity in Hereditary Stature." Journal of the Anthropological Institute, 1886.
- Montgomery, D.C. et al. Introduction to Linear Regression Analysis. Wiley, 2012.
- James, G. et al. An Introduction to Statistical Learning. Springer, 2021.
- Draper, N. and Smith, H. Applied Regression Analysis. Wiley, 1998.
- Freedman, D., Pisani, R. and Purves, R. Statistics. W.W. Norton, 2007.
Related Calculators
Browse all Statistics calculators →Correlation Calculator
Calculate Pearson correlation coefficient between two variables.
Standard Deviation Calculator
Calculate mean, variance, and standard deviation for any data set.
Mean Calculator
Calculate arithmetic mean, geometric mean, and harmonic mean for any data set.