Categorical Predictors
& Dummy Variables
Learn how to include non-numeric categories in regression models by encoding them as 0/1 dummy variables.
What Is a Categorical Predictor?
In regression, most predictors are quantitative: things like price, age, or temperature. But many real-world factors are categorical: they describe group membership rather than a measurable quantity.
Why Do We Need Dummy Variables?
Regression equations like \( Y = b_0 + b_1 X \) require numbers for every predictor. To include a categorical variable, we translate each category into a numerical code using 0s and 1s.
Where You'll See This in Business
The Encoding Rule
For a categorical variable with \( k \) categories, create exactly \( k - 1 \) dummy variables. The omitted category becomes the reference group (baseline).
The Regression Model with Dummies
With a single two-category predictor (e.g., Region: East vs. West), the model is:
Nominal vs. Ordinal Categoricals
| Nominal | Ordinal | |
|---|---|---|
| Definition | Categories have no natural order | Categories have a meaningful order |
| Examples | Region, Color, Department | Education level, Rating (Low/Med/High) |
| Encoding | Always use dummy variables | Dummies or numeric codes (1, 2, 3) |
| Danger of numbers | 1, 2, 3 implies false ordering | 1, 2, 3 may imply equal spacing |
Why \( k - 1 \) and Not \( k \)?
If you include a dummy for every category, the dummies always sum to 1 for every observation. This creates perfect multicollinearity: one variable is a perfect linear combination of the others, and the regression cannot compute unique coefficients.
How to Apply Dummy Coding
Example 1: Two Categories
A company compares average monthly sales ($thousands) for stores in Urban vs. Rural locations.
Example 2: Three Categories
A retailer studies whether shipping method (Standard, Express, Overnight) affects customer satisfaction (0-100 scale). Standard is the reference group.
| Observation | \( D_{\text{Express}} \) | \( D_{\text{Overnight}} \) |
|---|---|---|
| Standard | 0 | 0 |
| Express | 1 | 0 |
| Overnight | 0 | 1 |
Example 3: Mixing Both Predictor Types
A company predicts salary from years of experience (quantitative) and degree type (Bachelor's vs. Master's, categorical).
Interpreting Dummy Coefficients
Choosing the Reference Group
The choice of reference group does not change the model's predictive power or \( R^2 \). It only changes how you read the coefficients. Common strategies:
Common Mistakes
Summary of Key Concepts
| Concept | Key Point |
|---|---|
| Categorical predictor | A variable describing group membership, not quantity |
| Dummy variable | A 0/1 variable that encodes one category |
| Number of dummies | \( k - 1 \) for \( k \) categories |
| Reference group | The omitted category: all dummies \( = 0 \) |
| Intercept \( b_0 \) | Mean of \( Y \) for the reference group |
| Dummy coefficient \( b_j \) | Difference vs. reference, holding other variables constant |
Question 1 of 5
A categorical variable has 5 categories. How many dummy variables should you create for a regression model?
Question 2 of 5
In a model \( Y = 50 + 8D_{\text{Premium}} \), where \( D_{\text{Premium}} = 1 \) for premium customers and 0 for standard, what is the predicted \( Y \) for a premium customer?
Question 3 of 5
What happens if you include a dummy variable for every category (all \( k \) dummies) in a regression?
Question 4 of 5
In the model \( \text{Sales} = 30 + 5 \cdot \text{Ads} + 15 \cdot D_{\text{Online}} \), what does the coefficient 15 represent?
Question 5 of 5
A researcher codes "Region" as North = 1, South = 2, East = 3, West = 4 and enters this single numeric variable into a regression. What is wrong with this approach?