# Find the OLS estimator $β_1$ when a new variable is added to the regression

Suppose $y_t = \beta x_t + u_t$, where $t = 1, 2, ..., n$. We know, in this case, the OLS estimator is $\hat{\beta} = ∑x_t y_t /∑x_t^2$.

Now suppose one more observation $x_{n+1}$ is added. At the same time, a dummy variable is also added into the model, where $d_t = 0$ when $t = 1, 2, \ldots, n$ and $d_t = 1$ when $t = n + 1$. In other words, the new regression is $$y_t = \beta_1 x_t + \beta_2 d_t + e_t,$$ where $t = 1, 2, ..., n + 1$. Find the OLS estimator of $\beta_1$.

I have tried writing out functions using summations of $x_1$, $x_2$ and $y$ but nothing looks right. Any help would be appreciated.

Writing out the equations:

$$\begin{cases} \beta_1x_1=y_1\\ \beta_1x_2=y_2\\ ...\\ \beta_1 x_{n+1}+\beta_2=y_{n+1}\end{cases}$$

This gives you a matrix equation to solve:

$$\begin{bmatrix} x_1&0\\ x_2&0\\ ...&...\\ x_n&0\\ x_{n+1}&1\end{bmatrix} \begin{bmatrix} \beta_1\\ \beta_2\end{bmatrix}= \begin{bmatrix}y_1\\ y_2\\ ...\\ y_{n+1}\end{bmatrix}$$

Multiply by $X^T$ on both sides gives

$$\begin{bmatrix} \sum^{n+1}_{i=1}x_i^2 & x_{n+1}\\ x_{n+1}&1\end{bmatrix} \begin{bmatrix} \beta_1\\ \beta_2\end{bmatrix}= \begin{bmatrix}\sum^{n+1}_{i=1}x_iy_i\\ y_{n+1}\end{bmatrix}$$

Solve this system of equation (for example, using Crammer's rule):

$$\beta_1=\frac{\sum^n_{i=1}x_iy_i}{\sum^n_{i=1}x^2_i}$$ $$\beta_2=\frac{\sum^{n+1}_{i=1}x^2_i y_{n+1}-\sum^{n+1}_{i=1}x_i y_i x_{n+1}}{\sum^n_{i=1}x^2_i}$$

Notice that in three of the final summations the upper limits are $n$, not $n+1$. Those were not typos.