do_bootstrap: Bootstrap

Description Usage Arguments Value See Also Examples

View source: R/do_bootstrap.R

Description

Estimate bunching on bootstrapped samples, using residual-based bootstrapping with replacement.

Usage

1
2
3
do_bootstrap(zstar, binwidth, firstpass_prep, residuals, n_boot = 100,
  correct = TRUE, correct_iter_max = 200, notch = FALSE,
  zD_bin = NA, seed = NA)

Arguments

zstar

a numeric value for the the bunching point.

binwidth

a numeric value for the width of each bin.

firstpass_prep

(binned) data that includes all variables necessary for fitting the model.

residuals

residuals from (first pass) fitted bunching model.

n_boot

number of bootstrapped iterations. Default is 100.

correct

implements correction for integration constraint. Default is TRUE.

correct_iter_max

maximum iterations for integration constraint correction. Default is 200.

notch

whether analysis is for a kink or notch. Default is FALSE (kink).

zD_bin

the bin marking the upper end of the dominated region (notch case).

seed

a numeric value for bootstrap seed (random re-sampling of residuals). Default is NA.

Value

do_bootstrap returns a list with the following bootstrapped estimates:

b_vector

A vector with the bootstrapped normalized excess mass estimates.

b_sd

The standard deviation of the bootstrapped b_vector.

B_vector

A vector with the bootstrapped excess mass estimates (not normalized).

B_sd

The standard deviation of the bootstrapped B_vector.

marginal_buncher_vector

A vector with the bootstrapped estimates of the location (z value) of the marginal buncher.

marginal_buncher_sd

The standard deviation of the bootstrapped marginal_buncher_vector.

alpha_vector

A vector with the bootstrapped estimates of the fraction of bunchers in the dominated region (only in notch case).

alpha_vector_sd

The standard deviation of the bootstrapped alpha_vector.

See Also

bunchit, prep_data_for_fit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(bunching_data)
binned_data <- bin_data(z_vector = bunching_data$kink, zstar = 10000,
                        binwidth = 50, bins_l = 20, bins_r = 20)
prepped_data <- prep_data_for_fit(binned_data, zstar = 10000, binwidth = 50,
                                  bins_l = 20, bins_r = 20, poly = 4)
firstpass <- fit_bunching(prepped_data$data_binned, prepped_data$model_formula)
residuals_for_boot <- fit_bunching(prepped_data$data_binned,
                                   prepped_data$model_formula)$residuals
boot_results <- do_bootstrap(zstar = 10000, binwidth = 50,
                             firstpass_prep = prepped_data,
                             residuals = residuals_for_boot,
                             seed = 1)
boot_results$b_sd

bunching documentation built on Sept. 23, 2019, 5:04 p.m.