Tutorials › Introduction to Statistics › Calculating the Intercept from the Sample Means

Least-Squares Regression Lines · Tutorial 259 of 996

Calculating the Intercept from the Sample Means

Use the slope and the two sample means to calculate the intercept and write a fitted regression equation in context.

Beginner 9 min read

What You'll Learn

  • Use the sample means and slope to calculate the least-squares intercept.
  • Write the fitted regression equation in the form response equals intercept plus slope times explanatory variable.
  • Keep the slope and intercept units consistent with the variables.
  • Check the calculation by substituting the sample means into the fitted equation.
  • Distinguish the calculation of an intercept from whether its contextual interpretation is useful.

From Slope to a Complete Fitted Equation

A regression slope describes how a fitted response changes with the explanatory variable, but a slope alone does not determine the location of the fitted line. To write the full equation, we also need its intercept. If the slope and the sample means of the two variables are known, the intercept can be calculated directly.

Throughout this tutorial, \(x\) denotes a value of the explanatory variable and \(y\) a value of the response variable. Their sample means are \(\bar{x}\) and \(\bar{y}\). The fitted response is written \(\hat{y}\), the fitted slope is \(b_1\), and the fitted intercept is \(b_0\). The fitted equation is \(\hat{y}=b_0+b_1x\).

Definition: In the least-squares regression equation \(\hat{y}=b_0+b_1x\), the intercept \(b_0\) is the fitted response when \(x=0\). For a least-squares line based on paired observations, the intercept is calculated from the slope and sample means as \(b_0=\bar{y}-b_1\bar{x}\).

The calculation uses the mean of the response minus the slope multiplied by the mean of the explanatory variable. Keep the order of the variables straight: \(\bar{y}\) is the response mean, and \(\bar{x}\) is the explanatory-variable mean. The slope \(b_1\) must be the slope for predicting \(y\) from \(x\), not a slope from a regression in the reverse direction.

$$ b_0=\bar{y}-b_1\bar{x} \qquad\text{and therefore}\qquad \hat{y}=b_0+b_1x $$

The slope can be obtained by a method already used in regression, such as calculating it from the correlation and the sample standard deviations. For the intercept calculation itself, take the slope as an input and combine it with \(\bar{x}\) and \(\bar{y}\). All three quantities must come from the same paired data and use the same units as the intended equation.

Why the Formula Works

A standard property of a least-squares regression line is that it passes through the point formed by the two sample means, \((\bar{x},\bar{y})\). For this calculation, use that property as the starting point: when \(x=\bar{x}\), the fitted value on the line is \(\bar{y}\). Substituting those values into the equation and solving for \(b_0\) gives the formula.

$$ \begin{aligned} \bar{y} &= b_0+b_1\bar{x}\\ b_0 &= \bar{y}-b_1\bar{x} \end{aligned} $$

This is a short algebraic justification of the intercept formula. It also gives a useful check: after calculating the intercept, putting \(\bar{x}\) into the fitted equation should give \(\bar{y}\). If it does not, check the arithmetic, the placement of the variables, and the sign of the slope.

Worked Example: Exam Score and Study Time

Suppose a hypothetical sample of students has a mean study time of \(\bar{x}=5.0\) hours and a mean exam score of \(\bar{y}=68.0\) points. The least-squares slope for predicting exam score from study time is \(b_1=4.2\) points per hour. Find the intercept and write the fitted equation.

Here \(x\) is study time in hours, \(y\) is exam score in points, and the slope says that the fitted score changes by 4.2 points for each additional hour of study. Apply the intercept formula:

$$ \begin{aligned} b_0 &= \bar{y}-b_1\bar{x}\\ &=68.0\text{ points}-(4.2\text{ points/hour})(5.0\text{ hours})\\ &=68.0\text{ points}-21.0\text{ points}\\ &=47.0\text{ points}. \end{aligned} $$

The units in the product cancel correctly: points per hour multiplied by hours gives points. The fitted equation is

$$ \widehat{\text{score}}=47.0+4.2(\text{study time in hours}). $$

Check it at the sample mean study time: \(47.0+4.2(5.0)=68.0\) points, which is the sample mean score. The intercept is the fitted score at zero hours of study. That value is part of the equation, but whether it is a useful or plausible description depends on the data and context.

Sign and Units in the Calculation

The formula works for positive and negative slopes. When \(b_1\) is negative, the product \(b_1\bar{x}\) is negative, so subtracting it increases the intercept. This is ordinary signed arithmetic, not a special rule for negative slopes. Writing the subtraction explicitly before simplifying helps prevent a common sign error.

Units provide another check. The slope has units of response per unit of explanatory variable. Multiplying it by \(\bar{x}\), which has explanatory-variable units, produces response units. Since \(\bar{y}\) also has response units, their difference—and therefore the intercept—has response units. The intercept does not have the units of the explanatory variable.

Worked Example: Exercise Time and Resting Pulse

In a hypothetical sample, mean daily exercise time is \(\bar{x}=40\) minutes and mean resting pulse is \(\bar{y}=72\) beats per minute. The fitted slope for predicting resting pulse from exercise time is \(b_1=-0.18\) beats per minute per exercise minute. Calculate the intercept and write the equation.

Substitute the values, keeping the negative sign in the slope:

$$ \begin{aligned} b_0 &= \bar{y}-b_1\bar{x}\\ &=72\text{ beats/minute}-(-0.18\text{ beats/minute per exercise minute})(40\text{ exercise minutes})\\ &=72\text{ beats/minute}-(-7.2\text{ beats/minute})\\ &=79.2\text{ beats/minute}. \end{aligned} $$

The fitted equation is

$$ \widehat{\text{resting pulse}}=79.2-0.18(\text{exercise time in minutes}). $$

At the sample mean exercise time, the fitted value is \(79.2-0.18(40)=72\) beats per minute, matching \(\bar{y}\). The negative slope describes a downward fitted relationship in this sample; it does not establish that exercise caused the pulse values. Also, the intercept refers to the fitted value at zero exercise minutes, which may or may not be a useful interpretation for the population or range of data under consideration.

Calculating a Slope First, Then the Intercept

Sometimes the slope is supplied directly. In other problems, it may be calculated from the correlation and sample standard deviations using \(b_1=r(s_y/s_x)\), where \(r\) is the sample correlation, \(s_x\) is the explanatory-variable sample standard deviation, and \(s_y\) is the response-variable sample standard deviation. Once that slope is found, the intercept step is unchanged. Be sure the correlation and standard deviations refer to the same variables and sample.

Worked Example: Weekly App Use and a Vocabulary Score

For a hypothetical sample, let \(x\) be weekly minutes using a vocabulary app and \(y\) be a vocabulary test score in points. Suppose \(r=0.50\), \(s_x=12\) minutes, \(s_y=8\) points, \(\bar{x}=30\) minutes, and \(\bar{y}=74\) points. Find the slope using the correlation and standard deviations, then calculate the intercept and write the fitted equation.

First calculate the slope for predicting the score from app-use time:

$$ \begin{aligned} b_1 &= r\frac{s_y}{s_x}\\ &=0.50\left(\frac{8\text{ points}}{12\text{ minutes}}\right)\\ &=0.3333\text{ points per minute}. \end{aligned} $$

Now use this slope with the two sample means:

$$ \begin{aligned} b_0 &= \bar{y}-b_1\bar{x}\\ &=74\text{ points}-(0.3333\text{ points/minute})(30\text{ minutes})\\ &\approx74\text{ points}-10.00\text{ points}\\ &\approx64.00\text{ points}. \end{aligned} $$

The fitted equation, with the slope rounded for display, is

$$ \widehat{\text{vocabulary score}}=64.00+0.3333(\text{weekly app-use minutes}). $$

Using the unrounded slope \(0.50(8/12)=1/3\), the fitted value at \(x=30\) minutes is \(64+(\frac{1}{3})(30)=74\) points. That equals the sample mean score. The calculation also illustrates why it is sensible to keep extra digits during intermediate steps and round only when reporting the final equation.

Interpreting the Intercept Carefully

The intercept is defined mathematically as the fitted response when \(x=0\). That does not guarantee that zero is a value observed in the data, or that it is a meaningful value in the setting. If the observed explanatory-variable values are all far from zero, the intercept may describe an extrapolation beyond the data. Even when zero is within the observed range, its contextual meaning still deserves consideration.

The calculation should not be confused with a claim that the response truly equals the intercept whenever the explanatory variable is zero. It is the value predicted by the fitted line. Regression summarizes a pattern in paired data; a fitted equation does not, by itself, establish causation or guarantee accurate predictions for every individual.

A clear report gives the equation with variables and units identified, then interprets the intercept cautiously. For example, in the study-time equation, the intercept is 47.0 predicted exam points at zero study hours. That is a statement about the fitted line. Whether it is a reasonable description depends on what study times were observed and on the context of the exam.

Common Mistakes and a Reliable Workflow

The most frequent error is to swap the means or lose the sign while calculating. The response mean belongs first in the formula; the explanatory mean is multiplied by the slope. Another error is to treat the intercept as a second slope. Its units are the response units alone, whereas the slope units are response units per explanatory-variable unit.

Common mistake: A learner writes \(b_0=\bar{x}-b_1\bar{y}\), or changes a negative slope to positive before doing the subtraction. Correction: Start from \(b_0=\bar{y}-b_1\bar{x}\), preserve the sign of \(b_1\), and check that \(b_1\bar{x}\) has response units. Then substitute \(\bar{x}\) into the completed equation and verify that it gives \(\bar{y}\).

A disciplined calculation can be organized in four steps:

1
Identify the variables.
Name \(x\) as the explanatory variable and \(y\) as the response. Record \(\bar{x}\) and \(\bar{y}\) with their units.
2
Confirm the slope.
Use the slope for predicting the stated response from the stated explanatory variable. Check its sign and units.
3
Calculate the intercept.
Substitute into \(b_0=\bar{y}-b_1\bar{x}\), showing the product and signed subtraction.
4
Write and check the equation.
Put the intercept and slope into \(\hat{y}=b_0+b_1x\), label the variables, and verify that \(x=\bar{x}\) gives \(\hat{y}=\bar{y}\).

This process separates the arithmetic from the interpretation. A correctly calculated intercept completes the fitted equation; a separate contextual check determines whether the equation’s value at \(x=0\) is meaningful to discuss.

Check Your Understanding

Answer each question, showing the substitution and a brief unit check where appropriate.

  1. A fitted line predicts response \(y\) from explanatory variable \(x\). If \(\bar{x}=8\), \(\bar{y}=25\), and \(b_1=1.5\), calculate \(b_0\) and write the fitted equation.
  2. If the slope is negative, why can the intercept be greater than the response mean when the explanatory mean is positive?
  3. A slope is measured in points per hour, and \(\bar{x}\) is measured in hours. What units does \(b_1\bar{x}\) have, and what units must the intercept have?
  4. A learner calculates \(b_0=\bar{x}-b_1\bar{y}\). Identify both errors in this expression.
  5. After calculating an intercept, what equality should hold when you substitute \(\bar{x}\) into the fitted equation? Explain why this is a useful check.