Learn R Programming

bunchr (version 1.2.1)

bunch_viewer: Visualizing a histogram and potential excluded areas

Description

This function is meant to aid find excluded bins and analysis area for a bunching study. It displays a histogram with borders. Optionally, you can get the actual histogram back. This is convenient, as the kink/notch point is set as the center of a bin.

Usage

bunch_viewer(
  earnings,
  zstar = NA,
  cf_start = 10,
  cf_end = 50,
  exclude_before = 2,
  exclude_after = 20,
  binw = NA,
  trimy = TRUE,
  report = FALSE,
  title = "Count Histogram",
  varname = "Running Variable"
)

Value

A plot, the actual histogram if report is set to TRUE.

Arguments

earnings

Vector of earnings, hopefully a very large one

zstar

Place of notch/kink (critical earning point)

cf_start

Number of bins before the kink bin where counter-factual histogram should start.

cf_end

Number of bins after the kink bin where counter-factual histogram should start.

exclude_before

Number of excluded bins before the kink bin.

exclude_after

Number of excluded bins after the kink bin.

binw

Bin width.

trimy

Logical. Should the y-axis be trimmed to better show off-bunching histogram?

report

Should the function return the actual histogram?

title

Title for Plot output

varname

Name for running variable, to be desplayed in the plot

See Also

bunch

Examples

Run this code
ability_vec <- 4000 * rbeta(100000, 2, 5)
earning_vec <- sapply(ability_vec, earning_fun, 0.2, 0.1, 0.2, 0, 1000)
bunch_viewer(earning_vec, 1000, 20, 40, 2, 2, 20, trimy = TRUE, report = FALSE)

Run the code above in your browser using DataLab