Regression Calculator
Fit a simple linear regression line y = a + bx.
How simple linear regression works
Simple linear regression fits a straight line y = a + bx through paired data by the method of least squares, minimising the sum of squared vertical distances from the points to the line.
The slope b is the change in y for a one-unit change in x. The intercept a is the value of y when x is zero. R² is the proportion of the variation in y explained by x.
This is a simple linear regression with one predictor. It does not fit multivariate models, non-linear relationships, or extrapolate reliably beyond the range of your data.
The formulas
b = Σ((x−x̄)(y−ȳ)) ÷ Σ((x−x̄)²) · a = ȳ − b·x̄ · R² = r²
The slope is the covariance of x and y divided by the variance of x. The intercept places the line through the means. R² is the square of the Pearson correlation and ranges from 0 to 1.
Worked example
X = 1,2,3 and Y = 3,5,7
The points lie on y = 1 + 2x, so the slope is 2, the intercept is 1, r = 1 and R² = 1 — a perfect fit.
Frequently asked questions
What does R² tell me?
R² is the proportion of variance in y explained by x. R² = 0.9 means 90% of the variation is explained by the model; the rest is due to other factors or noise.
Can I use this for non-linear data?
The model always fits a straight line. If the relationship is curved, a straight line may fit poorly even with a moderate R² — consider transforming the variables or a different model.
Can I predict outside my data range?
Extrapolation beyond the observed range of x assumes the relationship continues unchanged, which is often unsafe. Interpret such predictions with caution.
Related tools
Related guides
- How to Choose the Right Statistical TestA practical framework for picking the right statistical test: start from your research question, data type and study design, then check the assumptions.
- Correlation vs RegressionThe difference between measuring a linear association (correlation) and modelling a relationship to make predictions (regression), and how R² connects them.
Built by PanelRoster
PanelRoster is an enterprise operations management platform for organizations coordinating distributed teams, assignments, workflows, quality assurance and operational execution.
Explore PanelRoster