Linear Model – How Many Parameters in a Linear Model with Interaction

categorical datainteractionmodelparameterizationregression

I have a question where I am not sure about the answer:

A linear model has the following characteristics:

*A dependent variable ($y$)

*One continuous variable ($x_l$), including a quadratic term ($x_1^2$)

*One categorical ($d$ with 3 levels) predictor variable and an interaction term ($d \times x_1$)

How many parameters, including the intercept, are associated with this
model?

So I thought about:
$y=\beta_0 + \beta_1 x_1 + \beta_2 x_1^2 + \beta_3 d$ + $\beta_4dx_1$

I thought I need 5 parameters for this model, but I was told the answer would be 7. So I guess I did the interaction wrong. So it seems to me I have to model each level of d with x1 with a single interaction. But how would I write this down and why do I need this?

Best Answer

The model has 7 parameters because of the 3-category categorical variable which will have 2 ``main effects'' parameters in the model (1 of the categories is omitted as the reference category). There will also be a parameter for the interaction between each of the levels of the categorical variable with the continuous variable:

  1. Continuous variable main effect
  2. Quadratic effect
  3. Category 1 main effect
  4. Category 2 main effect
  5. Continuous variable $\times$ category 1 interaction effect
  6. Continuous variable $\times$ category 2 interaction effect
  7. Intercept

Using your notation, the regression equation should be $$y=\beta_0 + \beta_1 x_1 + \beta_2 x_1^2 + \beta_3 d_1 + \beta_4 d_2 + \beta_5d_1x_1 + \beta_6d_2x_1$$

Related Question