rdwinselect: Window selection for RD designs under local randomization

View source: R/rdwinselect.R

rdwinselectR Documentation

Window selection for RD designs under local randomization

Description

rdwinselect implements a window-selection procedure based on balance tests for RD designs under local randomization. Specifically, it constructs a sequence of nested windows around the RD cutoff and reports binomial tests for the running variable and covariate balance tests for the covariates (if specified). The recommended window is the largest window around the cutoff such that the minimum p-value from the balance tests is larger than a prespecified level for all nested (smaller) windows. By default, the p-values are calculated using randomization inference methods.

Usage

rdwinselect(
  R,
  X,
  cutoff = 0,
  obsmin = NULL,
  wmin = NULL,
  wobs = NULL,
  wstep = NULL,
  wasymmetric = FALSE,
  wmasspoints = FALSE,
  dropmissing = FALSE,
  nwindows = 10,
  statistic = "diffmeans",
  p = 0,
  evalat = "cutoff",
  kernel = "uniform",
  approx = FALSE,
  level = 0.15,
  reps = 1000,
  seed = 666,
  plot = FALSE,
  quietly = FALSE,
  obsstep = NULL
)

Arguments

R

a vector containing the values of the running variable.

X

the matrix of covariates to be used in the balance tests. The matrix is optional, but the recommended window is only provided when at least one covariate is specified. This should be a matrix of size n x k where n is the total sample size and k is the number of covariates.

cutoff

the RD cutoff (default is 0).

obsmin

the minimum number of observations above and below the cutoff in the smallest window. Default is 10.

wmin

the smallest window to be used.

wobs

the number of observations to be added on each side of the cutoff at each step. Default is 5.

wstep

the increment in window length.

wasymmetric

allows for asymmetric windows around the cutoff when wobs is specified.

wmasspoints

specifies that the running variable is discrete and each masspoint should be used as a window.

dropmissing

drop rows with missing values in covariates when calculating windows.

nwindows

the number of windows to be used. Default is 10.

statistic

the statistic to be used in the balance tests. Allowed options are diffmeans (difference in means statistic), ksmirnov (Kolmogorov-Smirnov statistic), ranksum (Wilcoxon-Mann-Whitney standardized statistic) and hotelling (Hotelling's T-squared statistic). Default option is diffmeans. The statistic ttest is equivalent to diffmeans and included for backward compatibility.

p

the order of the polynomial for the outcome adjustment model (for covariates). Default is 0.

evalat

specifies the point at which the adjusted variable is evaluated. Allowed options are cutoff and means. Default is cutoff.

kernel

specifies the type of kernel to use as a weighting scheme. Allowed kernel types are uniform (uniform kernel), triangular (triangular kernel), and epan (Epanechnikov kernel). Default is uniform.

approx

forces the command to conduct the covariate balance tests using a large-sample approximation instead of finite-sample exact randomization inference methods.

level

the minimum accepted value of the p-value from the covariate balance tests. Default is .15.

reps

the number of replications. Default is 1000.

seed

the seed to be used for the randomization tests.

plot

draws a scatter plot of the minimum p-value from the covariate balance test against window length.

quietly

suppresses output.

obsstep

the minimum number of observations to be added on each side of the cutoff for the sequence of fixed-increment nested windows. This option is deprecated and only included for backward compatibility.

Value

A list containing:

w_left

left endpoint of the recommended window.

w_right

right endpoint of the recommended window.

wlist_left

left endpoints of the candidate windows.

wlist_right

right endpoints of the candidate windows.

results

matrix containing the minimum covariate-balance p-value, selected covariate index, binomial-test p-value, sample sizes below and above the cutoff, and window endpoints for each candidate window.

summary

matrix of sample-size summaries by side of the cutoff.

Author(s)

Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com

Rocio Titiunik, Princeton University. rocio.titiunik@gmail.com

Gonzalo Vazquez-Bare, UC Santa Barbara. gvazquezbare@gmail.com

References

Cattaneo, M.D., B. Frandsen and R. Titiunik. (2015). Randomization Inference in the Regression Discontinuity Design: An Application to Party Advantages in the U.S. Senate. Journal of Causal Inference 3(1): 1-24.

Cattaneo, M.D., R. Titiunik and G. Vazquez-Bare. (2016). Inference in Regression Discontinuity Designs under Local Randomization. Stata Journal 16(2): 331-367.

Cattaneo, M.D., R. Titiunik and G. Vazquez-Bare. (2017). Comparing Inference Approaches for RD Designs: A Reexamination of the Effect of Head Start on Child Mortality. Journal of Policy Analysis and Management 36(3): 643-681.

Examples

# Toy dataset
set.seed(123)
X <- array(rnorm(200),dim=c(100,2))
R <- X[,1] + X[,2] + rnorm(100)
# Window selection adding 5 observations at each step
# Note: low number of replications to speed up process.
tmp <- rdwinselect(R,X,obsmin=10,wobs=5,nwindows=5,reps=500,quietly=TRUE)
# Window selection setting initial window and step
# The user should increase the number of replications.
tmp <- rdwinselect(R,X,wmin=.5,wstep=.125,reps=500,quietly=TRUE)
# Window selection with approximate (large sample) inference and p-value plot
tmp <- rdwinselect(R,X,wmin=.5,wstep=.125,approx=TRUE,nwindows=20,quietly=TRUE,plot=TRUE)



rdlocrand documentation built on May 14, 2026, 5:10 p.m.