Identify Confounders Using the Change-in-Estimate Method
Source:R/identify_confounder.R
identify_confounder.Rd
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
Usage
identify_confounder(
data,
outcome,
exposure,
potential_confounder,
approach = "logit",
threshold = 10
)
Arguments
- 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:
"logit"
,"log-binomial"
,"poisson"
,"negbin"
,"robpoisson"
, or"linear"
.- threshold
Numeric. Percent change threshold to define confounding (default = 10). If the absolute percent change exceeds this, the variable is flagged as a confounder.
Value
If one confounder is provided, prints crude and adjusted estimates with a confounding flag. If multiple are given, returns a tibble with:
- covariate
Name of potential confounder.
- crude_est
Crude effect estimate.
- adjusted_est
Adjusted estimate including the confounder.
- pct_change
Percent change from crude to adjusted.
- is_confounder
Logical: whether confounding threshold is exceeded.
Details
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.
Examples
data <- data_PimaIndiansDiabetes
identify_confounder(
data = data,
outcome = "glucose",
exposure = "insulin",
potential_confounder = "age_cat",
approach = "linear"
)
#>
#> ------------------------------------------------------------
#> Crude Estimate: 0.151
#> Adjusted Estimate: NA
#> % Change from Crude: NA%
#> ------------------------------------------------------------
#> Confounding: NA
#> ------------------------------------------------------------
#> Notes:
#> * Confounding is suggested if percent change >=10%.
#> * This method does not assess effect modification.
#> * Use DAGs or domain knowledge to support confounder identification.