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).


closed as off-topic by Scortchi Jun 14 '17 at 16:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Scortchi
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Why not just create two separate variables that are equal to the interactions you want, and use those? $\endgroup$ – Bridgeburners Jun 14 '17 at 16:26
  • 1
    $\begingroup$ Welcome to Cross Validated! See ?formula & stats.stackexchange.com/q/133959/17230. $\endgroup$ – Scortchi Jun 14 '17 at 16:33
  • $\begingroup$ I agree with what @Scortchi points you to in the link to this question. 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. $\endgroup$ – EdM Jun 14 '17 at 16:38

(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).


Not the answer you're looking for? Browse other questions tagged or ask your own question.