Exercise

Specifying an interaction

So far you used a single parallel slopes model, which gave an OK fit for the whole dataset, then three separate models for each house age category, which gave a better fit for each individual category, but was clunky because you had three separate models to work with and explain. Ideally, you'd have a single model that had all the predictive power of the individual models.

Defining this single model is achieved through adding interactions between explanatory variables. R's formula syntax is flexible, and gives you a couple of options, depending on whether you prefer concise code that is quick to type and to read, or explicit code that describes what you are doing in detail.

taiwan_real_estate is available.

Instructions 1/2

undefined XP
  • 1

    Fit a linear regression of price_twd_msq versus n_convenience and house_age_years and their interaction, using the "times" syntax to implicitly generate the interaction.

  • 2

    Fit a linear regression of price_twd_msq versus n_convenience and house_age_years and their interaction, using the "colon" syntax to explicitly generate the interaction.