# Multiple linear Regression with dummy variables

I am confused! I have two dummy variables (3 groups) and a third predictor, $Age$, which is continuous. What I don't understand is: why do I get different results (p-value and coefficient) for $Age$ when I include the two dummy variables in the model vs. when I run the model over the reference group only (without the dummy variables), i.e.:

With the dummy variables: $y= \beta_0 + \beta_1Age + \beta_2d_1 + \beta_3d_2$

If I set $d_1$ and $d_2$ = 0, I get $y=\beta_0 + \beta_1Age$

When I run a analysis only over the reference group ($d_1$=0 and $d_2$=0), I should get the same result because $y=\beta_0 + \beta_1Age$, right?

• I find what you said about setting $d_1$ and $d_2$ to 0 confusing. Do you mean to say that you set those variables to 0 in the dataset and then re-ran your regression? – Marquis de Carabas Sep 8 '16 at 18:24

In your analysis with three groups $\beta_1$ captures the average relation of age and $y$ in the three groups. In you second analysis with only one group $\beta_1$ captures the average relation of age and $y$ in that group. If the relation between age and $y$ is different across your three groups, you will have different estimates for your two analyses.

You need to include the interaction between your indicators and age in your first regression if you want to recover the estimates of your single group regression.

If you want to run your analysis on reference group only, your equation would be y= b0 + b1*age + b4*d3 NOT y= b0 + b1*age

The second equation essentially doesn't know of the existence of any grouping variable, whereas the previous versions have information from the dummy variables. As a result there will be a change in the coefficient of age.

• Thanks for your answer, however, I think that is not true! For my three groups, I only have two dummy variables (d1 and d2) and no d3. – MikD Aug 18 '16 at 8:18
• For n classes, you will need only n-1 dummy variables. 0-0 indicates class 1, 0-1 indicates class2, 1-0 indicates class 3. If you want to only include class three, you will have to create a dummy just for it (d3). Not leave both dummy variables out entirely. – Arun Jose Aug 18 '16 at 8:29
• Just to clarify, when you say "When I run a analysis only over the reference group (d1=0, d2=0), " - Are you sampling data from only the reference group? – Arun Jose Aug 18 '16 at 8:33
• Thanks for your patience! Yes, I only select these cases in my file! – MikD Aug 18 '16 at 12:21
• if your sample changes between your tests, isn't it likely that your equation could vary as well, could you post your actual results? – Arun Jose Aug 19 '16 at 2:59

You should only get the results if the relationship between $y$ and $Age$ is exactly identical for all three groups. Consider the full, unrestricted model: $$y = (\alpha_0 + \alpha_1*Age)*d_1 + (\beta_0 + \beta_1*Age)*d_2 + (\gamma_0 + \gamma_1*Age)*d3 + \varepsilon$$

This allows each group to have its own intercept ($\alpha_0, \beta_0, \gamma_0$) and its own slope coefficient for age $(\alpha_1, \beta_1, \gamma_1)$. Your original model allows for the intercepts to be different (through your dummy variables) but you impose the assumption that $\alpha_1 = \beta_1 = \gamma_1$. So when you estimate the model $$y = b_0 + b_1Age + b_2d_1 + b_2*d_2 + e$$ your $b_1$ is a weighted average of the true $\alpha_1$, $\beta_1$, and $\gamma_1$. When you restrict the sample to $d_3 = 1$, you're getting $\gamma_1$ alone.

(For completeness, I also wanted to point out that roughly speaking, $b_0 = \alpha_0$, $b_2 = \beta_0 - \alpha_0$, and $b_3 = \gamma_0 - \alpha_0$, since this equation omits one group and uses a catchall intercept instead. However, they won't line up perfectly because you've forced all of the groups to have the same slope. But those equalities are what is intended, and if the slopes are in fact equal across all groups, then you'll get the right intercept estimates.)