Learn R Programming

bunching (version 0.8.4)

fit_bunching: Fit Bunching

Description

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

Usage

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

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.

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

See Also

bunchit, prep_data_for_fit

Examples

Run this code
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

Run the code above in your browser using DataLab