View source: R/interaction_models.R
interaction_models | R Documentation |
This 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).
interaction_models(
data,
outcome,
exposure,
covariates = NULL,
effect_modifier,
approach = "logit",
test = c("LRT", "Wald"),
verbose = TRUE
)
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:
|
test |
Type of statistical test for model comparison. Either:
|
verbose |
Logical; if |
A list with the following elements:
model_no_interaction
: The model without the interaction term.
model_with_interaction
: The model with the interaction term.
p_value
: The p-value for interaction (based on selected test).
interpretation
: A brief text interpretation if
verbose = TRUE
.
data <- data_PimaIndiansDiabetes
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.