View source: R/identify_confounder.R
identify_confounder | R Documentation |
Identifies whether one or more variables are confounders by comparing the crude and adjusted effect estimates of a primary exposure on an outcome. A variable is flagged as a confounder if its inclusion changes the estimate by more than a specified threshold (default = 10
identify_confounder(
data,
outcome,
exposure,
potential_confounder,
approach = "logit",
threshold = 10
)
data |
A data frame containing the variables. |
outcome |
The name of the outcome variable (character string). |
exposure |
The primary exposure variable (character string). |
potential_confounder |
One or more variables to test as potential confounders. |
approach |
The regression modeling approach. One of:
|
threshold |
Numeric. Percent change threshold to define confounding (default = 10). If the absolute percent change exceeds this, the variable is flagged as a confounder. |
Supports logistic, log-binomial, Poisson, robust Poisson, negative binomial, and linear regression approaches.
This method does not evaluate effect modification. Use causal diagrams (e.g., DAGs) and subject-matter knowledge to supplement decisions.
If one confounder is provided, prints crude and adjusted estimates with a confounding flag. If multiple are given, returns a tibble with:
Name of potential confounder.
Crude effect estimate.
Adjusted estimate including the confounder.
Percent change from crude to adjusted.
Logical: whether confounding threshold is exceeded.
[check_convergence()], [interaction_models()]
data <- data_PimaIndiansDiabetes
identify_confounder(
data = data,
outcome = "glucose",
exposure = "insulin",
potential_confounder = "age_cat",
approach = "linear"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.