Statistics Glossary → Dummy (indicator) variable coding
Dummy (indicator) variable codingconcept
A way of entering a categorical variable with k levels into a regression model as k - 1 zero/one variables, each representing one level.
Regression models work with numeric inputs. Using a code such as 'region = 1, 2, 3' directly as a number assumes the regions are ordered at equal intervals, which is usually meaningless. In dummy coding one level is chosen as the reference (baseline) level, and for every other level a variable is created that answers 'is this observation at that level?' with 1 or 0. A variable with k levels thus becomes k - 1 dummy variables.
Each dummy's coefficient gives the difference between that level and the reference level (a difference in log-odds or log-hazard in logistic and Cox models). Putting all k dummies into a model that has an intercept creates perfect multicollinearity, the 'dummy variable trap'. The choice of reference level does not change the model's fit, only what the coefficients are compared against, so choosing a meaningful baseline (such as a control group) makes interpretation easier. Alternative schemes such as deviation (effect) coding express the coefficients relative to the grand mean.
An everyday example
A property website models rent by district: Centre, North and South. With Centre as the reference, two dummies are created: 'is it North?' and 'is it South?'. If the North coefficient is -1,500 lira, a flat in the North rents for 1,500 lira less on average than an otherwise identical flat in the Centre.
In MerQur
In Multiple Linear, Logistic, Poisson / Negative Binomial, Multinomial and Ordinal regression, Instrumental Variables Regression and Probit, the 'Categorical (factor) variables' field, and in Ridge and Lasso the 'Categorical predictors' field, expand numerically coded columns into dummy variables; text columns are expanded automatically. In Multiple Linear and Logistic Regression, 'Reference category (factors)' chooses the omitted level (first or last). In Cox Regression and Time-Dependent Cox, 'Categorical coding' offers indicator coding (first or last level as reference) or deviation coding; the parameter-estimates table of Two-Way ANOVA and ANCOVA uses indicator coding with the last level as the comparison level.
Analyses where this concept appears
Two-Way ANOVAANCOVAMeta-AnalysisMultiple Linear RegressionLogistic RegressionPoisson / Negative Binomial Regression (Count Regression)Multinomial Logistic RegressionOrdinal Logistic RegressionRidge RegressionLasso RegressionInstrumental Variables Regression (2SLS)Difference-in-Differences (DiD)Decision Tree (CART)Weighted Linear Regression (Survey Regression)Weighted Logistic Regression (Survey Logistic Regression)Variance Components Analysis (VARCOMP)Generalized Additive Model (GAM, Nonlinear Regression)Robust Regression (M-estimator)Quantile RegressionProbit RegressionConditional Logit (Choice Model)Bayesian Linear RegressionHierarchical Bayesian RegressionMediation AnalysisCox Regression (Proportional Hazards Model)Parametric Survival (AFT)Competing RisksTime-dependent Cox RegressionSurvey-PHREG (Weighted Cox)Interval-Censored SurvivalCointegration (Johansen / Engle-Granger)Response Surface Regression (RSREG)Unobserved Components Model (Structural Time Series)Sample Selection and Truncated Regression (Heckman)
Related concepts
Reference category (comparison level)Deviation (effect) coding