10.2 One dummy: a shift in the intercept
What does the coefficient on a 0/1 variable mean?
Start with the simplest possible regression: log earnings on the urban dummy and nothing else.
\[\ln(\text{earnings}) = \beta_0 + \beta_1 \,\text{urban} + u\]
Work out what the model predicts for each group by substituting the only two values the variable can take.
For a rural worker, \(\text{urban} = 0\):
\[E[\ln(\text{earnings}) \mid \text{rural}] = \beta_0\]
For an urban worker, \(\text{urban} = 1\):
\[E[\ln(\text{earnings}) \mid \text{urban}] = \beta_0 + \beta_1\]
Subtracting the first from the second:
\[\beta_1 = E[\ln(\text{earnings}) \mid \text{urban}] - E[\ln(\text{earnings}) \mid \text{rural}]\]
The intercept is the mean of the base group — the one coded 0.
The coefficient is the difference in means between the two groups.
Nothing about a slope has changed conceptually. It is still the change in \(y\) for a one-unit change in \(x\); it is only that the single available unit is the whole distance from one group to the other.
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 9.818 0.00964 1018.03 0
#> urban 1.076 0.01861 57.81 0
#> Rural Urban
#> 9.818 10.894
The intercept, 9.818, is exactly the rural mean. The coefficient, 1.076, is exactly the gap between the two means.
Because the outcome is in logarithms, Section 9.2 tells us how to read it: urban workers earn about \(193\)% more than rural workers. The coefficient is far above 0.2, so the exact expression is required and the approximation of 108% would be badly wrong.
Something familiar
Look again at what this regression is doing. It is comparing the mean of one group with the mean of another and reporting a standard error for the difference.
That is the two-sample \(t\)-test of Unit 5.
c(regression_t = coef(summary(one_dummy))[2, 3],
t_test = abs(t.test(lw ~ residence, data = wages,
var.equal = TRUE)$statistic))#> regression_t t_test.t
#> 57.81 57.81
Not merely similar. The same number, to every digit R prints.
A regression on a single dummy variable is a two-sample \(t\)-test.
The pooled two-sample test of Section 5.4 assumed a common variance in the two groups; the regression assumes homoskedasticity, which here says the same thing. Given the same assumption, they are the same procedure written two ways.
This is worth pausing on, because it reframes everything that came before.
Unit 5 looked like a self-contained topic with its own formula. It was a special case of regression all along — the case with one explanatory variable that happens to be binary.
And regression can do what the \(t\)-test cannot. Add controls and the comparison becomes a difference between groups among people alike in other respects, which is precisely what Unit 8 was about.
controlled <- lm(lw ~ urban + education + age + male, data = wages)
round(coef(summary(controlled))[, 1:2], 5)#> Estimate Std. Error
#> (Intercept) 8.46020 0.02950
#> urban 0.80452 0.01713
#> education 0.07617 0.00152
#> age 0.01173 0.00065
#> male 0.77016 0.01629
The urban premium falls from 1.076 to 0.805 once education, age and sex are held fixed. Part of the raw gap was the fact that urban workers are better educated — not a return to living in a city.