combine_estimators: Create a synthetic estimator by combining multiple candidate...

Description Usage Arguments Value Examples

View source: R/combine_estimators.R

Description

Creates a synthetic estimator by minimizing the (estimated) mean squared error of a linear combination of multiple candidate estimators.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
combine_estimators(
  ests,
  name_0 = NULL,
  boot_ests = NULL,
  cov = NULL,
  print = FALSE,
  exclude_t0 = FALSE,
  bias_type = "raw_diff",
  ate_0 = NULL,
  n = NULL,
  ...
)

Arguments

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 ate_0 is given, then it is used as θ_0 in place of this.

boot_ests

p-column matrix of bootstrap estimators corresponding to the estimators in ests. If NULL, then cov must be supplied.

cov

p x p covariance matrix of ests. Default is NULL, but if supplied boot_ests are not needed.

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 raw_diff, which computes the bias as the raw difference between each of the candidate estimator and θ_0. Other options to compute the bias include: bootstrap which computes the bias as the difference between the mean of the bootstrap samples and the observed value of θ_0; bootstrap_all which computes the bias as the mean of the difference between the bootstrapped version of the candidate estimator and the bootstrapped version of θ_0; none which assumes no bias; shrunk which computes the bias as the raw difference divided by n.

ate_0

external value of θ_0. Default is NULL, in which case θ_0 is taken to be name_0.

n

sample size. Default is NULL. Needed only if bias_type is shrunk.

Value

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.

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

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