do_correction: Integration Constraint Correction

Description Usage Arguments Value See Also Examples

View source: R/do_correction.R

Description

Implements the correction for the integration constraint.

Usage

1
2
do_correction(zstar, binwidth, data_prepped, firstpass_results,
  correct_iter_max = 200, notch = FALSE, zD_bin = NA)

Arguments

zstar

a numeric value for the the bunching point.

binwidth

a numeric value for the width of each bin.

data_prepped

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

firstpass_results

initial bunching estimates without correction.

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

Value

do_correction returns a list with the data and estimates after correcting for the integration constraint, as follows:

data

The dataset with the corrected counterfactual.

coefficients

The coefficients of the model fit on the corrected data.

b_corrected

The normalized excess mass, corrected for the integration constraint.

B_corrected

The excess mass (not normalized), corrected for the integration constraint.

c0_corrected

The counterfactual at zstar, corrected for the integration constraint.

marginal_buncher_corrected

The location (z value) of the marginal buncher, corrected for the integration constraint.

alpha_corrected

The estimated fraction of bunchers in the dominated region, corrected for the integration constraint (only in notch case).

See Also

bunchit, fit_bunching

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)
corrected <- do_correction(zstar = 10000, binwidth = 50,
                           data_prepped = prepped_data$data_binned,
                           firstpass_results = firstpass)
paste0("Without correction, b = ", firstpass$b_estimate)
paste0("With correction, b = ", round(corrected$b_corrected,3))

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