Categorical Predictors and Interactions in Logistic Models
What you'll learn: How to incorporate categorical variables and interaction terms into logistic regression models to capture richer relationships in binary outcomes.
The Core Idea
Just as you've learned in multiple linear regression, logistic regression can include categorical predictors through dummy variable encoding and interaction terms to model non-additive effects. The difference is that now you're modeling the log-odds of a binary outcome rather than a continuous response.
When you include a categorical predictor (like treatment_group), you create dummy variables with a reference category, and each coefficient represents the change in log-odds compared to that baseline. For example, if treatment = 1 has a coefficient of 0.8, it means being in the treatment group increases the log-odds by 0.8 (or multiplies the odds by e^0.8 ≈ 2.23).
Interactions in Logistic Regression
Interaction terms work the same way conceptually as in linear models, but their interpretation involves log-odds. A categorical × continuous interaction lets the effect of a continuous predictor differ across groups. For instance, you might model whether age affects heart disease risk differently for males vs. females.
A categorical × categorical interaction captures whether the combined effect of two categories differs from their individual additive effects—like whether a specific treatment works differently depending on disease severity level.
The coefficients still represent changes in log-odds, but now they're conditional on the other variable in the interaction.
When to Use Them
Use categorical predictors when group membership matters for your binary outcome. Add interactions when you suspect the relationship between predictors and outcome isn't simply additive—when one variable modifies how another affects the response.
Key Takeaway: Categorical predictors and interactions in logistic regression extend your inferential toolkit to model complex, group-specific relationships with binary outcomes, with all coefficients interpreted on the log-odds scale.