What are dummy variables and why are they used?

Instruction: Describe the concept of dummy variables and their application in statistical analysis.

Context: This question assesses the candidate's understanding of how categorical data is handled in statistical modeling, specifically the use and importance of dummy variables.

Updated

Official answer

A dummy variable is a 0/1 indicator for membership in a category. It lets a model represent nominal categories without imposing an arbitrary numeric order.

For color with levels red, blue and green, an intercept model can use red=(1,0), blue=(0,1) and green=(0,0). Green is the reference. In a linear model without interactions, the red coefficient is the modeled red-versus-green mean difference with other predictors fixed; the intercept applies to green at the other predictors’ zero values.

Including all three indicators plus an intercept creates exact linear dependence because the indicators sum to one. This is the dummy-variable trap, not merely high correlation. Using K−1 indicators is one standard identifiable coding; other contrast systems or an appropriate no-intercept model are possible.

Fit and preserve the encoding schema on training data. Define handling for unseen and missing categories. Dummy encoding does not guarantee predictive improvement, and some algorithms support categorical features directly.

Related Questions