OLS Regression with
Dummy Variables as
regressors
Class Notes: Module 3
Econometric Methods: AE-EE-08
MA 2nd Semester (Jan-May 2026)
Course Coordinator: Gopal Krishna Roy
Email: [Link]@[Link]
Introduction
• We now move from using the quantitative (numeric continuous: ratio scale)
independent variables to qualitative independent (categorical: nominal)
variables. E.g., gender: male, female; location: rural, urban
• OLS regression can also be applied to the case where x is a binary variable,
often called a dummy variable. As the name “binary variable” suggests, x
takes on only two values, zero and one.
• Even though zero and one are numbers, they are just two categories here coded
as 1 and 0.
• These two values are used to put each unit in the population into one of two
groups represented by x=0 and x=1.
• For example, we can use a binary variable to describe whether a worker
participates in a job training program. The independent variable training can be
coded as training=1 means a person participates; training=0 means the person
does not. Given a data set, we add an i subscript, as usual, so trainingi indicates
job training status for a randomly drawn person i.
• Suppose in the wage
example that we have
chosen the name female to
indicate gender. Further, we
define a binary variable
married to equal one if a
person is married and zero if
otherwise.
• Table 7.1 gives a partial
listing of a wage data set
that might result. We see
that Person 1 is female and
not married, Person 2 is
female and married, Person
3 is male and not married,
and so on (Wooldridge,
2018, Ch7).
What a dummy variable coefficient means in
OLS?
• Suppose our model is:
𝑌 = 𝛽0 + 𝛽1 𝐷 + 𝜖
where 𝐷is a dummy (0 or 1). Think of it as gender (Male=1 and
Female=0)
• For a continuous variable X, marginal effect is:
𝜕𝐸(𝑌|𝑋)
𝜕𝑋
• But for a dummy variable, we can’t take a derivative. So
instead, the marginal effect is defined as a discrete change:
• 𝛽1 = 𝑀𝑎𝑟𝑔𝑖𝑛𝑎𝑙 𝐸𝑓𝑓𝑒𝑐𝑡 = 𝐸 𝑌 ∣ 𝐷 = 1 − 𝐸 𝑌 ∣ 𝐷 = 0
• β1 represents the difference in the expected
value of 𝑌 when: 𝐷 = 1 vs 𝐷 = 0
PRF is E(𝑌|𝐷) = 𝛽0 + 𝛽1 𝐷 (assuming MLR4 E(𝜖|D)=0)
• Step 1: Plug in 𝐷 = 1
𝐸[Y|D = 1] = 𝛽0 + 𝛽1
• Step 2: Plug in 𝐷 = 0
𝐸[Y|D = 0] = 𝛽0
• Step 3: Take the difference
𝐸 Y D = 1 − 𝐸 Y D = 0 = 𝛽1
Dummy Independent Variable: Interpretation
wage = β0+ β1 female + β2 educ + u
• Because female= 1 when the person is female, and female =0 when the person is
male, the parameter β1 has the following interpretation: β1 is the difference in
expected hourly wage between females and males, keeping other factors
constant.
• This difference in hourly wage is due to gender or other factors associated
with the gender that we have not controlled for in the model.
• After we control for other relevant variables that determine wage (for e.g.
experience, tenure, innate ability, weekly hours of work, marital status, hazardous
employment, paid time off/casual leaves, public or private sector etc.), the
coefficient β1 determines whether there is discrimination against women: if β1 < 0,
then for the same level of other factors, women earn less than men on average. We
test whether this estimated negative coefficient is significantly different from zero
(hypothesis test using p-value)
• In terms of expectations, if we assume the zero conditional mean
assumption E(u|female,educ) = 0, then
• β1= E(wage| female=1,educ)- E(wage| female=0,educ)
• Because female=1 corresponds to females and female=0
corresponds to males, we can write this more simply as
• β1= E(wage| female=1,educ)- E(wage| male,educ)
• The key here is that the level of education is the same in both
expectations; the difference, β1, is due to gender only.
• The situation can be depicted graphically as an intercept shift
between males and females. The difference does not depend on
the amount of education, and this explains why the wage-
education profiles for women and men are parallel.
Dummy variable trap
• why we do not also include in the wage regression equation a dummy
variable, say male, which is one for males and zero for females.
• This would be redundant.
• Using two dummy variables would introduce perfect collinearity because
female + male = 1, which means that male is a perfect linear function of
female.
• What is the problem if we have perfect multicollinearity among
explanatory variables? Violation of MLR 3 (check partialling out formula)
• Including dummy variables for both genders is the simplest example of the
so-called dummy variable trap, which arises when we use as many
dummy variables as the total number of categories.
• In the previous wage regression, we have chosen males to be the
base/reference group or benchmark group, that is, the group against
which comparisons are made.
• We introduce n-1 dummy variables if there are n categories in a variable.
Suppose the Dummy variable has three groups:
• Category A
• Category B
• Category C
We create two dummies for B and C and keep A as
the reference category:
• 𝐷𝐵 = 1 if B, 0 otherwise
• 𝐷𝐶 = 1if C, 0 otherwise
• Category A is the baseline/reference (when both
dummies = 0)
Hence, the regression equation is:
Y=β0+β1DB+β2DC+β3X+ϵ
• Imputing values for dummy variables for each category, we
get:
• Category A (baseline/reference category)
𝐷𝐵 = 0, 𝐷𝐶 = 0
𝐸[Y|A, X] = 𝛽0 + 𝛽3 𝑋 ……(1)
• Category B
𝐷𝐵 = 1, 𝐷𝐶 = 0
𝐸 Y B, X = 𝛽0 + 𝛽1 + 𝛽3 𝑋 ……..(2)
• Category C
𝐷𝐵 = 0, 𝐷𝐶 = 1
𝐸 Y C, X = 𝛽0 + 𝛽2 + 𝛽3 𝑋 …….(3)
So, E[Y∣B,X]−E[Y∣A,X]=β1 (eqn (2)-(1)), and
E[Y∣C,X]−E[Y∣A,X]=β2 (eqn (3)-(1))
Interactions Effects
Intuition:
• It is possible that the partial effect, elasticity, or semi-elasticity of the
dependent variable with respect to an explanatory variable may
depend on the magnitude of yet another explanatory variable
(Wooldridge, 2018, Ch 6).
• To test a hypothesis like the above, we run the regression with an
interaction term between two explanatory variables of interest.
• Consider the model: 𝑦 = 𝛽0 + 𝛽1 𝑥1 + 𝛽2 𝑥2 + 𝛽3 𝑥1 𝑥2 + 𝑢
• In the above eqn, 𝛽3 is the coefficient of the interaction term
between x1 and x2.
• Depending upon the scale of measurement of x1 and x2, we can have
three types of interactions: continuous by continuous, continuous by
categorical, categorical by categorical.
Categorical by Continuous interaction
• Consider the model: 𝑦 = 𝛽0 + 𝛽1 𝑥1 + 𝛽2 𝑥2 + 𝛽3 𝑥1 𝑥2 + 𝑢
• E.g. x1 is a dummy variable on gender (Female =1 and
male =0) and x2 is a continuous variable on years of
education. Let y be log of wages.
• A model like above can be useful if we are interested to
test the hypothesis that returns to education are
different for males and females (allowing for different
slopes of education based on gender categories)
• H0: 𝛽3 = 0, which means that the slope of log(wage)
with respect to educ is the same for men and women.
• If p-value is less than the significance level, then we
have evidence against the null that the returns to
education is the same for men and women.
Continuous by Continuous interaction
• Suppose both x1 and x2 are continuous in:
𝑦 = 𝛽0 + 𝛽1 𝑥1 + 𝛽2 𝑥2 + 𝛽3 𝑥1 𝑥2 + 𝑢
Δ𝑦 Δ𝑦
• Here, = 𝛽1 + 𝛽3 𝑥2 , and = 𝛽2 + 𝛽3 𝑥1 (usually we
Δ𝑥1 Δ𝑥2
interpret these at interesting values of x such as
mean or the upper/lower quartiles in the sample)
• When we include interaction term (effects), the
interpretation of 𝛽1 𝑎𝑛𝑑 𝛽2 (called simple effects) is
not much of interest.
• 𝛽2 is the effect of x2 on y when x1 is equal to zero
(not interesting)
• In the above eqn, 𝛽3 gives the interaction effect.
• If 𝛽3 > 0, then it implies that an additional bedroom
yields a higher increase in housing price for larger
houses.
Categorical by Categorical interaction
• Suppose both x1 and x2 are categorical in: 𝑦 = 𝛽0 + 𝛽1 𝑥1 + 𝛽2 𝑥2
+ 𝛽3 𝑥1 𝑥2 + 𝑢
• E.g. x1 is a dummy variable on gender (Female =1 and male =0)
and x2 is a dummy variable on marital status (married=1 and
unmarried =0). Let y be log of wages.
• So overall, there are four categories as follows:
▪ Unmarried male (x1 = 0 , x2 = 0) (base category)
▪ Married male (x1 = 0 , x2 = 1, 𝑥1 𝑥2 =0)
▪ Unmarried Female (x1 = 1 , x2 = 0, 𝑥1 𝑥2 =0)
▪ Married Female (x1 = 1 , x2 = 1, 𝑥1 𝑥2 =1)
• Through the interaction term, the model allows us to obtain the wage
differentials across all gender–marital status combinations, and
• The model also tests the null hypothesis that the gender differential
does not depend on marital status (equivalently, that the marriage
differential does not depend on gender (Wooldridge, 2018, Ch 7).
Incorporating Ordinal Information by Using Dummy
Variables
• Suppose that we would like to estimate the effect of city credit
ratings on the municipal bond interest rate (MBR).
• Several financial companies, such as Moody’s Investors Service
and Standard and Poor’s, rate the quality of debt for local
governments, where the ratings depend on things like probability
of default.
• Local governments prefer lower interest rates in order to reduce
their costs of borrowing.
• For simplicity, suppose that rankings take on the integer values
{0, 1, 2, 3, 4} with zero being the worst credit rating and four
being the best. This is an example of an ordinal variable.
• The question we need to address is: How do we incorporate the
variable CR (credit rating) into a model to explain MBR?
• One possibility is to just include CR as we would include any other
explanatory variable:
• MBR = β0+ β1 CR + 𝑜𝑡ℎ𝑒𝑟 𝑓𝑎𝑐𝑡𝑜𝑟𝑠
• Then β1 is the percentage point change in MBR when CR increases
by one unit, holding other factors fixed. Unfortunately, it is rather
hard to interpret a one-unit increase in CR.
• We know that a CR of four is better than a CR of three, but is the
difference between four and three the same as the difference
between one and zero? If not, then it might not make sense to
assume that a one-unit increase in CR has a constant effect on
MBR.
• A better approach, which we can implement because CR takes on
relatively few values, is to define dummy variables for each value of
CR. Thus, let CR1 = 1 if CR =1, and CR1 = 0 otherwise;CR2 = 1 if
CR = 2, and CR2 = 0 otherwise; and so on.
• Effectively, we take the single credit rating and turn it into five
categories. Then, we can estimate the model
• MBR = β0+ β1 CR1 + β2 CR2 + β3 CR3 + β4 CR4 +other factors
• Following our rule for including dummy variables in a model, we
include four dummy variables because we have five categories. The
omitted category here is a credit rating of zero, and so it is the base
group. (This is why we do not need to define a dummy variable for this
category).
• The coefficients are easy to interpret: β1 is the difference in MBR
(other factors fixed) between a municipality with a credit rating of one
and a municipality with a credit rating of zero; β2 is the difference in
MBR between a municipality with a credit rating of two and a
municipality with a credit rating of zero; and so on.
• The movement between each credit rating is allowed to have a
different effect, so using dummy variables is much more flexible than
simply putting CR in as a single continuous variable.
• In some cases, the ordinal variable takes on too many
values so that a dummy variable cannot be included for
each value.
• For example, we have data on median starting salaries
for law school graduates. One of the key explanatory
variables is the rank of the law school. Because each
law school has a different rank, we clearly cannot
include a dummy variable for each rank.
• If we do not wish to put the rank directly in the
equation, we can break it down into categories.
Reference Books
• Wooldridge, J., Introductory Econometrics: A Modern Approach
7th Edition, 2018, Cengage Learning.