Solution (source code)

= Solution

Include both main effects and their <interaction term>:

``
fit_interaction <- lm(testosterone ~ weight * sex, data = mice)
``

Here `mice` denotes the data frame containing the named variables. In this R formula, `weight * sex` expands to `weight + sex + weight:sex`; it does not omit the main effects.