Gender, region, season, a policy being in force: regressions need to take account of facts that are categories, not quantities. A dummy variable does it with a 0 or a 1. This lesson shows what a dummy does to the line (it moves it), what an interaction does (it tilts it), why a regression on a dummy is nothing more than a comparison of averages, and why including a dummy for every category as well as a constant makes the regression impossible to run.
The Ashanagar survey is invented. The statistics modules used one district of 60 households. Econometrics needs more households and more variables, so this is a new, larger survey of 600 households in the same imaginary district: income, spending, household size, whether the household is in the town or a village, the head’s schooling and earnings.
Because we wrote the data-generating process, we know the true answers, and every lab can show whether a regression recovers them. Household spending, in thousands of rupees a month, was generated as 1 + 0.45 × income + 0.9 × household size + 1.5 × town + an error with standard deviation 2.5. A real survey never tells you its true coefficients. This one does, so you can see how close an estimate comes.
It also holds a variable, the head’s ability, that a real survey could not observe. It is kept so that the lessons on omitted variables can show what happens when it is left out. Every figure here is illustrative, not official statistics.
A dummy variable (also called an indicator or a binary variable) is 1 when an observation has some property and 0 when it does not. Put it in a regression next to a quantitative regressor and it works like a switch that adds a fixed amount to the prediction when the property holds:
For a base-group member the prediction is a + bx. For a member of the other group it is a + bx + d. The two lines have the same slope b and differ by d everywhere, so they are parallel and d is called the differential intercept.
In the survey, 244 of 600 heads of household live in a town. Their earnings average 19.13 (₹ thousand a month) against 11.78 in villages, a gap of 7.35. Regress earnings on the town dummy alone and the coefficients are exactly these averages: intercept 11.78, dummy 7.35. The derivation shows why this must happen.
The columns of X are a column of ones and D. Let n₀ households have D = 0, n₁ have D = 1, and n = n₀ + n₁. Then X′X has n and n₁ on the diagonal and n₁ off it (the sum of D is n₁, and so is the sum of D²). X′y has the sum of all y and the sum of y over the D = 1 group:
n₁a + n₁d = ΣD=1 y. Divide by n₁: a + d = ȳ₁, the average y of the D = 1 group.
The first equation is na + n₁d = Σall y. Subtracting the second leaves (n − n₁)a = n₀a = ΣD=0 y, so a = ȳ₀, the average of the D = 0 group. Then d = ȳ₁ − a = ȳ₁ − ȳ₀.
Of the 600 households, 356 are in villages and 244 in towns. The head’s average earnings are 11.7812 in villages and 19.1311 in towns, a gap of 7.35. The regression of earnings on the town dummy gives a = 11.7812 and d = 7.35. They match.
The standard error of d is √(s²(1 ÷ n₀ + 1 ÷ n₁)), where s² is the residual variance, which here is the pooled within-group variance. That is the standard error of a difference between two means with a pooled variance: √(43.492 × (1 ÷ 356 + 1 ÷ 244)) = 0.5481, and the regression reports 0.5481. A regression with one dummy and an intercept is the equal-variance two-sample t test.
If the dummy is coded the other way (1 for villages), the intercept becomes the town average and the coefficient becomes −d: the same two averages, written differently.
Now hold other things constant. Add schooling and the head’s ability to the regression and the town coefficient falls to 3.04 (we wrote the model with a true town effect of 3). Most of the raw gap of 7.35 was town heads being better schooled and abler, not towns paying more for the same person. A dummy coefficient in a multiple regression is a gap at the same values of everything else in the model, and which controls are included changes what it measures.
Three small readings the exams ask for:
A dummy alone forces the two groups to have the same slope. If the payoff to schooling may differ between towns and villages, multiply the dummy by the quantitative variable and include the product, an interaction term:
| Group | Intercept | Slope |
|---|---|---|
| Base group, D = 0 | a | b |
| Other group, D = 1 | a + d | b + g |
In the lab, choose between the dummy alone and the dummy with its interaction, code the dummy 0/1 or −1/+1, and move the slider to build a real extra payoff to schooling into town earnings. Watch the lines, and watch which coefficient carries which change.
Heads of household in the survey: earnings (₹ thousand a month) against years of schooling. Every fit also holds the invented ability score fixed, so the true values are known: schooling pays 1.3 and a town adds 3.
| Term | Estimate | Std. error | t |
|---|---|---|---|
| Intercept | 2.937 | 0.273 | 10.74 |
| Schooling (years) | 1.298 | 0.035 | 37.09 |
| Town (1) or village (0) | 3.037 | 0.235 | 12.93 |
| Ability | 2.685 | 0.108 | 24.79 |
Horizontal: years of schooling of the head. Vertical: the head’s monthly earnings in ₹ thousand. Lines are drawn at average ability. Every third household is shown, nudged sideways so the points do not stack.
The two lines are parallel: both rise 1.3 per extra year of schooling, and the town line sits 3.04 higher. That 3.04 is the average gap between a town head and a village head with the same schooling and ability (we wrote 3). It is the intercept shift.
600 households, 596 degrees of freedom.
Reading the interaction model:
A variable with m categories (four seasons, five regions) needs m − 1 dummies when the regression has a constant. The omitted category is the base, and each dummy coefficient is a gap from it. The survey’s heads of household fall into three education groups, by years of schooling:
| Group | Households | Average earnings |
|---|---|---|
| Primary (0 to 5 years) | 137 | 6.028 |
| Secondary (6 to 10 years) | 312 | 14.262 |
| Higher (11 or more) | 151 | 23.753 |
Take primary as the base, with a constant and two dummies: the constant is 6.028, the secondary dummy is 8.234 (14.262 − 6.028) and the higher dummy is 17.725 (23.753 − 6.028). Now take secondary as the base: the constant becomes 14.262, and the other two coefficients become −8.234 and 9.491. Everything is rewritten, and nothing has changed: both regressions give the same fitted values, the same residuals and the same R², 0.6721. Try it, and then try to include all three dummies together with the constant.
| Term | Estimate | Std. error |
|---|---|---|
| Intercept | 6.028 | 0.368 |
| Secondary | 8.234 | 0.442 |
| Higher | 17.725 | 0.509 |
Each dummy coefficient is a gap from the base group, primary: the constant 6.03 is that group's average earnings, and adding a dummy's coefficient gives the other group's average. The fitted averages match the actual ones, and R² (0.6721) is the same whichever group you make the base. Changing the base changes how the same three averages are written, not what the regression says.
There are two ways out, and both are standard:
Two papers print “quantitative variable” where they mean a qualitative one with m categories; the rule is for qualitative variables, and with a constant the answer is m − 1 dummies. A regression that has a constant plus both a Pass and a Fail dummy cannot be estimated, for the same reason: Pass + Fail = 1.
With a constant, a variable with m categories gets m − 1 dummies; using all m is perfect collinearity (the dummy-variable trap). Each dummy coefficient is a gap from the omitted base group, and the choice of base changes the coefficients but not the fitted values or R².
Recoding a dummy rewrites the same line in new coefficients. Suppose y = a + bx + dD with D = 0 or 1. Define a new variable E = 2D − 1, which is −1 for the base group and +1 for the other group, so D = (E + 1) ÷ 2. Substitute:
| Coding | Intercept | Coefficient on x | Dummy coefficient |
|---|---|---|---|
| Base 0, other 1 | a | b | d |
| Swap: base 1, other 0 | a + d | b | −d |
| Base −1, other +1 | a + d ÷ 2 | b | d ÷ 2 |
In every row the fitted values, the residuals, R² and the t statistic of the dummy (up to sign) are identical. Only what the numbers are called changes. The same is true of changing the base category with m groups (chapter 3), and of rescaling x (lesson 6), which changes b but not the dummy’s coefficient. Switch the lab above to −1/+1 coding and compare the lines.
Suppose the slope of spending on income changes once income passes a threshold X*, say 400. Two ways to write it:
Take Ŷ = 100 + 0.5X − 0.2(X − 400)D. Below 400 the slope is 0.5; above, 0.5 − 0.2 = 0.3. At X = 400 both pieces give 100 + 0.5 × 400 = 300, so the line bends there without a gap. At X = 500 the prediction is 100 + 250 − 20 = 330. The coefficient on D·(X − X*) is the change in slope, and a t test on it tests whether the kink is real. This is the econometrics behind kinked Engel curves, tax schedules and piecewise-linear spline models.
Definitions and one-step calculations: a t statistic, an R², which assumption is which. Most CUET and JNU questions sit here.
Restricted against unrestricted regressions, reading output, and statement questions, up to GATE and IIT JAM level.
This topic’s hardest questions, from the DSE entrance, are worked through in Lesson 18: Dummy variables, recoding and kinks.
These are questions from the TestStop bank. A free account answers 10 a day, each with its worked solution; All-Access opens every set with no daily limit.
The Delhi School’s questions on dummies (a dummy for gender and the most precise estimate of the gap, a poor-condition dummy in a home-sales regression, a kinked Engel curve) are in the hard-problems lesson at the end of the module. The case where the dependent variable is a dummy is in lesson 14, on the linear probability model, logit and probit.