% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/MIRDD.R
\name{MIdiagRDD}
\alias{MIdiagRDD}
\title{Diagnostic Tool by Multiple Imputation for Regression Discontinuity Designs}
\usage{
MIdiagRDD(
  y,
  x,
  cut,
  seed = NULL,
  M1 = 100,
  M2 = 5,
  M3 = 1,
  p2s1 = 1,
  emp = 0,
  bw = "mserd",
  ker = "triangular",
  h = NULL,
  type = "Conventional",
  p1 = 1,
  conf = 95,
  upper = 1,
  covs1 = NULL,
  up = NULL,
  lo = NULL
)
}
\arguments{
\item{y}{A numeric vector of the outcome variable.}

\item{x}{A numeric vector of the running variable (forcing variable).}

\item{cut}{A numeric value indicating the cutoff point in x. The user must supply a specific number.}

\item{seed}{A seed number for reproducibility. Default is NULL.}

\item{M1}{Number of imputations for MIRDD. Default is 100.}

\item{M2}{Number of imputations for visualization (plots 3, 4, 9, and 10). Default is 5. These datasets are the subsets of M1 imputed datasets. Thus, M2 cannot be larger than M1.}

\item{M3}{Number of imputed datasets for plots 5 to 10. Default is 1. These datasets are the subsets of M1 imputed datasets. Thus, M3 cannot be larger than M1.}

\item{p2s1}{Integer for Amelia's p2s argument (0 or 1), where 0 for no screen printing and 1 for screen printing of multiple imputation process. Default is 1.}

\item{emp}{Amelia's empirical (ridge) prior. Default is 0. A reasonable upper bound is 0.1.}

\item{bw}{Bandwidth selection method for rdrobust. Options are "mserd" (default), "msesum", "cerrd", and "cersum". "mserd" is one common MSE-optimal bandwidth selector. "msesum" is one common MSE-optimal bandwidth selector for the sum of regression estimates. "cerrd" is one common CER-optimal bandwidth selector. "cersum" is one common CER-optimal bandwidth selector for the sum of regression estimates. MSE is Mean Squared Error. CER is Coverage Error Rate.}

\item{ker}{Kernel function for rdrobust. Options are "triangular" (default option), "epanechnikov", and "uniform".}

\item{h}{Number for bandwidth. Default is NULL (data-driven).}

\item{type}{Inference type: "Conventional" (default), "Bias-Corrected", or "Robust".}

\item{p1}{Polynomial order (1 or 2) for rdrobust and MIRDD. Default is 1 (local linear regression). Can take either 1 (local linear regression) or 2 (local quadratic regression). When specified larger than 2, it will be considered 2.}

\item{conf}{Confidence level (0-100). Default is 95.}

\item{upper}{If 1 (default), treatment is x >= cut. If 0, treatment is x < cut.}

\item{covs1}{Optional covariates. If two additional covariates z1 and z2 need to be used, then covs1 = data.frame(z1, z2).}

\item{up}{Optional upper bound for imputed values.}

\item{lo}{Optional lower bound for imputed values.}
}
\value{
\item{Estimate}{Estimated quantities of the average treatment effects (ATE) at the cutoff.}
\item{Std.Error}{Standard error of the estimate.}
\item{CI.LL}{Lower limit of the 95\% confidence interval.}
\item{CI.UL}{Upper limit of the 95\% confidence interval.}
\item{size}{Sub-sample size to estimate the ATE at the cutoff.}
\item{bandwidth}{Length of the bandwidth used for RDD analysis.}

In addition to the data frame, a series of diagnostic plots are generated:
\describe{
  \item{1. MIRDD, RDD, Naive}{A diagnostic plot to visualize the relationship among the three estimators. Red vertical line is RDD, black solid line is naive, and histogram is MI.}
  \item{2. MIRDD and RDD}{A diagnostic plot to visualize the relationship between the two estimators. Red vertical line is RDD and histogram is MI.}
  \item{3. Densities (Control)}{A diagnostic plot to visualize the densities of observed and imputed data. Gray solid curve is the density of observed data in the control group. Blue solid curve is the density of observed data in the treatment group. Red dashed lines are the densities of imputed data in the control group.}
  \item{4. Densities (Treatment)}{A diagnostic plot to visualize the densities of observed and imputed data. Gray solid curve is the density of observed data in the control group. Blue solid curve is the density of observed data in the treatment group. Red dashed lines are the densities of imputed data in the treatment group.}
  \item{5. Observed Values}{A diagnostic plot to visualize the scatterplot of observed data. Gray circles are observed data in the control group. Blue triangles are observed data in the treatment group.}
  \item{6. Observed & Imputed Values}{A diagnostic plot to visualize the scatterplot of observed and imputed data. Red circles are imputed data in the control group. Red triangles are imputed data in the treatment group. These imputed data are overlaid on the observed data in Figure 5.}
  \item{7. Observed & Imputed (Control)}{A diagnostic plot to clearly visualize the scatterplot of observed and imputed data in the control group only.}
  \item{8. Observed & Imputed (Treatment)}{A diagnostic plot to clearly visualize the scatterplot of observed and imputed data in the treatment group only.}
  \item{9. Around Cutoff (Control)}{A diagnostic plot to clearly visualize the scatterplot, around the cutoff point, of observed and imputed data in the control group only. Five solid lines are the estimated linear regression lines based on multiply imputed data.}
  \item{10. Around Cutoff (Treatment)}{A diagnostic plot to clearly visualize the scatterplot, around the cutoff point, of observed and imputed data in the treatment group only. Five solid lines are the estimated linear regression lines based on multiply imputed data.}
  \item{11. Local Slope (Control)}{A diagnostic plot to visualize the distribution of the coefficients of the estimated linear regression models around the cutoff point in the control group.}
  \item{12. Local Slope (Treatment)}{A diagnostic plot to visualize the distribution of the coefficients of the estimated linear regression models around the cutoff point in the treatment group.}
}
}
\description{
Estimates average treatment effects at the cutoff based on sharp regression discontinuity
designs (RDD) and multiple imputation regression discontinuity designs (MIRDD).
It provides diagnostic tools for RDD by comparing results with those from MIRDD.
}
\examples{
# Example usage with dummy data
x <- runif(100, -1, 1)
y <- 0.5 * x + (x >= 0) + rnorm(100, 0, 0.1)
MIdiagRDD(y = y, x = x, cut = 0)
}
\references{
Takahashi, M. 2023. Multiple imputation regression discontinuity designs: Alternative to regression discontinuity designs to estimate the local average treatment effect at the cutoff. Communications in Statistics - Simulation and Computation 53(9): 4293-4312. \doi{10.1080/03610918.2021.1960374}

Takahashi, M. 2026. MIRDD: An R package for multiple imputation regression discontinuity design. SoftwareX 34(102707): 1-6. \doi{10.1016/j.softx.2026.102707}

Calonico, S., Cattaneo, M.D., and Titiunik, R. 2015. rdrobust: An R Package for robust nonparametric inference in regression-discontinuity designs. R Journal 7(1): 38-51. \doi{10.32614/RJ-2015-004}

Honaker, J., King, G., and Blackwell, M. 2011. Amelia II: A program for missing data. Journal of Statistical Software 45(7): 1-47. \doi{10.18637/jss.v045.i07}
}
