<p>When an intercept is included, sum of residuals in multiple regression equals 0.</p>

<p>In multiple regression, 
<span class="math-container">$$
\hat{y}_i = \beta_0 + \beta_1x_{i,1} + \beta_2x_{i,2} +…+ \beta_px_{i,p}
$$</span>
In Least squares regression, the sum of the squares of the errors is minimized.
<span class="math-container">$$
SSE=\displaystyle\sum\limits_{i=1}^n \left(e_i \right)^2= \sum_{i=1}^n\left(y_i - \hat{y_i} \right)^2= \sum_{i=1}^n\left(y_i -\beta_0- \beta_1x_{i,1}-\beta_2x_{i,2}-…- \beta_px_{i,p} \right)^2
$$</span>
Take the partial derivative of SSE with respect to <span class="math-container">$\beta_0$</span> and setting it to zero.
<span class="math-container">$$
\frac{\partial{SSE}}{\partial{\beta_0}} = \sum_{i=1}^n 2\left(y_i -\beta_0- \beta_1x_{i,1}-\beta_2x_{i,2}-…- \beta_px_{i,p} \right)^1 (-1) = -2\displaystyle\sum\limits_{i=1}^n(y_i-\hat{y_i})=-2\displaystyle\sum\limits_{i=1}^ne_i=0
$$</span>
Hence, when an intercept is included, sum of residuals in multiple regression equals 0.</p>

CC BY-SA 4.0
2019-04-07T00:20:09.943Z
2019-04-07T00:31:58.857Z
2019-04-07T00:31:58.857Z
RobinCruise
<p>Completing the notation with the indices
<span class="math-container">$$
\forall j: \sum_{i=1}^{n} X_{i,j}\hat{u}_{i} = 0.
$$</span>
As you say, if <span class="math-container">$X_0$</span> is the constant then
<span class="math-container">$$
\forall i: X_{i,0} = 1.
$$</span>
Inputing <span class="math-container">$j = 0$</span> into the first equation
<span class="math-container">$$
\begin{align*}
\sum_{i=1}^{n} X_{i,0}\hat{u}_{i} &amp; = 0 \\
\\
\sum_{i=1}^{n} 1\hat{u}_{i} &amp; = 0 \\
\\
\sum_{i=1}^{n} \hat{u}_{i} &amp; = 0.
\end{align*}
$$</span></p>

CC BY-SA 4.0
2019-03-17T17:08:45.760Z
2019-03-17T17:08:45.760Z
Giskard
<p>I understand that in multiple regression 
<span class="math-container">$$\sum_{}^{} X_{i,j}\hat{u}_{i} = 0 $$</span>
 but I do not understand how my textbook says that if we include the intercept in the regression (<span class="math-container">$X_{i,0} = 1$</span>)then we get:
<span class="math-container">$$\sum_{}^{} \hat{u}_{i} = 0$$</span></p>

<econometrics><statistics>
Sum of residuals in multiple regression equals 0
Martin 
# Sum of residuals in multiple regression equals 0

(Asked by: username_0 on 2019-03-17)

I understand that in multiple regression
$$\sum\_{}^{} X\_{i,j}\hat{u}\_{i} = 0 $$
but I do not understand how my textbook says that if we include the intercept in the regression ($X\_{i,0} = 1$)then we get:
$$\sum\_{}^{} \hat{u}\_{i} = 0$$

**Tags:** econometrics, statistics

---

## 2 answers

### Answer by username_2 on 2019-03-17. Score: 3 | Accepted answer

Completing the notation with the indices
$$
\forall j: \sum\_{i=1}^{n} X\_{i,j}\hat{u}\_{i} = 0.
$$
As you say, if $X\_0$ is the constant then
$$
\forall i: X\_{i,0} = 1.
$$
Inputing $j = 0$ into the first equation
$$
\begin{align\*}
\sum\_{i=1}^{n} X\_{i,0}\hat{u}\_{i} & = 0 \\
\\
\sum\_{i=1}^{n} 1\hat{u}\_{i} & = 0 \\
\\
\sum\_{i=1}^{n} \hat{u}\_{i} & = 0.
\end{align\*}
$$


---

### Answer by username_1 on 2019-04-07. Score: 1

When an intercept is included, sum of residuals in multiple regression equals 0.

In multiple regression,
$$
\hat{y}\_i = \beta\_0 + \beta\_1x\_{i,1} + \beta\_2x\_{i,2} +…+ \beta\_px\_{i,p}
$$
In Least squares regression, the sum of the squares of the errors is minimized.
$$
SSE=\displaystyle\sum\limits\_{i=1}^n \left(e\_i \right)^2= \sum\_{i=1}^n\left(y\_i - \hat{y\_i} \right)^2= \sum\_{i=1}^n\left(y\_i -\beta\_0- \beta\_1x\_{i,1}-\beta\_2x\_{i,2}-…- \beta\_px\_{i,p} \right)^2
$$
Take the partial derivative of SSE with respect to $\beta\_0$ and setting it to zero.
$$
\frac{\partial{SSE}}{\partial{\beta\_0}} = \sum\_{i=1}^n 2\left(y\_i -\beta\_0- \beta\_1x\_{i,1}-\beta\_2x\_{i,2}-…- \beta\_px\_{i,p} \right)^1 (-1) = -2\displaystyle\sum\limits\_{i=1}^n(y\_i-\hat{y\_i})=-2\displaystyle\sum\limits\_{i=1}^ne\_i=0
$$
Hence, when an intercept is included, sum of residuals in multiple regression equals 0.


---

