Ad Space — Top Banner

Linear Regression Slope Formula

Calculate the slope and intercept of a linear regression line using the least squares method.
Predict outcomes from data relationships.

The Formulas

b = Σ(xi − x̄)(yi − ȳ) / Σ(xi − x̄)2

a = ȳ − b × x̄

The linear regression slope formula calculates the best-fitting straight line through a set of data points using the least squares method. The slope (b) tells you how much the dependent variable (y) changes for every one-unit increase in the independent variable (x). The intercept (a) tells you the predicted value of y when x equals zero.

The least squares method minimizes the sum of the squared differences between the observed y-values and the predicted y-values on the line. This ensures that the line is as close as possible to all data points, giving equal importance to points above and below the line. The method was independently developed by Adrien-Marie Legendre in 1805 in France and Carl Friedrich Gauss in 1809 in Germany.

The slope formula works by measuring how x and y vary together (the covariance in the numerator) and dividing by how much x varies on its own (the variance of x in the denominator). A positive slope means y increases as x increases. A negative slope means y decreases as x increases. A slope near zero means there is little linear relationship between the variables.

Once you have the slope, the intercept is calculated by ensuring the regression line passes through the point (x̄, ȳ) — the mean of x and the mean of y. This guarantees that the line is centered on the data. Together, the slope and intercept define the equation ŷ = a + bx, which can be used to predict y for any given x value within the range of the data.

Variables

SymbolMeaning
bSlope of the regression line
aY-intercept of the regression line
xiIndividual x data values
yiIndividual y data values
Mean (average) of all x values
ȳMean (average) of all y values

Example 1

Problem

Given the data points (1, 2), (2, 4), (3, 5), (4, 4), (5, 5), find the regression slope.

x̄ = (1+2+3+4+5)/5 = 3, ȳ = (2+4+5+4+5)/5 = 4

Σ(xi−x̄)(yi−ȳ) = (−2)(−2)+(−1)(0)+(0)(1)+(1)(0)+(2)(1) = 4+0+0+0+2 = 6

Σ(xi−x̄)2 = 4+1+0+1+4 = 10

b = 6/10 = 0.6

The slope is 0.6, meaning y increases by 0.6 for each unit increase in x. Intercept: a = 4 − 0.6(3) = 2.2. The line is ŷ = 2.2 + 0.6x.

Example 2

Problem

Hours studied (x): 1, 3, 5, 7. Exam scores (y): 50, 65, 75, 90. Find the regression equation.

x̄ = 16/4 = 4, ȳ = 280/4 = 70

Σ(xi−x̄)(yi−ȳ) = (−3)(−20)+(−1)(−5)+(1)(5)+(3)(20) = 60+5+5+60 = 130

Σ(xi−x̄)2 = 9+1+1+9 = 20

b = 130/20 = 6.5, a = 70 − 6.5(4) = 44

ŷ = 44 + 6.5x. Each additional hour of study predicts a 6.5-point increase in the exam score.

When to Use It

The least squares regression slope is fundamental for finding linear relationships in data and making predictions.

  • Predicting outcomes based on a single explanatory variable (sales from advertising spend, grades from study time)
  • Quantifying the rate of change in a relationship (how much does Y change per unit of X)
  • Establishing trend lines for time series data
  • Comparing the strength of relationships across different datasets

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.