Skip to contents

Draw repeated resamples of the original data keeping the running-variable distribution fixed and re-estimate the sharp or fuzzy RDD bounds for each user-specified manipulation region.

Usage

bootstrap_bounds(
  data,
  running_var,
  outcome,
  treatment = NULL,
  cutoff,
  manip_regions,
  estimator = c("fuzzy", "sharp"),
  n_boot = 200L,
  poly_order = 1L,
  weight_var = NULL,
  density_args = list(),
  ci_level = 0.95,
  parallel = FALSE,
  n_cores = NULL,
  progress = TRUE,
  seed = NULL
)

Arguments

data

A data.frame that contains the running variable, outcome and- for fuzzy designs-the treatment column.

running_var, outcome

Character names of the running variable and outcome columns.

treatment

Character name of the treatment take-up column (0/1). Required when estimator = "fuzzy".

cutoff

Numeric RDD threshold.

manip_regions

List of numeric length-2 vectors (lower, upper) giving suspected manipulation intervals.

estimator

Either "fuzzy" (default) or "sharp".

n_boot

Integer number of bootstrap replications (default 200).

poly_order

Local polynomial order (default 1).

weight_var

Optional character column in data holding non-negative observation weights. If NULL, each row receives weight 1.

density_args

Optional named list forwarded to .density_estimation().

ci_level

Percentile coverage of the bootstrap interval (default 0.95).

parallel

Logical. If TRUE, uses parallel::mclapply() on non-Windows systems.

n_cores

Number of cores for parallel execution (defaults to parallel::detectCores() - 1).

progress

Logical - print a progress bar (default TRUE). Progress is suppressed automatically when running in parallel to avoid garbled output.

seed

Optional integer for reproducibility of resampling.

Value

An object of class rdpartial_boot - a list with elements

  • boot_array - 3-D array (n_boot, R, 2) storing lower/upper bounds.

  • ci - R × 2 matrix of percentile intervals (lwr, upr).

  • manip_regions, estimator, call - metadata for downstream methods.

Details

This function is a high-level wrapper around three internal work-horses:

Examples

set.seed(101)
n <- 3000; cutoff <- 16
x <- rpois(n, 15)
z <- rbinom(n, 1, prob = ifelse(x >= cutoff, 0.7, 0.2))
y <- 0.2 * x + 3 * z + rnorm(n)
dat <- data.frame(x = x, y = y, z = z)

res <- bootstrap_bounds(dat, running_var = "x", outcome = "y",
                        treatment = "z", cutoff = cutoff,
                        manip_regions = list(c(cutoff - 0.3, cutoff)),
                        n_boot = 50, parallel = FALSE)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=                                                                     |   2%
  |                                                                            
  |===                                                                   |   4%
  |                                                                            
  |====                                                                  |   6%
  |                                                                            
  |======                                                                |   8%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |========                                                              |  12%
  |                                                                            
  |==========                                                            |  14%
  |                                                                            
  |===========                                                           |  16%
  |                                                                            
  |=============                                                         |  18%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |==================                                                    |  26%
  |                                                                            
  |====================                                                  |  28%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |======================                                                |  32%
  |                                                                            
  |========================                                              |  34%
  |                                                                            
  |=========================                                             |  36%
  |                                                                            
  |===========================                                           |  38%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |=============================                                         |  42%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |================================                                      |  46%
  |                                                                            
  |==================================                                    |  48%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================                                  |  52%
  |                                                                            
  |======================================                                |  54%
  |                                                                            
  |=======================================                               |  56%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |===========================================                           |  62%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |==============================================                        |  66%
  |                                                                            
  |================================================                      |  68%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |==================================================                    |  72%
  |                                                                            
  |====================================================                  |  74%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |=======================================================               |  78%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |=========================================================             |  82%
  |                                                                            
  |===========================================================           |  84%
  |                                                                            
  |============================================================          |  86%
  |                                                                            
  |==============================================================        |  88%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |================================================================      |  92%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |===================================================================   |  96%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |======================================================================| 100%
res$ci
#>              lwr      upr
#> region1 2.837978 3.260979
#> attr(,"level")
#> [1] 0.95