Tutorials › Introduction to Statistics › Why a Regression Line Need Not Pass Through the Origin

Least-Squares Regression Lines · Tutorial 271 of 996

Why a Regression Line Need Not Pass Through the Origin

See how allowing an intercept changes a least-squares fit, and when it may be reasonable to require the fitted line to pass through the origin.

Beginner 10 min read

What You'll Learn

  • Explain why ordinary least squares estimates an intercept rather than fixing it at zero.
  • Calculate the slope and intercept for an ordinary least-squares line.
  • Calculate the slope for a line constrained to pass through the origin.
  • Compare fitted values and sums of squared errors for the two approaches.
  • Assess whether a zero-intercept constraint has a meaningful interpretation in context.

Why the Origin Is a Special Choice

A regression line summarizes how a quantitative response \(y\) changes with a quantitative predictor \(x\). The ordinary least-squares line has the form \(\hat{y}=b_0+b_1x\): it estimates both an intercept \(b_0\) and a slope \(b_1\). A line forced through the origin instead has the form \(\hat{y}=b_1x\), so its intercept is fixed at zero.

That constraint may look like a harmless simplification. But it makes a substantive claim: when \(x=0\), the fitted response must be zero. This is appropriate only when that claim makes sense for the situation and the way the variables are measured. A response can still be positive at \(x=0\), for example, if there is a fixed starting amount, fee, or baseline.

Definition: The ordinary least-squares line is the line \(\hat{y}=b_0+b_1x\) that minimizes the sum of squared vertical differences between observed responses and fitted responses. A zero-intercept fit is a line \(\hat{y}=b_1x\) chosen to minimize that same sum, but with the additional restriction \(b_0=0\).

For paired observations \((x_i,y_i)\), the ordinary least-squares line minimizes \(\sum_{i=1}^{n}(y_i-b_0-b_1x_i)^2\) over choices of both coefficients. The zero-intercept line minimizes \(\sum_{i=1}^{n}(y_i-b_1x_i)^2\) over choices of slope alone. These definitions describe how the coefficients are calculated; they do not by themselves establish that a linear model is a good description of a broader population.

To calculate either fit, the data must consist of paired quantitative measurements, with \(x\) treated as the predictor and \(y\) as the response. Least squares selects coefficients to minimize squared response errors. No probability model is needed just to perform this calculation. If the goal is statistical inference beyond the observed data, additional assumptions would be needed.

How the Two Fits Are Calculated

For the ordinary line, the slope is based on how \(x\) and \(y\) vary together around their sample means, and the intercept is then chosen so the fitted line is positioned appropriately. Using the course notation, the formulas are:

$$ b_1=\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})} {\sum_{i=1}^{n}(x_i-\bar{x})^2}, \qquad b_0=\bar{y}-b_1\bar{x}. $$

The zero-intercept slope uses a different calculation because it must fit the data without shifting the line up or down:

$$ b_1=\frac{\sum_{i=1}^{n}x_i y_i}{\sum_{i=1}^{n}x_i^2}. $$

The slopes need not be equal. The ordinary fit estimates a baseline response as well as a rate of change; the zero-intercept fit cannot estimate a baseline separately, so its slope must account for any systematic offset in the observed responses.

Why Ordinary Least Squares Estimates an Intercept

A short minimization argument shows why the ordinary fit does not generally put its intercept at zero. For a fixed slope \(b_1\), the sum of squared errors is \(S(b_0)=\sum_{i=1}^{n}(y_i-b_0-b_1x_i)^2\). Its derivative with respect to \(b_0\) is \(-2\sum_{i=1}^{n}(y_i-b_0-b_1x_i)\). At the minimizing intercept, this derivative is zero, so the residuals sum to zero:

$$ \sum_{i=1}^{n}(y_i-b_0-b_1x_i)=0 \quad\Longrightarrow\quad b_0=\bar{y}-b_1\bar{x}. $$

Thus the intercept is selected to suit the observed data rather than assumed in advance. It equals zero only when the fitted slope and the sample means happen to satisfy \(\bar{y}=b_1\bar{x}\). If theory or measurement justifies requiring the line through \((0,0)\), that is a different, constrained fitting problem—not the default ordinary least-squares problem.

Worked Example: A Fixed Setup Fee

Suppose, hypothetically, a service charges a fixed setup fee of $5 plus $2 per item processed. For three jobs, the observed numbers of items \(x\) and total charges \(y\) are \((1,7)\), \((2,9)\), and \((3,11)\). Find and compare the ordinary fit and the zero-intercept fit. Here, \(x\) is measured in items and \(y\) in dollars.

Ordinary fit. The sample means are \(\bar{x}=2\) items and \(\bar{y}=9\) dollars. The slope is

$$ b_1= \frac{(-1)(-2)+(0)(0)+(1)(2)} {(-1)^2+0^2+1^2} =\frac{4}{2}=2\text{ dollars per item}. $$

The intercept is \(b_0=9-(2)(2)=5\) dollars. The fitted equation is \(\hat{y}=5+2x\). It predicts charges of $7, $9, and $11 for these three jobs, exactly matching the hypothetical observations.

Zero-intercept fit. Its slope is

$$ b_1=\frac{(1)(7)+(2)(9)+(3)(11)}{1^2+2^2+3^2} =\frac{58}{14}\approx4.143\text{ dollars per item}. $$

The constrained equation is \(\hat{y}=4.143x\). Its predictions at \(x=1,2,3\) are approximately $4.143, $8.286, and $12.429. The sum of squared errors is

$$ (7-4.143)^2+(9-8.286)^2+(11-12.429)^2 \approx10.714\text{ dollars}^2. $$

The ordinary fit captures the setup fee in its intercept, leaving the slope to represent the per-item charge. The constrained fit cannot represent a $5 charge at zero items, so it tilts the line to compromise across the observations. Since zero items would still incur the setup fee in this scenario, forcing the fitted charge to be zero at \(x=0\) is not appropriate.

Comparing the Fits on the Same Data

The following example shows that even when the response increases with the predictor, the two choices can produce different predictions. It also makes clear that ordinary least squares minimizes the total squared errors for the data used to fit the line.

Worked Example: Comparing Two Fitted Equations

Consider hypothetical paired measurements of study time \(x\), in hours, and quiz score \(y\), in points: \((1,4)\), \((2,5)\), \((3,7)\), and \((4,8)\). Calculate both lines and compare their predictions at 4 hours.

The means are \(\bar{x}=2.5\) hours and \(\bar{y}=6\) points. For the ordinary fit, the centered cross-products sum to 7 and the squared \(x\)-deviations sum to 5. Therefore,

$$ b_1=\frac{7}{5}=1.4\text{ points per hour}, \qquad b_0=6-(1.4)(2.5)=2.5\text{ points}. $$

The ordinary fitted equation is \(\hat{y}=2.5+1.4x\). At 4 hours, it predicts \(2.5+(1.4)(4)=8.1\) points. At the four observed \(x\)-values, its fitted values are 3.9, 5.3, 6.7, and 8.1 points. The corresponding observed-minus-fitted differences are \(0.1,-0.3,0.3,-0.1\) points, giving a sum of squared errors of \(0.01+0.09+0.09+0.01=0.20\) points squared.

For the zero-intercept fit, \(\sum x_i y_i=67\) and \(\sum x_i^2=30\), so

$$ b_1=\frac{67}{30}\approx2.233\text{ points per hour}. $$

This equation predicts \(2.233(4)\approx8.933\) points at 4 hours. Its fitted values at \(x=1,2,3,4\) are about 2.233, 4.467, 6.700, and 8.933 points. The squared errors sum to approximately

$$ (4-2.233)^2+(5-4.467)^2+(7-6.700)^2+(8-8.933)^2 \approx4.367\text{ points}^2. $$

For these observed data, the ordinary line has the smaller sum of squared errors. But the calculation alone does not show whether study time has a causal effect on quiz scores, or whether a score of zero at zero study hours is scientifically impossible. Those are questions about context and study design, not just the fitting arithmetic.

When a Zero Intercept Can Make Sense

A zero-intercept fit can be reasonable when there is a strong substantive or measurement-based reason for the response to be zero whenever the predictor is zero. For example, a hypothetical sensor calibrated to measure added mass might be expected to report zero added mass when no mass is applied. Even then, the exact relationship might be affected by measurement error or other features of the instrument. The constraint should be justified, not adopted merely because a line looks simpler without an intercept.

Worked Example: A Calibration That Is Near the Origin

Suppose a hypothetical instrument is tested at four applied masses \(x\), in kilograms, and gives readings \(y\), in units: \((0,0)\), \((1,2.1)\), \((2,3.9)\), and \((3,6.2)\). Compare the two fits. The zero reading at zero applied mass makes a zero-intercept constraint plausible in this setup, though it does not by itself prove that the constraint is correct for all measurements.

For the ordinary fit, \(\bar{x}=1.5\) kilograms and \(\bar{y}=3.05\) units. The centered cross-products sum to 10.2 and the squared \(x\)-deviations sum to 5. Thus,

$$ b_1=\frac{10.2}{5}=2.04\text{ units per kilogram}, \qquad b_0=3.05-(2.04)(1.5)=-0.01\text{ units}. $$

The ordinary equation is \(\hat{y}=-0.01+2.04x\). Its fitted values are \(-0.01,2.03,4.07,6.11\) units, giving squared errors that sum to \(0.0420\) units squared.

For the constrained fit, \(\sum x_i y_i=28.5\) and \(\sum x_i^2=14\), so \(b_1=28.5/14\approx2.036\) units per kilogram. Its fitted values are approximately \(0,2.036,4.071,6.107\) units, and its squared errors sum to approximately \(0.04214\) units squared. The two fits are very similar here, in part because the ordinary intercept is close to zero. This is a comparison for these four observations, not proof that the intercept is exactly zero in a larger measurement process.

The intercept is the line's predicted response at \(x=0\). That interpretation may be useful even if zero is outside the observed predictor range, but a prediction there may then be an extrapolation rather than a prediction supported by nearby data. The earlier material on extrapolation explains why predictions beyond the observed range require particular caution.

What Least Squares Guarantees—and What It Does Not

The ordinary model includes every line available to the zero-intercept model: setting \(b_0=0\) in the ordinary equation produces a zero-intercept line. Therefore, the minimum possible sum of squared errors for the ordinary fit cannot be greater than the minimum for the constrained fit:

$$ \min_{b_0,b_1}\sum_{i=1}^{n}(y_i-b_0-b_1x_i)^2 \leq \min_{b_1}\sum_{i=1}^{n}(y_i-b_1x_i)^2. $$

This is a mathematical guarantee about the fitting data and the squared-error criterion. It does not mean the ordinary fit must be the better scientific model in every situation. A justified zero-intercept constraint may reflect known measurement or physical structure; and a smaller fitting error alone does not establish that one line will predict new observations more accurately. Nor does least squares guarantee that every individual prediction from the ordinary line is closer to its observed response than the corresponding prediction from the constrained line.

Common Mistake

Common mistake: “The predictor is measured from zero, so the regression line should go through the origin.” A zero point on the predictor scale does not force the response to be zero there. The correction is to ask what \(y\) means when \(x=0\), and whether the context gives a defensible reason to impose \(\hat{y}=0\). If the response can have a baseline or fixed component, estimate the intercept unless there is a clear reason to constrain it.

A related error is to treat the ordinary intercept as proof that the response truly has that value at zero predictor. The intercept is a fitted value implied by the chosen line. If zero is far from the observed \(x\)-values, its contextual interpretation may depend on extrapolation.

Key takeaway: Ordinary least squares estimates both intercept and slope because that choice minimizes squared errors over the full set of lines. A zero-intercept fit is a constrained alternative that should be used when the response is meaningfully expected to be zero at a zero predictor—not simply because the origin seems convenient.

Check Your Understanding

Use the definitions and comparisons in this tutorial to answer the following questions.

  1. In a model of total delivery cost \(y\) versus distance \(x\), what does a zero-intercept constraint claim about the predicted cost at zero distance?
  2. For a zero-intercept least-squares fit, the data have \(\sum x_i y_i=48\) and \(\sum x_i^2=16\). What is the fitted slope, including its calculation?
  3. Why can the ordinary least-squares slope differ from the slope of a zero-intercept fit?
  4. Is the ordinary fit's sum of squared errors guaranteed to be less than or equal to the zero-intercept fit's sum for the fitting data? Explain using the sets of lines each fit considers.
  5. A fitted ordinary line has a nonzero intercept. Does that alone prove the true response at \(x=0\) is nonzero? Explain the distinction.