Description Usage Arguments Value Examples
View source: R/synthetic_split_subset.R
This function allows you to compute a set of split-sample candidate estimators and bootstrap estimates once and then compute on it many times. It's designed to work well with map2
.
1 2 | synthetic_split_subset(thetahat_a, thetahat_b, boot, estimators = NULL,
...)
|
thetahat_a |
one-row data frame of candidate estimators fit on one half of the sample. |
thetahat_b |
one-row data frame of candidate estimators fit on the other half of the sample. |
boot |
data frame of bootstrapped versions of candidate estimators. |
estimators |
vector of estimator names to be included in synthetic estimator; if NULL (the default) all estimators are used. |
... |
additional arguments to be passed to |
vector of synthetic estimators
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ate_list <- list(
ipw1 = ipw1_ate,
ipw2 = ipw2_ate,
ipw3 = ipw3_ate,
strat = strat_ate,
strat_regr = strat_regr_ate,
match_ps = match_ps_ate,
match_prog = match_prog_ate,
match_both = match_both_ate,
cal_ps = caliper_ps_ate,
cal_both = caliper_both_ate,
regr = regr_ate,
dr = dr_ate,
bal = bal_ate,
hdbal = highdim_bal_ate
)
gen_mod <- generate_data(n = 100,
dgp = 'ks',
correct_outcome = FALSE,
correct_ps = TRUE)
this_data <- gen_mod$data
this_data <- with(gen_mod, estimate_scores(this_data, outcome_fm = outcome_fm,
ps_fm = ps_fm,
ps_fam = ps_fam,
outcome_fam = outcome_fam))
thetahat <- with(gen_mod,
estimate_ates(this_data,
ate_list,
cov_ids = cov_ids,
outcome_fm = stringr::str_c('d + ', outcome_fm),
outcome_fam = outcome_fam))
predict_delta <- function(d) {
gen_mod$true_ate
}
resample_thetas <- with(gen_mod, resample_fn(dat = this_data,
dpredfn = predict_delta,
B = 50,
ate_list = ate_list,
outcome_fm = outcome_fm,
ps_fm = ps_fm,
ps_fam = ps_fam,
outcome_fam = outcome_fam,
cov_ids = cov_ids))
boot_theta <- resample_thetas[[1]]
synthetic_subset(thetahat, boot_theta,
estimators = c('ate_regr', 'ate_ipw_2', 'ate_dr', 'ate_bal'),
name_0 = 'ate_dr')
synthetic_subset(thetahat, boot_theta,
estimators = c('ate_regr', 'ate_ipw_2', 'ate_dr', 'match_ps'),
ate_0 = thetahat$ate_bal,
name_0 = 'ate_dr')
out_df <- tibble::tibble(
thetahat = list(thetahat),
boot_theta = list(boot_theta))
##
dplyr::mutate(out_df,
theta_s = unlist(purrr::map2(
thetahat,
boot_theta,
synthetic_subset,
estimators = c('ate_regr', 'ate_ipw_2', 'ate_dr', 'ate_bal'),
name_0 = 'ate_dr')))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.