Skip to content
Calculator Collection

Linear Regression Slope Calculator

Calculate the slope of a least-squares linear regression line from summary statistics of paired x and y data. The slope tells you how much y changes per unit change in x — central to forecasting, regression analysis, and any task that quantifies a linear relationship between two variables.

Last updated: May 2026

Fill in the required fields to see your result.

Compare with similar

About this calculator

The least-squares regression slope is computed from summary statistics: b = (n · Σxy − Σx · Σy) / (n · Σx² − (Σx)²), where n is the number of (x, y) pairs, Σxy is the sum of products of paired observations, Σx is the sum of x values, Σy is the sum of y values, and Σx² is the sum of squared x values. The numerator is proportional to the covariance of x and y; the denominator is proportional to the variance of x. The slope minimises the sum of squared residuals — the total squared vertical distance between observed y values and the fitted line. Variables: b is the slope (rise per unit run), positive when y increases with x and negative when it decreases. The slope has units of y per unit x. Edge cases: if all x values are identical, the denominator becomes zero and the slope is undefined (no x variation means no way to estimate a relationship). If x and y have no linear relationship, the slope can still be computed but is close to zero — always check the correlation coefficient r or coefficient of determination r² before interpreting. The least-squares slope is sensitive to outliers because deviations are squared; one extreme point can swing the line substantially. For robust regression in the presence of outliers, use Theil-Sen estimators or RANSAC instead.

How to use

Example 1 — Hours studied vs exam score. Five students: hours = (1, 2, 3, 4, 5), score = (50, 60, 70, 80, 90). n = 5, Σx = 1+2+3+4+5 = 15, Σy = 50+60+70+80+90 = 350, Σxy = 1·50 + 2·60 + 3·70 + 4·80 + 5·90 = 50+120+210+320+450 = 1150, Σx² = 1+4+9+16+25 = 55. b = (5·1150 − 15·350) / (5·55 − 15²) = (5750 − 5250) / (275 − 225) = 500/50 = 10. ✓ Each additional hour of study is associated with a 10-point higher exam score — a perfectly linear relationship in this textbook example. Example 2 — Years of experience vs salary. Four employees: years = (1, 3, 5, 7), salary in $k = (40, 50, 65, 80). n = 4, Σx = 16, Σy = 235, Σxy = 1·40 + 3·50 + 5·65 + 7·80 = 40+150+325+560 = 1075, Σx² = 1+9+25+49 = 84. b = (4·1075 − 16·235) / (4·84 − 16²) = (4300 − 3760) / (336 − 256) = 540/80 = 6.75. ✓ Each additional year of experience is associated with a $6,750 higher salary. Combined with the intercept (a = ȳ − b·x̄ = 235/4 − 6.75·16/4 = 58.75 − 27 = 31.75), the full regression line is salary($k) = 31.75 + 6.75·years.

Frequently asked questions

What does the regression slope actually mean?

The slope is the expected change in y for each one-unit increase in x, based on the best-fitting straight line through the data. If you fit y = a + b·x to your data and get b = 10, then on average y goes up by 10 units when x increases by 1 unit. The slope is a population-level summary, not a deterministic prediction: individual observations vary around the line by the residual variance. Slope has units of y per unit x — for salary versus years of experience, that’s $/year; for height versus age, cm/year; for energy versus time, watts. The slope alone doesn’t tell you how well the line fits the data; for that you need r² (coefficient of determination), which gives the fraction of variance in y explained by x. A perfect line has r² = 1; uncorrelated data has r² close to 0.

How is the regression slope related to the correlation coefficient?

Slope and correlation coefficient r are tightly linked: b = r × (sᵧ / sₓ), where sᵧ and sₓ are the standard deviations of y and x. The correlation r is dimensionless and bounded between −1 and +1, while slope b has units and can take any value. If r = 0 then b = 0 (no linear relationship), and the sign of r matches the sign of b. The correlation summarises strength and direction of the linear relationship; the slope summarises the rate of change. r² = b² · (sₓ²/sᵧ²) gives the fraction of variance in y explained by x — for a regression with slope 10 on data with sₓ = 1 and sᵧ = 11, r² = 100/121 ≈ 0.83, meaning about 83% of the variation in y is explained by x. Always report both slope (for interpretation) and r² (for fit quality).

What does it mean if the regression slope is zero?

A slope of zero means y does not change linearly with x — the best-fitting line is horizontal. This usually indicates one of three things: (1) x and y are genuinely unrelated; (2) there is a non-linear relationship (parabolic, exponential, periodic) that a linear model cannot capture — always plot the data to check; (3) there is a relationship but you are missing a moderator variable that breaks the pattern within subgroups (Simpson’s paradox). Statistical tests on the slope (t-tests or F-tests) can tell you whether the observed slope is significantly different from zero given your sample size. With small samples even a real linear relationship can fail to clear the significance threshold; with huge samples even a trivially small slope will be ‘statistically significant’. Pair the slope with an effect-size measure (r or r²) and a visualisation to interpret it honestly.

What are the most common mistakes people make with regression slopes?

The first is interpreting slope as causation — a slope of 10 says y increases by 10 units per unit x in the observed data, not that increasing x causes y to rise. Confounders, reverse causation, and selection bias all produce strong slopes without any causal link. The second is extrapolating outside the observed range of x; a slope estimated for x between 1 and 5 may not apply when x = 100. The third is ignoring outliers, which can flip the sign or magnitude of the slope dramatically — always inspect a scatter plot before trusting the number. The fourth is fitting a linear model to non-linear data; a parabolic relationship can produce a near-zero slope while showing strong curvature. The fifth is reporting slope without standard error or confidence interval, hiding the uncertainty in the estimate. The sixth is fitting a regression on summary statistics computed from grouped data when the underlying within-group relationship is different — Simpson’s paradox can reverse the apparent direction of the slope.

When should I not use this calculator?

Skip it for non-linear relationships — if your data shows curvature, use polynomial regression, log-transformations, or non-linear models. Avoid it for small samples (n < 5) where the slope estimate is highly unstable and confidence intervals are wide. It is the wrong tool when assumptions of ordinary least squares are violated: heteroscedastic residuals (variance changes with x), autocorrelated residuals (time series), or non-normal errors with heavy tails — these require weighted least squares, ARIMA, or robust regression. Do not use it for categorical predictors without dummy-coding them properly first. Skip it for high-dimensional regression (many predictors), where you need multiple regression with potential regularisation (ridge, lasso). And for predictions outside the observed x range, use it with extreme caution: linear extrapolation can be wildly wrong far from the data.

Sources & references