synthetic_subset: Compute synthetic estimator on a subset of candidate...

Description Usage Arguments Value Examples

View source: R/synthetic_subset.R

Description

This function allows you to compute a set of candidate estimators and bootstrap estimates once and then compute on it many times. It's designed to work well with map2.

Usage

1
synthetic_subset(theta, boot, estimators = NULL, ...)

Arguments

theta

one-row data frame of candidate estimators.

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 combine_estimators.

Value

vector of synthetic estimators

Examples

 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')))
    
    

denisagniel/synthate documentation built on April 16, 2020, 12:45 a.m.