1

I am running a logistic regression model with 5 predictor variables. I would like to include an interaction term in this model. However, when I use the formula:

glm(Indroad~A+B+C+D+E + (A*B*C*D*), family=binomial(link="logit"), data=sub.data) 

or the formula:

glm(Indroad ~ A*B*C*D*E, family=binomial(link="logit"), data=sub.data) 

I am given an output that includes all possible combinations for the interaction term (e.g., A:B, A:C). I am really only interested in the terms A:B:C and A:B:C:D:E.

Is there anyway to limit the interactions that R runs? I have tried without success to use the update command, and have tried to run the same formula with - unwanted interaction terms (both without success).

gung - Reinstate Monica
  • 132,789
  • 81
  • 357
  • 650
Kris
  • 11
  • 2
  • Why not just create two separate variables that are equal to the interactions you want, and use those? – Bridgeburners Jun 14 '17 at 16:26
  • 1
    Welcome to Cross Validated! See `?formula` & https://stats.stackexchange.com/q/133959/17230. – Scortchi - Reinstate Monica Jun 14 '17 at 16:33
  • I agree with what @Scortchi points you to in the link to [this question](https://stats.stackexchange.com/q/133959/28500). Please consider whether you should be looking at these high-order interactions without considering the lower-order interactions. That's an important statistical (as opposed to coding) issue. – EdM Jun 14 '17 at 16:38

1 Answers1

4

(This is mostly a question about how to use R, and thus off topic here.)

In R, if you use * in a formula, it will automatically insert all interaction terms and main effect terms below the interaction you specify. To specify a only specific interaction term, you need to use : (see here). That is,

glm(Indroad~A+B+C+D+E + A:B:C + A:B:C:D:E, family=binomial(link="logit"), data=sub.data)

That said, the statistical issue here is that you almost certainly should not include an interaction term (A:B:C:D:E) without including the lower level terms beneath it in the hierarchy. For more on this, see Including the interaction but not the main effects in a model (of which this is really a duplicate).

gung - Reinstate Monica
  • 132,789
  • 81
  • 357
  • 650