% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rdsensitivity.R
\name{rdsensitivity}
\alias{rdsensitivity}
\title{Sensitivity analysis for RD designs under local randomization}
\usage{
rdsensitivity(
  Y,
  R,
  cutoff = 0,
  wlist,
  wlist_left,
  tlist,
  statistic = "diffmeans",
  p = 0,
  evalat = "cutoff",
  kernel = "uniform",
  fuzzy = NULL,
  ci = NULL,
  ci_alpha = 0.05,
  reps = 1000,
  seed = 666,
  nodraw = FALSE,
  quietly = FALSE
)
}
\arguments{
\item{Y}{a vector containing the values of the outcome variable.}

\item{R}{a vector containing the values of the running variable.}

\item{cutoff}{the RD cutoff (default is 0).}

\item{wlist}{the list of windows to the right of the cutoff. By default the program constructs 10 windows around the cutoff with 5 observations each.}

\item{wlist_left}{the list of windows to the left of the cutoff. If not specified, the windows are constructed symmetrically around the cutoff based on the values in wlist.}

\item{tlist}{the list of treatment-effect values under the null to be evaluated. By default the program uses ten evenly spaced points within the asymptotic confidence interval for a constant treatment effect in the smallest window to be used.}

\item{statistic}{the randomization test statistic to be used. Allowed options are \code{diffmeans} (difference in means statistic), \code{ksmirnov} (Kolmogorov-Smirnov statistic), and \code{ranksum} (Wilcoxon-Mann-Whitney standardized statistic). Default option is \code{diffmeans}. The statistic \code{ttest} is equivalent to \code{diffmeans} and included for backward compatibility.}

\item{p}{the order of the polynomial for the outcome adjustment model. Default is 0.}

\item{evalat}{specifies the point at which the adjusted variable is evaluated. Allowed options are \code{cutoff} and \code{means}. Default is \code{cutoff}.}

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

\item{fuzzy}{indicates that the RD design is fuzzy. \code{fuzzy} should be specified as a vector containing the values of the endogenous treatment variable. This option uses an Anderson-Rubin/intention-to-treat statistic.}

\item{ci}{returns the confidence interval corresponding to the indicated window length. \code{ci} must be a two-element vector containing the left and right limits of the window. Default alpha is .05 (95\% level CI).}

\item{ci_alpha}{specifies the value of alpha for the confidence interval. Default alpha is .05 (95\% level CI).}

\item{reps}{the number of replications. Default is 1000.}

\item{seed}{the seed to be used for the randomization tests.}

\item{nodraw}{suppresses contour plot.}

\item{quietly}{suppresses the output table.}
}
\value{
A list containing:
\item{tlist}{treatment-effect grid.}
\item{wlist}{right endpoints of the window grid.}
\item{wlist_left}{left endpoints of the window grid.}
\item{results}{matrix of p-values for each treatment-effect and window pair.}
\item{ci}{confidence interval; included only when \code{ci} is specified.}
}
\description{
\code{rdsensitivity} analyzes the sensitivity of randomization p-values
and confidence intervals to different window lengths.
}
\examples{
# Toy dataset
set.seed(123)
R <- runif(100,-1,1)
Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(100)
# Sensitivity analysis
# Note: low number of replications to speed up process.
# The user should increase the number of replications.
tmp <- rdsensitivity(Y,R,wlist=seq(.75,2,by=.25),tlist=seq(0,5,by=1),
                     reps=500,nodraw=TRUE,quietly=TRUE)


}
\references{
Cattaneo, M.D., B. Frandsen and R. Titiunik. (2015). \href{https://rdpackages.github.io/references/Cattaneo-Frandsen-Titiunik_2015_JCI.pdf}{Randomization Inference in the Regression Discontinuity Design: An Application to Party Advantages in the U.S. Senate}. \emph{Journal of Causal Inference} 3(1): 1-24.

Cattaneo, M.D., R. Titiunik and G. Vazquez-Bare. (2016). \href{https://rdpackages.github.io/references/Cattaneo-Titiunik-VazquezBare_2016_Stata.pdf}{Inference in Regression Discontinuity Designs under Local Randomization}. \emph{Stata Journal} 16(2): 331-367.

Cattaneo, M.D., R. Titiunik and G. Vazquez-Bare. (2017). \href{https://rdpackages.github.io/references/Cattaneo-Titiunik-VazquezBare_2017_JPAM.pdf}{Comparing Inference Approaches for RD Designs: A Reexamination of the Effect of Head Start on Child Mortality}. \emph{Journal of Policy Analysis and Management} 36(3): 643-681.
}
\author{
Matias D. Cattaneo, Princeton University. \email{matias.d.cattaneo@gmail.com}

Rocio Titiunik, Princeton University. \email{rocio.titiunik@gmail.com}

Gonzalo Vazquez-Bare, UC Santa Barbara. \email{gvazquezbare@gmail.com}
}
