Description Usage Arguments Value Examples
View source: R/combine_estimators.R
Creates a synthetic estimator by minimizing the (estimated) mean squared error of a linear combination of multiple candidate estimators.
1 2 3 4 5 6 7 8 9 10 11 12 |
ests |
one-row, p-column data frame of estimators. |
name_0 |
character value of the name of the presumed unbiased estimator, θ_0. Default is NULL, which returns results for using each candidate estimator as θ_0, one synthetic estimator for each. If |
boot_ests |
p-column matrix of bootstrap estimators corresponding to the estimators in |
cov |
p x p covariance matrix of |
print |
logical indicating whether details should be printed. Default is FALSE. |
exclude_t0 |
logical indicating whether θ_0 should be considered an external estimator (not a candidate for combining with others). Default is FALSE. |
bias_type |
method to compute the bias in the mean squard error. Default is |
ate_0 |
external value of θ_0. Default is NULL, in which case θ_0 is taken to be |
n |
sample size. Default is NULL. Needed only if |
list of three objects, including ate_res
which gives results for the synthetic estimator, b_res
which gives results for how the estimators were combined, and C
which gives the covariance matrix of the 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 | gen_mod <- generate_data(n = 100,
dgp = 'ks',
correct_outcome = FALSE,
correct_ps = TRUE)
this_data <- gen_mod$data
this_data <- 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 = B,
ate_list = ate_list,
outcome_fm = outcome_fm,
ps_fm = ps_fm,
ps_fam = ps_fam,
outcome_fam = outcome_fam))
boot_theta <- resample_thetas[[1]] %>% as.matrix
synthetic_estimator <- combine_estimators(thetahat,
boot_ests = boot_theta,
name_0 = 'ate_dr',
bias_type = 'raw_diff')
synthetic_estimator$ate_res
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.