I have a logistic model with plenty of interactions in R.
I want to extract only the variables and interactions that are either interactions or just predictor variables that are significant.
It's fine if I can just look at every interaction that's significant as I can still look at which non-significant fields were used to get them.
Thank you.
This is the most I have
broom::tidy(logmod)[,c("term", "estimate", "p.value")]
Here is a way. After fitting the logistic model use a logical condition to get the significant predictors and a regex (logical
grep
) to get the interactions. These two index vectors can be combined with&
, in the case below returning no significant interactions at thealpha == 0.05
level.Created on 2022-09-15 with reprex v2.0.2