# rdwinselect

##### Window selection for RD designs under local randomization

`rdwinselect`

implements the 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 runvar and covariate balance
tests for covariates covariates (if specified). The recommended window is the
largest window around the cutoff such that the minimum p-value of the balance test
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,
wmasspoints = 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 balancing 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 at each side of the cutoff at each step. Default is 5

- wstep
the increment in window length.

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

- 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 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 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
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
suppress 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

recommended window (NA is covariates are not specified)

list of window lengths

table including window lengths, minimum p-value in each window, corresponding number of the variable with minimum p-value (i.e. column of covariate matrix), Binomial test p-value and sample sizes to the left and right of the cutoff in each window.

summary statistics.

##### References

M.D. Cattaneo, 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.

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

M.D. Cattaneo, 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

```
# NOT RUN {
# Toy dataset
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,reps=500)
# 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)
# Window selection with approximate (large sample) inference and p-value plot
tmp <- rdwinselect(R,X,wmin=.5,wstep=.125,approx=TRUE,nwin=80,quietly=TRUE,plot=TRUE)
# }
```

*Documentation reproduced from package rdlocrand, version 0.7, License: GPL-2*