calc_risk_diff_iptw | R Documentation |
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.
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
)
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) |
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
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.
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
A tibble of class "riskdiff_iptw_result" containing:
Character. Name of treatment variable
Numeric. IPTW-standardized risk difference
Numeric. Lower confidence interval bound
Numeric. Upper confidence interval bound
Numeric. P-value for test of null hypothesis
Character. Type of weights used
Numeric. Effective sample size
Numeric. Risk in treated group
Numeric. Risk in control group
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.