View source: R/summary_functions.R
summarize_sensitivity | R Documentation |
Returns a data.frame or Kable table with summary measures of sensitivity
summarize_sensitivity(
weights = NULL,
Y = NULL,
Z = NULL,
b_star = 0,
estimate = NULL,
SE = NULL,
unweighted = NULL,
sigma2 = NULL,
estimand = "ATT",
pretty = FALSE,
svy_srs = NULL,
svy_wt = NULL,
sig.fig = 2
)
weights |
Vector of estimated weights |
Y |
Outcome of interest |
Z |
Treatment assignment (Not needed for settings when users are analyzing surveys) |
b_star |
Killer confounder threshold. If not specified, will be automatically set to 0. |
estimate |
(Optional) Weighted point estimate. If not specified, function will automatically generate the weighted estimator, given the inputs in |
SE |
(Optional) Standard error associated with the weighted point estimate |
unweighted |
(Optional) Unweighted point estimate. |
sigma2 |
(Optional) Variance of outcomes or individual-level treatment effect in PATE case. In the case of a PATE estimator, if not specified, function will automatically estimate an upper bound for the variance of the individual-level treatment effect. |
estimand |
Specifies estimand; possible parameters include "ATT", "PATE", or "Survey" |
pretty |
If set to |
svy_srs |
Unweighted |
svy_wt |
Weighted |
sig.fig |
Significant figures to round the output to (default set to 2) |
Sensitivity summary
data(jtpa_women)
site_name <- "NE"
df_site <- jtpa_women[which(jtpa_women$site == site_name), ]
df_else <- jtpa_women[which(jtpa_women$site != site_name), ]
# Estimate unweighted estimator:
model_dim <- estimatr::lm_robust(Y ~ T, data = df_site)
PATE <- coef(lm(Y ~ T, data = df_else))[2]
DiM <- coef(model_dim)[2]
# Generate weights using observed covariates:
df_all <- jtpa_women
df_all$S <- ifelse(jtpa_women$site == "NE", 1, 0)
model_ps <- WeightIt::weightit(
(1 - S) ~ . - site - T - Y,
data = df_all, method = "ebal", estimand = "ATT"
)
weights <- model_ps$weights[df_all$S == 1]
# Estimate IPW model:
model_ipw <- estimatr::lm_robust(Y ~ T, data = df_site, weights = weights)
ipw <- coef(model_ipw)[2]
# Estimate bound for var(tau):
vartau <- var(df_site$Y[df_site$T == 1]) - var(df_site$Y[df_site$T == 0])
summarize_sensitivity(weights = weights,
Y = df_site$Y,
Z = df_site$T,
sigma2 = vartau,
estimand = "PATE")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.