Contents
- Why are dummy variables needed?
- How should the 0 and 1 be assigned?
- A worked example in Minitab
- Reading the dummy coefficient
- Categorical variables with more than two categories
- Dummy variables in log models and interactions
- Creating dummy variables in Python
- Frequently asked questions
- What is a dummy variable in regression?
- How many dummy variables are needed for a variable with four categories?
- What is the dummy variable trap?
- Can a dummy variable be the dependent variable?
- Do dummy variables need to pass the normality test?
- Can an ordinal variable such as education level be entered as dummies?
- References
Versi bahasa Indonesia: Variabel Dummy dalam Regresi: Pengertian dan Cara Membacanya
Short answer: a dummy variable is an artificial variable coded 0 and 1 that allows categorical information, such as gender, location, or group membership, to enter a regression model. The coefficient of a dummy variable is read as the difference in the mean of Y between the category coded 1 and the reference category coded 0, holding the other variables constant. A categorical variable with k categories requires k − 1 dummy variables.
| Situation | Coding | Interpretation of the coefficient |
|---|---|---|
| Two categories (member vs non-member) | One dummy: member = 1, non-member = 0 | Difference in Y for members relative to non-members |
| Three categories (lowland, midland, highland) | Two dummies; lowland as reference | Each coefficient is the difference from lowland |
| Dependent variable in logarithms | Dummy = 0 or 1 | (eb − 1) × 100% difference in Y |
| Dummy × continuous variable | Interaction term | Difference in the slope between categories |
Why are dummy variables needed?
Linear regression and multiple regression describe how one dependent variable responds to several independent variables. A production model, for example, may relate output to land area, fertilizer, labor, and capital. These variables are measured on interval or ratio scales, which suits the arithmetic of regression. However, many relevant factors are categories rather than quantities: whether a farmer belongs to a farmer group, whether a plot is irrigated, which region a household lives in, or whether a firm is exporting. Such nominal or ordinal information cannot enter the equation directly as text. Dummy variables translate it into numbers that regression can use.
Two examples illustrate the idea. In a study of spending at shopping centers, gender can be coded 0 for male and 1 for female. In a study of farm income, farmer group membership can be coded 0 for non-members and 1 for members. In both cases, the dummy coefficient estimates how much the dependent variable differs between the two groups after accounting for the other variables in the model.
Dummy variables should not be confused with logistic regression. In logistic regression, the categorical variable is the dependent variable (Y). In the case discussed here, the categorical variable is an independent variable (X). Both can appear in the same model, since a logistic regression can also contain dummy independent variables.
How should the 0 and 1 be assigned?
The assignment of 0 and 1 is a choice, and a thoughtful choice makes interpretation easier. A practical rule is to give the value 1 to the category that the hypothesis expects to affect Y. In the farmer group example, the hypothesis states that membership raises income, so members are coded 1. The coefficient then directly measures the income advantage of members over non-members.
Reversing the coding is not wrong. The model fit, the p-value, and the size of the effect remain identical; only the sign of the coefficient changes. A negative coefficient for “non-member = 1” carries exactly the same information as a positive coefficient for “member = 1”. However, a reversed coding often confuses readers and examiners, and the discussion becomes harder to write. Consequently, coding the expected “treatment” group as 1 is the clearer option.
A worked example in Minitab
The practice data were generated randomly in Excel and contain five independent variables, of which X2 is a dummy variable. The analysis uses Minitab 17.

The procedure is as follows: (1) open Stat, Regression, Regression, Fit Regression Model; (2) enter Y as the response; (3) enter X1, X3, X4, and X5 as continuous predictors; and (4) enter X2 as a categorical predictor. Declaring X2 as categorical tells Minitab to treat 0 as the reference level.



The model summary shows R-sq = 65.09%, which means that the model explains about 65% of the variation in Y. Among the five variables, only X2 has a p-value below 0.05. The VIF values of X1 and X4 exceed 10, indicating multicollinearity that would need to be addressed in a real study. For the purpose of explaining the dummy coefficient, the discussion assumes these diagnostics have been resolved.
Reading the dummy coefficient
The coefficient for X2 = 1 is 3,876. Respondents coded 1 have, on average, a Y value 3,876 units higher than respondents coded 0, holding X1, X3, X4, and X5 constant. The same conclusion can be read from the regression equations that Minitab reports for each level of X2.

When X2 = 0, the equation is Y = 5,468 + 2.89X1 − 19.0X3 − 5.74X4 − 1.49X5. When X2 = 1, it becomes Y = 9,344 + 2.89X1 − 19.0X3 − 5.74X4 − 1.49X5. The slopes are identical, and only the intercept changes. The difference between the intercepts, 9,344 − 5,468 = 3,876, equals the dummy coefficient. Thus, a dummy variable shifts the regression line up or down without changing its slope.
This interpretation differs from that of a continuous variable. A continuous coefficient describes the change in Y for each additional unit of X. A dummy coefficient describes a one-time difference between two groups, since a dummy cannot increase by “one more unit” beyond 1.
Categorical variables with more than two categories
A variable with three or more categories requires several dummy variables. Consider farm location with three categories: lowland, midland, and highland. Two dummies are created: Dmid = 1 for midland farms and 0 otherwise, and Dhigh = 1 for highland farms and 0 otherwise. Lowland farms have 0 on both dummies and serve as the reference category.
Including a third dummy for lowland would create perfect multicollinearity, because the three dummies would always sum to 1 and duplicate the intercept. This situation is known as the dummy variable trap, and software either fails to estimate the model or drops one dummy automatically. Consequently, a variable with k categories always enters the model as k − 1 dummies.
The choice of reference category affects interpretation but not the model fit. Each dummy coefficient is the difference between that category and the reference. A sensible reference is the largest group or the natural baseline, such as “no treatment” or “lowland” in the example above.
Dummy variables in log models and interactions
When the dependent variable is in logarithms, the dummy coefficient is not exactly a percentage. The correct percentage difference is (eb − 1) × 100%. For a coefficient of 0.25, the difference is (e0.25 − 1) × 100% = 28.4%, not 25%. For small coefficients the approximation is close, but for large coefficients the difference becomes substantial.
A dummy can also be multiplied by a continuous variable to create an interaction term. For example, the product of irrigation status and fertilizer use allows the effect of fertilizer to differ between irrigated and rainfed farms. The interaction coefficient measures the difference in the slope. A small field scene makes the logic concrete: two neighboring farmers apply the same extra bag of urea, yet only the one with reliable irrigation sees a clear yield response. The interaction term captures exactly that difference.
Creating dummy variables in Python
import pandas as pd
import statsmodels.formula.api as smf
df = pd.read_csv("farms.csv")
# C() treats 'location' as categorical; Treatment() sets the reference category
model = smf.ols("income ~ land + member + C(location, Treatment('lowland'))", data=df).fit()
print(model.summary())
The formula interface creates the k − 1 dummies automatically and names each coefficient after its category, which avoids the dummy variable trap without manual coding.
Related guides on Catatan Budi: multiple linear regression, variance inflation factor (VIF), and R-squared vs adjusted vs predicted R-squared.
Frequently asked questions
What is a dummy variable in regression?
A dummy variable is a 0/1 variable that represents a category, allowing qualitative information to be included in a regression model.
How many dummy variables are needed for a variable with four categories?
Three. A variable with k categories requires k − 1 dummies, and the omitted category becomes the reference.
What is the dummy variable trap?
The trap occurs when a dummy is created for every category and all are included together with the intercept. The dummies then sum to 1 and are perfectly collinear with the constant, so the model cannot be estimated.
Can a dummy variable be the dependent variable?
Yes, but then linear regression is no longer appropriate. A binary dependent variable is analyzed with logistic or probit regression.
Do dummy variables need to pass the normality test?
No. Normality concerns the residuals of the model, not the independent variables. A 0/1 variable can never be normally distributed, and that is not a violation of any regression assumption.
Can an ordinal variable such as education level be entered as dummies?
Yes. An ordinal variable can be entered either as a single numeric score, which assumes equal steps between levels, or as k − 1 dummies, which lets each level have its own effect. The dummy approach is safer when the distances between levels are not equal, for example between primary, secondary, and tertiary education.
References
- Gujarati, D. N., and Porter, D. C. (2009). Basic Econometrics (5th ed.). McGraw-Hill.
- Halvorsen, R., and Palmquist, R. (1980). The interpretation of dummy variables in semilogarithmic equations. American Economic Review, 70(3), 474–475.
- Wooldridge, J. M. (2020). Introductory Econometrics: A Modern Approach (7th ed.). Cengage.
Discussion
No comments yet. Have a question about this topic? Write it below and I will do my best to answer.