Topics Covered
Continuous + Categorical Predictors
Fit models like body_mass_g ~ flipper_length_mm + sex and interpret partial effects while controlling for the other predictor.
Two Categorical Predictors
Model mean differences with body_mass_g ~ species + sex, understand reference levels, and read dummy-coded coefficients.
Additive vs Interaction Models
Use anova() to test whether we need interaction terms like species * sex or flipper_length_mm * sex.
Scripts
mr_cont_cat.R
Tutorial for continuous outcome with one continuous predictor and one categorical predictor, including model comparison and adjusted predictions.
mr_two_cat.R
Tutorial for continuous outcome with two categorical predictors, including additive vs interaction models and predicted cell means.
mr_interact.R
Dedicated interaction-effects tutorial covering continuous * categorical and categorical * categorical models with nested comparisons.
Key Concepts
- Partial regression coefficients: each term is interpreted while holding other predictors constant.
- Reference levels in factors: the intercept and factor coefficients are always relative to a baseline category.
- Additive models vs interaction models: interaction terms test whether one predictor's effect changes across groups.
- Nested model comparison with
anova(): checks if extra terms provide a meaningful fit improvement.
Homework
- Run
mr_cont_cat.Rand explain the coefficients forflipper_length_mmandsexmale. - Use
anova()to compare additive and interaction models in both scripts. Report which model is preferred and why. - Run
mr_two_cat.Rand interpret one species coefficient and one interaction coefficient in plain language.