Exercise

Modeling an interaction

In this exercise, you will use interactions to model the effect of gender and gastric activity on alcohol metabolism.

The alcohol data frame has been pre-loaded, and has the columns:

  • Metabol: the alcohol metabolism rate
  • Gastric: the rate of gastric alcohol dehydrogenase activity
  • Sex: the sex of the drinker (Male or Female)

In the video, we fit three models to the alcohol data:

  • one with only additive (main effect) terms : Metabol ~ Gastric + Sex
  • two models, each with interactions between gastric activity and sex

You saw that one of the models with interaction terms had a better R-squared than the additive model, suggesting that using interaction terms gives a better fit. In this exercise, you will compare the R-squared of one of the interaction models to the main-effects-only model.

Recall that the operator : designates the interaction between two variables. The operator * designates the interaction between the two variables, plus the main effects.

x*y = x + y + x:y

Instructions

100 XP
  • Write a formula that expresses Metabol as a function of Gastric and Sex with no interactions.
    • Assign the formula to the variable fmla_add and print it.
  • Write a formula that expresses Metabol as a function of the interaction between Gastric and Sex.
    • Add Gastric as a main effect, but not Sex.
    • Assign the formula to the variable fmla_interaction and print it.
  • Fit a linear model with only main effects: model_add to the data.
  • Fit a linear model with the interaction: model_interaction to the data.
  • Call summary() on both models. Which has a better R-squared?