<p>That is natural and you are not missing anything.</p>

<p>Let $y=\alpha + \beta z + u$. Your prediction of $y$ given $z=1$ is $\hat{y} = a + b$, where $a$ and $b$ are the OLS estimates. The prediction error ($y - \hat{y}$) for $z=1$ is, thus, $(\alpha - a) + (\beta-b) + u$, which is involved with $b$. On the other hand, for $z=0$, the prediction of $y$ is $a$ and the prediction error is $(\alpha-a) + u$, which has nothing to do with $b$. As you said, the former depends on $b$, while the latter does not. (Perhaps it would help to remember that the value of $z$ is given for the prediction, and thus the prediction intervals depend on the value of $z$.)</p>

<p>(Calculation of the prediction intervals:) You can calculate the prediction intervals using the formula $(a+b) \pm se((\alpha-a)+(\beta-b)+u) \cdot \textit{critical value}$ for $z=1$, and the formula $a \pm se((\alpha-a)+u) \cdot \textit{critical value}$ for $z=0$. which is fine. Note that these two prediction intervals can also be written as $(a+b) \pm se(a+b+u) \cdot cv$ and $a\pm se(a+u) \cdot cv$, respectively, because $\alpha$ and $\beta$ are constant (nonrandom). How to estimate the standard errors can be found in Wooldridge's textbook (the "Prediction and Residual Analysis" section; 6.4 in 5ed).</p>

CC BY-SA 3.0
2017-07-16T15:10:57.897Z
Thanks for your answer. The counter-intuitive part for me is that the category with $z=1$ always has the extra variance due to the variance of $b$, which means a wider prediction interval (i.e., we are less sure where a new observation falls). Thus, we are less sure about a new observation in category 1, if we code category 1 as $z=1$, and less sure about category 2 otherwise. It seems that this inference depends on how we code the dummy variable, instead of the nature of the problem. If we change the coding, we obtain different intervals, then which intervals should we use? Thanks.
Justin
CC BY-SA 3.0
2017-07-16T15:16:50.883Z
That's an interesting point, but it won't happen. If you define $w=1-z$ and regress $y$ on $w$ instead of on $z$, then $\alpha$ and $\beta$ change, $a$ and $b$ change, and the standard errors change, and in the end the prediction interval for $w=0$ is exactly the same as what you originally obtained for $z=1$. Also $a+b$ doesn't have to have a larger variance than $a$ when they are mutually (strongly negatively) correlated.
chan1142
CC BY-SA 3.0
2017-07-16T20:20:46.800Z
Thanks a lot. This answers my question. I missed the point that $a$ and $b$ in general are not independent.
Justin
CC BY-SA 3.0
2017-07-14T05:00:49.103Z
2017-07-14T05:00:49.103Z
chan1142
<p>When I analyzed a data set with two categories, I used a dummy variable $z=1$ for category 1, and 0 otherwise, and added the extra term $\beta z$ to the regression model. Suppose the least squares estimate for $\beta$ is $b$. I tried to calculate some prediction intervals for the two categories. For category 1, since $z=1$, I needed to count the variance for $b$, but for category 2, since $z=0$, I did not count this variance. It then appeared that the variance for category 1 includes an additional variance because I happened to code it as $z=1$. I am new to study econometrics. Could anyone please help with this puzzle? Am I missing anything here? </p>

<econometrics><regression>
Regression with Dummy Variables
Justin
# Regression with Dummy Variables

(Asked by: username_0 on 2017-07-13)

When I analyzed a data set with two categories, I used a dummy variable $z=1$ for category 1, and 0 otherwise, and added the extra term $\beta z$ to the regression model. Suppose the least squares estimate for $\beta$ is $b$. I tried to calculate some prediction intervals for the two categories. For category 1, since $z=1$, I needed to count the variance for $b$, but for category 2, since $z=0$, I did not count this variance. It then appeared that the variance for category 1 includes an additional variance because I happened to code it as $z=1$. I am new to study econometrics. Could anyone please help with this puzzle? Am I missing anything here?

**Tags:** econometrics, regression

---

## 1 answers

### Answer by username_1 on 2017-07-14. Score: 2

That is natural and you are not missing anything.

Let $y=\alpha + \beta z + u$. Your prediction of $y$ given $z=1$ is $\hat{y} = a + b$, where $a$ and $b$ are the OLS estimates. The prediction error ($y - \hat{y}$) for $z=1$ is, thus, $(\alpha - a) + (\beta-b) + u$, which is involved with $b$. On the other hand, for $z=0$, the prediction of $y$ is $a$ and the prediction error is $(\alpha-a) + u$, which has nothing to do with $b$. As you said, the former depends on $b$, while the latter does not. (Perhaps it would help to remember that the value of $z$ is given for the prediction, and thus the prediction intervals depend on the value of $z$.)

(Calculation of the prediction intervals:) You can calculate the prediction intervals using the formula $(a+b) \pm se((\alpha-a)+(\beta-b)+u) \cdot \textit{critical value}$ for $z=1$, and the formula $a \pm se((\alpha-a)+u) \cdot \textit{critical value}$ for $z=0$. which is fine. Note that these two prediction intervals can also be written as $(a+b) \pm se(a+b+u) \cdot cv$ and $a\pm se(a+u) \cdot cv$, respectively, because $\alpha$ and $\beta$ are constant (nonrandom). How to estimate the standard errors can be found in Wooldridge's textbook (the "Prediction and Residual Analysis" section; 6.4 in 5ed).

> **Comments:**
> **username_0**: Thanks for your answer. The counter-intuitive part for me is that the category with $z=1$ always has the extra variance due to the variance of $b$, which means a wider prediction interval (i.e., we are less sure where a new observation falls). Thus, we are less sure about a new observation in category 1, if we code category 1 as $z=1$, and less sure about category 2 otherwise. It seems that this inference depends on how we code the dummy variable, instead of the nature of the problem. If we change the coding, we obtain different intervals, then which intervals should we use? Thanks.  
> **username_1**: That's an interesting point, but it won't happen. If you define $w=1-z$ and regress $y$ on $w$ instead of on $z$, then $\alpha$ and $\beta$ change, $a$ and $b$ change, and the standard errors change, and in the end the prediction interval for $w=0$ is exactly the same as what you originally obtained for $z=1$. Also $a+b$ doesn't have to have a larger variance than $a$ when they are mutually (strongly negatively) correlated.  
> **username_0**: Thanks a lot. This answers my question. I missed the point that $a$ and $b$ in general are not independent.  

---

