# LPPOptBW: Optimal Bandwidth Selection for inference at a point In kolesarm/RDHonest: Honest inference in sharp regression discontinuity designs

## Description

Estimate bandwidth based on local polynomial regression that optimizes either maximum mean squared error, or length or quantiles of excess length of a honest CI under second order Hölder or Taylor class.

## Usage

 1 2 3 LPPOptBW(formula, data, subset, point = 0, M, kern = "triangular", na.action, opt.criterion, alpha = 0.05, beta = 0.8, sclass = "H", order = 1, se.initial = "ROTEHW")

## Arguments

 formula object of class "formula" (or one that can be coerced to that class) of the form outcome ~ independent_variable data optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the outcome and independent variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which the function is called. subset optional vector specifying a subset of observations to be used in the fitting process. point specifies the point X_0 at which to do inference M Bound on second derivative of the conditional mean function. kern specifies kernel function used in the local regression. It can either be a string equal to "triangular" (k(u)=(1-|u|)_{+}), "epanechnikov" (k(u)=(3/4)(1-u^2)_{+}), or "uniform" (k(u)= (|u|<1)/2), or else a kernel function. na.action function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options (usually na.omit). opt.criterion Optimality criterion that bandwidth is designed to optimize. It can either be based on exact finite-sample maximum bias and finite-sample estimate of variance, or asymptotic approximations to the bias and variance. The options are: "MSE"Finite-sample maximum MSE "FLCI"Length of (fixed-length) two-sided confidence intervals. "OCI"Given quantile of excess length of one-sided confidence intervals The finite-sample methods use conditional variance given by sigma2, if supplied. Otherwise, for the purpose of estimating the optimal bandwidth, conditional variance is assumed homoscedastic, and estimated using a nearest neighbor estimator. alpha determines confidence level, 1-alpha for constructing/optimizing confidence intervals. beta Determines quantile of excess length to optimize, if bandwidth optimizes given quantile of excess length of one-sided confidence intervals. sclass Smoothness class, either "T" for Taylor or "H" for Hölder class. order Order of local regression 1 for linear, 2 for quadratic. se.initial Method for estimating initial variance for computing optimal bandwidth. Ignored if data already contains estimate of variance. "ROTEHW"Based on residuals from a local linear regression using a triangular kernel and ROT bandwidth "ROTdemeaned"Based on sum of squared deviations of outcome from estimate of intercept in local linear regression with triangular kernel and ROT bandwidth

## Value

Returns an object of class "LPPBW". The function print can be used to obtain and print a summary of the results. An object of class "LPPBW" is a list containing the following components:

h

Bandwidth

sigma2

estimate of conditional variance at a point

call

the matched call

na.action

(where relevant) information on handling of missing data.

## Note

subset is evaluated in the same way as variables in formula, that is first in data and then in the environment of formula.