Skip to contents

Binned scatter + global-polynomial data for an RD plot

Usage

morie_rdd_plot_data(
  data,
  outcome,
  running,
  cutoff = 0,
  n_bins = 20,
  p_global = 4,
  p_local = 1,
  bandwidth = NULL,
  kernel = "triangular"
)

Arguments

data

A data.frame holding the outcome, running variable, treatment, and any covariates referenced by name.

outcome

Character; column name of the response variable in data.

running

Character; column name of the running (forcing) variable in data.

cutoff

Numeric scalar; the threshold on running. Default 0 (the canonical normalisation).

n_bins

Integer; bin count for histogram-based density tests and binned-plot reductions.

p_global

Integer; polynomial order for the global component of morie_rdd_plot_data.

p_local

Integer; polynomial order for the local component of morie_rdd_plot_data.

bandwidth

Numeric; the local-polynomial bandwidth on each side of the cutoff. NULL invokes the data-driven CCT selector.

kernel

One of "triangular" (default), "epanechnikov", "uniform", or "gaussian".

Value

A named list (see Details).

Examples

set.seed(1)
x <- runif(300, -1, 1)
y <- 0.3 * x + 1.0 * (x >= 0) + rnorm(300, sd = 0.3)
d <- data.frame(x, y)
out <- morie_rdd_plot_data(d, "y", "x", n_bins = 10L)
head(out$bins)
#>                bin      mean_y      mean_x
#> 1  [-0.974,-0.742] -0.20735910 -0.84756241
#> 2  (-0.742,-0.576] -0.14198916 -0.66404345
#> 3  (-0.576,-0.392] -0.15056299 -0.49009693
#> 4  (-0.392,-0.229] -0.01029953 -0.30968607
#> 5 (-0.229,-0.0451] -0.12653448 -0.13572595
#> 6  (-0.0451,0.123]  0.70380443  0.02573288