Compare Models With and Without Interaction Term
Source:R/interaction_models.R
interaction_models.RdThis function fits two models—one with and one without an interaction term between an exposure and a potential effect modifier— and compares them using either a likelihood ratio test (LRT) or Wald test. It is useful for assessing whether there is statistical evidence of interaction (effect modification).
Usage
interaction_models(
data,
outcome,
exposure,
covariates = NULL,
effect_modifier,
approach = "logit",
test = c("LRT", "Wald"),
verbose = TRUE
)Arguments
- data
A data frame containing all required variables.
- outcome
The name of the outcome variable
- exposure
The name of the main exposure variable.
- covariates
character vector of additional covariates to adjust for
- effect_modifier
The name of the variable to test for interaction
- approach
The regression modeling approach to use. One of:
"logit","log-binomial","poisson","robpoisson","negbin", or"linear".- test
Type of statistical test for model comparison. Either:
"LRT"(likelihood ratio test, default) or"Wald".- verbose
Logical; if
TRUE, prints a basic interpretation of whether interaction is likely present (default =FALSE).