Dummy coding represents a categorical variable as separate binary variables, marking each category with 1 when present and 0 when absent. This lets linear models incorporate categorical data as predictors. section 9.2.1
Use dummy coding thoughtfully when preparing categorical predictors:
- Encode each day of the week as its own indicator when category-specific effects matter. section 9.2.1
- Usually omit one category, such as Sunday; all-zero indicators imply the omitted reference category. section 9.2.1
- Replace detailed categories with a meaningful binary variable when grouped behavior better represents the prediction problem. section 9.2.1
Rat sightings by weekday
A model predicting daily New York City rat sightings can encode day of week with indicators, or use a single weekday variable equal to 1 for Monday through Friday and 0 otherwise. Correlation checks can help assess its relationship with sightings and other predictors. section 9.2.1
Figure 9.24 Dummy-coded variables for each day of the week. The final set of variables for a model will often exclude the last category, which is implied when all other categories are absent.
Inspect the day-of-week indicator layout and the omitted-category convention. section 9.2.1
