Track 9 · Correlation and Regression · Lesson 10 of 15

Categorical predictors

Include categorical variables in a regression with dummy coding, interpret each coefficient against the reference level, and recognise when an interaction is needed.

40 minAdvanced8 graded exercisesMembers

A pay-equity review asks how salaries differ between men and women, and between departments, once job level is taken into account. Gender, department and job level are categories, not numbers — yet they belong in the same regression as years of experience. Dummy variables make that possible, and reading them correctly is essential to an honest pay analysis.

A regression needs numbers, so a categorical variable with LL levels is represented by L−1L - 1 dummy (indicator) variables, each equal to 1 for one level and 0 otherwise. The level without a dummy is the reference level (baseline). Its average is absorbed into the intercept, and every dummy coefficient is a difference from the reference.

Included with a Formula Quest membership

It has 8 graded exercises with feedback, hints and worked solutions. After it you will be able to:

  • Represent a categorical variable with L − 1 dummy variables and avoid the dummy-variable trap
  • Interpret dummy coefficients as differences from the reference level, and change the reference
  • Explain why an adjusted pay gap depends on the controls chosen, and how adjusting for a possible mediator such as job level changes the comparison
  • Use an interaction to let a slope differ between groups, and read the group-specific slopes