Skip to contents

Computes logistic regression propensity scores, Inverse Probability of Treatment Weighting (IPTW: ATE, ATT/SMR, stabilized weights), and pre/post Standardized Mean Difference (SMD) covariate balance diagnostics for comparative effectiveness studies.

Usage

generate_propensity_weights(
  con = NULL,
  cohort_table = "cohort",
  target_id = 1L,
  comparator_id = 2L,
  covariate_cols = NULL,
  treatment_col = "cohort_definition_id",
  trim = 0.01
)

Arguments

con

Active DBI/DuckDB connection (required if cohort_table is a character table name).

cohort_table

Character table name or data.frame containing cohort subjects and covariates.

target_id

Integer identifier representing target (treated) cohort (Z = 1, default 1L).

comparator_id

Integer identifier representing comparator cohort (Z = 0, default 2L).

covariate_cols

Optional character vector of covariate column names to balance. If NULL, auto-detects all numeric columns excluding cohort identifiers.

treatment_col

Column containing group indicators (default "cohort_definition_id").

trim

Optional clipping threshold for extreme propensity scores (default 0.01).

Value

An object of class c("omop_propensity_result", "list") containing:

data

data.frame with added columns propensity_score, iptw_ate, iptw_att, and iptw_stabilized_ate.

balance

data.frame of pre- and post-weighting SMDs and means for each covariate.

coefficients

Named numeric vector of logistic regression coefficients.

max_post_smd

Numeric maximum post-weighting ATE SMD across all evaluated covariates.