Why do the residuals of an OLS model with an intercept always sum to zero?

Quick Overview

Asks why the residuals of an ordinary least squares fit with an intercept always add up to zero. Tests whether you can derive the property from the normal equations, explain what follows from it, and say when it stops holding.

Why do the residuals of an OLS model with an intercept always sum to zero?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why do the residuals of an OLS model with an intercept always sum to zero? ```hint Differentiate with respect to the intercept Write the sum of squared residuals and set its derivative with respect to the intercept to zero. Read what that equation says about the residuals. ``` ```hint Matrix view In matrix form, the normal equations state a condition on every column of the design matrix and the residual vector. Look at which column belongs to the intercept. ``` ### What a Strong Answer Covers - The first-order condition for the intercept and what it implies for the residuals - The matrix form of the normal equations and the role of the column of ones - At least one consequence of the property for the fitted model - The conditions under which the property fails, and a case where it holds without an explicit intercept column ### Follow-up Questions - A model has no intercept but includes a dummy column for every level of a categorical feature. Do the residuals sum to zero? - Why does the usual $R^2$ break down for a regression through the origin? - Does a similar property hold for logistic regression with an intercept? What sums to zero there? - What is the analogous condition in weighted least squares?

Overview: Asks why the residuals of an ordinary least squares fit with an intercept always add up to zero. Tests whether you can derive the property from the normal equations, explain what follows from it, and say when it stops holding.

Nov 25, 2026
mediumData ScientistOtherMachine Learning
0
0

Why do the residuals of an OLS model with an intercept always sum to zero?

What a Strong Answer Covers Guidance

  • The first-order condition for the intercept and what it implies for the residuals
  • The matrix form of the normal equations and the role of the column of ones
  • At least one consequence of the property for the fitted model
  • The conditions under which the property fails, and a case where it holds without an explicit intercept column

Follow-up Questions Guidance

  • A model has no intercept but includes a dummy column for every level of a categorical feature. Do the residuals sum to zero?
  • Why does the usual R2R^2 break down for a regression through the origin?
  • Does a similar property hold for logistic regression with an intercept? What sums to zero there?
  • What is the analogous condition in weighted least squares?