calc_risk_diff_iptw {riskdiff} | R Documentation |
Calculate Standardized Risk Differences Using IPTW
Description
Calculates standardized risk differences using inverse probability of treatment weighting. This approach estimates causal effects under the assumption of no unmeasured confounding by creating a pseudo-population where treatment assignment is independent of measured confounders.
Usage
calc_risk_diff_iptw(
data,
outcome,
treatment,
covariates,
iptw_weights = NULL,
weight_type = "ATE",
ps_method = "logistic",
stabilize = TRUE,
trim_weights = TRUE,
alpha = 0.05,
bootstrap_ci = FALSE,
boot_n = 1000,
verbose = FALSE
)
Arguments
data |
A data frame containing outcome, treatment, and covariate data |
outcome |
Character string naming the binary outcome variable |
treatment |
Character string naming the binary treatment variable |
covariates |
Character vector of covariate names for propensity score model |
iptw_weights |
Optional vector of pre-calculated IPTW weights |
weight_type |
Type of weights if calculating: "ATE", "ATT", or "ATC" (default: "ATE") |
ps_method |
Method for propensity score estimation (default: "logistic") |
stabilize |
Whether to use stabilized weights (default: TRUE) |
trim_weights |
Whether to trim extreme weights (default: TRUE) |
alpha |
Significance level for confidence intervals (default: 0.05) |
bootstrap_ci |
Whether to use bootstrap confidence intervals (default: FALSE) |
boot_n |
Number of bootstrap replicates if bootstrap_ci=TRUE (default: 1000) |
verbose |
Whether to print diagnostic information (default: FALSE) |
Details
Causal Interpretation
IPTW estimates causal effects by weighting observations to create balance on measured confounders. The estimand depends on the weight type:
-
ATE: Average treatment effect in the population
-
ATT: Average treatment effect among those who received treatment
-
ATC: Average treatment effect among those who did not receive treatment
Standard Errors
By default, uses robust (sandwich) standard errors that account for propensity score estimation uncertainty. Bootstrap confidence intervals are available as an alternative that may perform better with small samples.
Assumptions
-
No unmeasured confounding: All confounders are measured and included
-
Positivity: All subjects have non-zero probability of receiving either treatment
-
Correct model specification: Propensity score model is correctly specified
Value
A tibble of class "riskdiff_iptw_result" containing:
- treatment_var
Character. Name of treatment variable
- rd_iptw
Numeric. IPTW-standardized risk difference
- ci_lower
Numeric. Lower confidence interval bound
- ci_upper
Numeric. Upper confidence interval bound
- p_value
Numeric. P-value for test of null hypothesis
- weight_type
Character. Type of weights used
- effective_n
Numeric. Effective sample size
- risk_treated
Numeric. Risk in treated group
- risk_control
Numeric. Risk in control group
Examples
data(cachar_sample)
# Standard ATE estimation
rd_iptw <- calc_risk_diff_iptw(
data = cachar_sample,
outcome = "abnormal_screen",
treatment = "areca_nut",
covariates = c("age", "sex", "residence", "smoking")
)
print(rd_iptw)
# ATT estimation with bootstrap CI
rd_att <- calc_risk_diff_iptw(
data = cachar_sample,
outcome = "head_neck_abnormal",
treatment = "tobacco_chewing",
covariates = c("age", "sex", "residence", "areca_nut"),
weight_type = "ATT",
bootstrap_ci = TRUE,
boot_n = 500
)
print(rd_att)