01
How to use the regression calculator
- Paste the predictor values in the X box and the outcome values in the Y box, in the same order.
- Read the equation and R². They update as you type.
- Enter an X value to get the predicted Y.
- Check the plot, and open “Predicted values and residuals”: the residuals (observed minus predicted) should scatter around zero with no pattern.
02
Linear regression formulas
slope b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
intercept a = ȳ − b × x̄
line: y = a + b × x
The slope is the change in Y for a one-unit increase in X. The intercept is the predicted Y when X is zero, which may or may not be a meaningful point for your data.
residual SD s = √( Σ(y − ŷ)² ÷ (n − 2) )
SE(b) = s ÷ √Σ(x − x̄)², t = b ÷ SE(b) on n − 2 degrees of freedom
03
Worked example
The calculator opens with X = 1, 2, 3, 4, 5 and Y = 2, 4, 5, 4, 5 (means 3 and 4).
b = 6 ÷ 10 = 0.6, a = 4 − 0.6 × 3 = 2.2, so y = 2.2 + 0.6x
| Quantity | Value |
|---|---|
| R² | 0.60 |
| Residual SD | 0.894 |
| SE of the slope | 0.283 |
| 95% CI of the slope | −0.30 to 1.50 |
| t (3 df), p | 2.12, p = .124 |
| Predicted Y at X = 6 | 5.8 (95% CI of the mean 2.81 to 8.79) |
The slope’s interval includes zero: five points are not enough to show a trend, even with R² = 0.60.
04
What R² means
R² is the share of the variation in Y that the line accounts for, from 0 to 1. With one predictor it equals the square of Pearson’s correlation (see the correlation coefficient calculator). A high R² does not show that the relationship is linear or causal, and a low R² can still go with a slope that is clearly not zero in a large sample.
05
Predictions and their limits
- The interval shown is for the mean Y at that X. A single new observation varies more: its prediction interval is wider.
- Predicting outside the range of your X values (extrapolation) assumes the line continues unchanged. The calculator warns when you do it.
- The intervals are narrowest at the mean of X and widen toward the ends.
06
Assumptions to check on the plot
- Linearity: the points follow a straight band, not a curve.
- Constant spread: the scatter around the line is similar along its length, not a funnel.
- Independence: each point is a separate observation, not repeated measurements of a few subjects.
- No dominant outlier: one extreme point can set the slope almost by itself.
07
Common mistakes in simple regression
- Swapping X and Y. Regressing X on Y in the worked example gives a slope of 1.0; turned round, that is not the 0.6 you get from Y on X. Put the variable you want to predict on the Y axis.
- Letting one point set the line. Adding a single point at (10, 20) to the example moves the slope from 0.6 to 1.95 and R² from 0.60 to 0.88.
- Quoting the interval for the mean as the range for one new value. At X = 6 the mean’s 95% CI is 2.81 to 8.79, but a single new observation should fall between 1.68 and 9.92.
- Extrapolating. At X = 20, far outside 1 to 5, the line predicts 14.2 with a 95% CI of −1.16 to 29.6.
Trust
How this page is checked
- The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
- The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
- Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.
Cite this page
Sciloom. (2026). Linear regression calculator. Zebra Nine Studio Inc. https://sciloom.si/linear-regression-calculator
Frequently asked questions
How do I find the equation of the regression line?
Paste your X and Y values. The calculator computes the least-squares slope and intercept and writes the equation as y = a + bx.
What is the difference between regression and correlation?
Correlation measures how strongly two variables move together, as one number. Regression describes the line itself, so you can predict Y from X. With one predictor they give the same p value.
What does the p value of the slope mean?
It tests whether the true slope is zero. A small p value means the data show a linear trend that chance alone would rarely produce.
How many data points do I need?
At least three to fit a line and estimate its error, but estimates from fewer than about ten points are very imprecise, as the wide confidence interval will show.