fit_bunching: Fit Bunching

Description Usage Arguments Value See Also Examples

View source: R/fit_bunching.R

Description

Fit bunching model to (binned) data and estimate excess mass.

Usage

1
fit_bunching(thedata, themodelformula, notch = FALSE, zD_bin = NA)

Arguments

thedata

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

themodelformula

formula to fit.

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

fit_bunching returns a list of the following results:

coefficients

The coefficients from the fitted model.

residuals

The residuals from the fitted model.

cf_density

The estimated counterfactual density.

bunchers_excess

The estimate of the excess mass (not normalized).

cf_bunchers

The counterfactual estimate of counts in the bunching region.

b_estimate

The estimate of the normalized excess mass.

bins_bunchers

The number of bins in the bunching region.

model_formula

The model formula used for fitting.

B_zl_zstar

The count of bunchers in the bunching region below and up to zstar.

B_zstar_zu

The count of bunchers in the bunching region above zstar.

alpha

The estimated fraction of bunchers in the dominated region (only in notch case.)

zD_bin

The value of the bin which zD falls in.

See Also

bunchit, prep_data_for_fit

Examples

1
2
3
4
5
6
7
8
9
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)
fitted <- fit_bunching(thedata = prepped_data$data_binned,
                       themodelformula = prepped_data$model_formula)
# extract coefficients
fitted$coefficients

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