identify_confounder: Identify Confounders Using the Change-in-Estimate Method

View source: R/identify_confounder.R

identify_confounderR Documentation

Identify Confounders Using the Change-in-Estimate Method

Description

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.

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.

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.

See Also

[check_convergence()], [interaction_models()]

Examples

data <- data_PimaIndiansDiabetes
identify_confounder(
  data = data,
  outcome = "glucose",
  exposure = "insulin",
  potential_confounder = "age_cat",
  approach = "linear"
)


gtregression documentation built on Aug. 18, 2025, 5:23 p.m.