Dummy Variables
- #intro-econometrics
- #dummy-variables
- #categorical-variables
- #base-category
- #dummy-variable-trap
- #perfect-multicollinearity
- #OLS
Dummy Variables
Part of: Intro Econometrics | Key concepts: Dummy Variable, Base Category, Dummy Variable Trap, Perfect Multicollinearity, F-test, Model Misspecification
Where this lecture sits
The thread from last weekLast week (Lec_08-Goodness of Fit & Multicollinearity) ended on multicollinearity — what happens when regressors are linearly related. This lecture opens with a short review of model misspecification (the related question of which variables to include), then introduces the central new tool: how to put categorical information (gender, marital status, country of origin, education level) into a regression that, mechanically, only understands numbers. The answer is the dummy variable. The multicollinearity idea returns immediately — it is exactly what forces us to use one fewer dummy than categories.
The lecture has two strands:
- Review — model misspecification: the two errors of variable choice (adding an irrelevant variable, omitting a relevant one) and how to detect and fix each.
- Main content — dummy variables: binary dummies for two-category variables, sets of dummies for multi-category variables, the base-category logic, joint F-testing, the dummy-variable trap, and using dummies to capture nonlinear effects.
Part 0 — Review: Model Misspecification
Throughout the course we assumed we already knew the correct set of explanatory variables. In practice you must choose them yourself, by trial and error — adding and removing variables until the specification is right. Two errors can occur.
Running example — the price of beerSuppose the true data-generating function (model 0) is where
volume= litres per container,units= cans/bottles sold together,abv= % alcohol by volume.
Error 1 — Adding an irrelevant variable
We estimate, with random.noise tacked on:
Consequence: harmless to bias, costly to precisionIncluding an irrelevant regressor does not bias — they stay unbiased. The only cost is the precision hit from any partial collinearity the junk variable introduces (the variance-inflation story from Lecture 8).
- How to spot it: you fail to reject .
- How to fix it: drop the variable and re-estimate. With a single suspected junk variable, a t-test suffices; with several, use an F-test on the joint restriction and check the fit improves.
Error 2 — Omitting a relevant variable
We estimate, leaving out the genuinely relevant :
Consequence: omitted-variable biasIf the omitted variable () covaries with an included one (), then is biased — the included variable picks up part of the omitted variable's effect. This is the more dangerous error: it corrupts the coefficients you care about.
- How to fix it: if you have data on the missing variable, add it (estimate model 0) and test . Reject ⟹ keep the variable. As always, then check for partial collinearity.
The asymmetry to rememberAdding junk → unbiased but less precise (recoverable). Omitting a relevant, correlated variable → biased (not recoverable from the same data). When in doubt about a borderline variable that correlates with your regressor of interest, the safer error is to keep it.
Part 1 — Dummy Variables: the binary case
Until now every regressor was continuous (a real number). But much of what explains an outcome is categorical:
- gender, nationality, occupation → affect wages
- season → affects demand
- family status → affects hours worked
Regression only understands numbers, so we translate a category into a binary (0 or 1) variable. In econometrics this is a dummy variable.
Naming conventionA dummy is named after the value it takes when it equals 1. So
manfor men and for women;womanfor women and for men. Reading the name tells you which group is coded 1.
How a dummy shifts the intercept
Take wage as a function of education and gender:
where = years of education. Splitting by group shows what each coefficient means:
| Group | Model becomes | Intercept | |
|---|---|---|---|
| Women | |||
| Men |
A dummy produces two parallel linesBoth groups share the same slope (the marginal effect of education is assumed equal for men and women). The dummy only shifts the intercept. The vertical gap between the two parallel lines is exactly .
Interpreting each coefficient
- = intercept for women (the group coded 0) — wage of a woman with zero education.
- = intercept for men — wage of a man with zero education.
- = the wage gap: how much more a man earns than a woman with the same education.
- = marginal effect of education, common to both groups.
Sign reading: ⟹ men earn more; ⟹ men earn less; ⟹ no gap. Testing is a test of discrimination.
Reversing the dummy changes nothing of substance
Use woman instead of man:
Only the sign flips, never the magnitudeSwitching from
mantowomangives — same size, opposite sign — and now is the men's intercept. The fitted lines, predictions, and the test of discrimination are identical. The choice of which category is coded 1 is purely cosmetic.
Worked R example — the gender wage gap
ln_wage ~ schooly + age_g + agesq + maleCoefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.16722657 0.07405767 -15.761 <2e-16 *** schooly 0.09690805 0.00235077 41.224 <2e-16 *** age_g 0.15300905 0.00362554 42.203 <2e-16 *** agesq -0.00153057 0.00004272 -35.831 <2e-16 *** male 0.13120339 0.01408364 9.316 <2e-16 *** Multiple R-squared: 0.3711 F-statistic: 1500 on 4 and 10168 DFSince the outcome is log wage, reads as men earn ≈ 13.1% more than women with the same age and education — and it is highly significant ().
Predicting a level wage (log-dependent variable)For a woman aged 30 with 12 years of education: For an identical man (): . The jump from 25.4 to 29.0 is the same ≈13.1% the coefficient promised.
Reversing confirms the symmetryRe-running with
female(= 1 for women) flips the coefficient to and moves the intercept from (women's) to (men's). Note : the two intercepts always differ by exactly .
Activity 10, part 1 — domestic vs foreign beer
with
is.domestic= 1 if the beer is Canadian, 0 otherwise. The estimated , so the difference in between domestic and foreign beer is : domestic (Canadian) beer is about 18.5% cheaper than foreign beer with the same volume, units, and abv.
Adding a second dummy — multiple binary controls
Dummies stack. Add origin_ussr (= 1 if born in the USSR) to the wage model:
ln_wage ~ schooly + age_g + agesq + female + origin_ussr: those born in the USSR earn ≈13% less than otherwise-identical people (same age, gender, education).
What two independent dummies assumeWith both
femaleandorigin_ussrentered additively, the model assumes the gaps are separable and constant: the male–female gap (−0.128) is the same for USSR-born and non-USSR-born people, and the USSR gap (−0.132) is the same for men and women. The four group intercepts are just sums:
Group Intercept Man, not USSR (base) Woman, not USSR Man, USSR Woman, USSR Relaxing this "constant gap" assumption — letting the gender gap differ by origin — is exactly what interaction terms (Lec_11-Interaction Terms) are for.
Part 2 — Categorical variables with more than two categories
A variable like family status has three values: married, single, divorced. We represent categories with dummies. Using single as the omitted (base) group:
| Category | ||
|---|---|---|
| Married | ||
| Divorced | ||
| Single (base) |
This creates three regression lines with different intercepts but a common slope:
| Group | Intercept |
|---|---|
| Married | |
| Divorced | |
| Single (base) |
The base category is the reference pointThe group coded 0 on every dummy is the base (control) category. Every coefficient is interpreted relative to it: is the married-vs-single gap, the divorced-vs-single gap. Choosing the base is arbitrary, but it changes what each coefficient compares against, so always state it.
Why you must drop one dummy — the dummy-variable trap
The dummy-variable trap = perfect multicollinearityIf you include a dummy for every category plus an intercept, you create perfect multicollinearity, because the dummies sum to 1 for everyone: One dummy is an exact linear function of the others (and the constant), the OLS first-order conditions become redundant, and no unique solution exists. R silently drops one dummy. The rule is absolute: The omitted category becomes the base. This is the same mechanism as the perfect-collinearity result from Lec_08-Goodness of Fit & Multicollinearity.
Significance testing — use a joint F-test, not separate t-tests
Don't t-test individual dummies for "category significance"Because the base category is arbitrary, a single t-test on only asks "is married different from single?" — it says nothing about whether family status as a whole matters. To test the overall effect of a categorical variable, restrict all its dummies to zero jointly and use an F-test: This is the same joint-restriction logic as the multicollinearity diagnosis in Lecture 8: individually weak dummies can be jointly significant.
Worked R example — marital status
log_wage_per_hour ~ schooly + age + agesq + female + ussrborn + arab + married + divorcedCoefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.360729 0.103052 13.204 <2e-16 *** schooly 0.078422 0.001827 42.936 <2e-16 *** age 0.277831 0.022074 12.586 <2e-16 *** agesq -0.012220 0.001135 -10.763 <2e-16 *** female -0.182158 0.011767 -15.480 <2e-16 *** ussrborn -0.196914 0.015999 -12.308 <2e-16 *** arab -0.259704 0.019186 -13.536 <2e-16 *** married 0.170373 0.016378 10.402 <2e-16 *** divorced 0.040444 0.026623 1.519 0.129With single as the base: married people earn ≈17% more than singles (highly significant); divorced earn ≈4% more than singles, but only significant at the 12.9% level.
Activity 10, part 2 — base category and a prediction
Questions on the marital-status regression(a) What is the overall base category? The group coded 0 on every dummy: male, not born in USSR, Jewish (non-Arab), single.
(b) Predicted wage of a single Jewish woman born in the USSR, aged 40, 16 years of education? (Only
femaleandussrbornswitch on;marriedanddivorcedare 0 because she is single — the base for marital status.)
Part 3 — Dummies for nonlinear effects
Dummies aren't only for genuine categories. They are also a flexible way to capture a nonlinear marginal effect of an underlying continuous variable — here, education.
The ideaInstead of forcing a single linear coefficient on "years of education", convert education into brackets (highest diploma) and give each bracket its own dummy. Each person falls in exactly one bracket, so only one dummy is "on". This lets each level of education shift the intercept by a different, freely-estimated amount — a step function rather than a straight line.
The five diploma levels (one becomes the base):
| Code | Meaning |
|---|---|
| HSD | High school, no bagrut (matriculation) — base |
| HSG | High school with bagrut |
| SC | Post-high-school certificate |
| CG | Undergraduate degree |
| PC | Post-graduate (master's or higher) |
ln_wage ~ age + agesq + female + ussr + HSG + SC + CG + PCCoefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.65599250 0.09884423 6.637 3.5e-11 *** age 0.12040626 0.00492425 24.452 <2e-16 *** agesq -0.00120131 0.00005784 -20.770 <2e-16 *** ussr -0.23310881 0.02536835 -9.189 <2e-16 *** HSG 0.01725424 0.02804976 0.615 0.538 SC 0.31032637 0.03105285 9.993 <2e-16 *** CG 0.61595207 0.02798668 22.009 <2e-16 *** PC 0.81316002 0.03258451 24.955 <2e-16 ***Each diploma coefficient is the wage premium over HSD (the base): a certificate (SC) pays ≈31% more than no-bagrut high school, an undergraduate degree (CG) ≈62% more, a postgraduate degree (PC) ≈81% more. HSG (bagrut alone) is not significantly above HSD () — finishing high school without a certificate adds little. The premiums increase with level but in uneven steps — precisely the nonlinearity a single linear
yearsterm would miss.
Predicting from the diploma modelPredicted hourly wage (NIS) for a woman aged 40 born in the USSR with an undergraduate degree (CG = 1):
Activity 10, part 3 — differences between bracketsBecause the outcome is log-wage, differences of coefficients give percentage wage gaps directly. (a) Undergraduate (CG) vs postgraduate (PC), all else equal: — a postgraduate earns ≈19.8% more than an otherwise-identical undergraduate. (b) Postgraduate born in USSR vs certificate (SC) born in Israel, same age: The USSR penalty applies only to the first woman; the SC premium only to the second, so it is subtracted when comparing her to the PC woman.
Practice exam — a linear restriction across two coefficients
SetupHypothesis: "adding to the log building area changes the apartment price by 4 times the change from adding the same to the log lot size." Unrestricted model:
(a) The null hypothesis. "4× the effect" means , i.e.
(b)/(c) The restricted model. Impose and collect terms:
So the restricted regression has dependent variable and just two regressors: and the constructed variable . The restriction removes one parameter ().
(d) The F-statistic. With , , restriction, and residual degrees of freedom:
(e)/(f) Decision. Critical value . Since , reject at 5%.
(g) Can a t-test replace this F-test?No. The null relates two parameters to each other () rather than fixing a single coefficient to a constant. A t-test handles a hypothesis about one coefficient (or, with rearrangement, one linear combination tested via a reparameterised model), but the standard "read-off-the-output" t-test cannot test a cross-parameter restriction directly — the F-test on the restricted-vs-unrestricted RSS is the right tool. (Connects to the F-in- caveat from Lec_08-Goodness of Fit & Multicollinearity: the form fails here because the restricted model's dependent variable variance is unchanged but the restriction is not of the simple type.)
Summary
- Model misspecification has two errors. Adding an irrelevant variable keeps coefficients unbiased (only hurts precision) — spot it with a failed t-test, fix by dropping. Omitting a relevant, correlated variable causes bias — the dangerous error; fix by adding the variable back. When unsure, keep a borderline variable that correlates with your regressor of interest.
- A dummy variable converts a category into 0/1 and is named after the value-1 group. In , the dummy shifts the intercept only, producing parallel lines; is the gap between the value-1 group and the value-0 group.
- Reversing a dummy (man ↔ woman) flips the sign of its coefficient but leaves the magnitude, fitted lines, and tests identical. With a log outcome, a dummy coefficient ≈ a percentage difference (e.g.
male= 0.131 → men earn ≈13.1% more). - For a -category variable use dummies plus the intercept. Including all creates the dummy-variable trap = perfect multicollinearity (), so no unique OLS solution exists.
- The omitted group is the base category; every dummy coefficient is read relative to it. To test whether a categorical variable matters as a whole, use a joint F-test (: all its dummies = 0), never separate t-tests — the base choice is arbitrary.
- Dummies also model nonlinear effects: bracket a continuous variable (e.g. education into diploma levels) and give each bracket its own dummy, letting each level shift the intercept by a freely-estimated, uneven step. Coefficient differences give bracket-to-bracket percentage gaps.
- A hypothesis relating two parameters () is tested with the F-test on restricted-vs-unrestricted RSS, not a standard t-test.
Related Notes
- Previous: Lec_09-Model Misspecification & Quadratics — omitted and irrelevant variables and quadratics, the misspecification ideas that dummies extend
- Earlier: Lec_08-Goodness of Fit & Multicollinearity — perfect vs partial multicollinearity (the engine behind the dummy-variable trap), the joint F-test
- Next: Lec_11-Interaction Terms — letting the slope (effect size) differ across groups, relaxing the constant-gap assumption of additive dummies
- Then: Lec_12-Heteroskedasticity
- Foundational: OLS Estimation, F-test, Perfect Multicollinearity, Model Misspecification
- Concepts: Dummy Variable, Base Category, Dummy Variable Trap, Omitted Variable Bias
- Hub: Intro Econometrics