kdrobust: Kernel Density Methods with Robust Bias-Corrected Inference

View source: R/kdrobust.R

kdrobustR Documentation

Kernel Density Methods with Robust Bias-Corrected Inference

Description

kdrobust implements kernel density point estimators, with robust bias-corrected confidence intervals and inference procedures developed in Calonico, Cattaneo and Farrell (2018). See also Calonico, Cattaneo and Farrell (2022) for related optimality results. It also implements other estimation and inference procedures available in the literature.

Companion commands: kdbwselect for kernel density data-driven bandwidth selection, and nprobust.plot for plotting results.

A detailed introduction to this command is given in Calonico, Cattaneo and Farrell (2019). For more details and related software useful for empirical analysis, visit https://nppackages.github.io/.

Usage

kdrobust(x, eval = NULL, neval = NULL, h = NULL, b = NULL, rho = 1, 
kernel = "epa", bwselect = NULL, bwcheck = 21, imsegrid=30, level = 95, subset = NULL,
data = NULL)

Arguments

x

independent variable.

eval

vector of evaluation point(s). By default it uses 30 quantile-spaced points (deciles 0.1 to 0.9 in equal steps) over the support of x.

neval

number of quantile-spaced evaluation points on the support of x. Default is neval=30.

h

main bandwidth used to construct the kernel density point estimator. Can be either scalar (same bandwidth for all evaluation points), or vector of same dimension as eval. If not specified, bandwidth h is computed by the companion command kdbwselect.

b

bias bandwidth used to construct the bias-correction estimator. Can be either scalar (same bandwidth for all evaluation points), or vector of same dimension as eval. By default it is set equal to h. If rho is set to zero, b is computed by the companion command kdbwselect.

rho

Sets b=h/rho. Default is rho = 1.

kernel

kernel function used to construct kernel density estimators. Options are epa for the epanechnikov kernel and uni for the uniform kernel. Default is kernel = epa.

bwselect

bandwidth selection procedure to be used via kdbwselect. By default it computes h and sets b=h/rho (with rho=1 by default). It computes both h and b if rho is set equal to zero. Options are:

mse-dpi second-generation DPI implementation of MSE-optimal bandwidth. Default option if only one evaluation point is chosen.

imse-dpi second-generation DPI implementation of IMSE-optimal bandwidth (computed using a grid of evaluation points). Default option if more than one evaluation point is chosen.

imse-rot ROT implementation of IMSE-optimal bandwidth (computed using a grid of evaluation points).

ce-dpi second generation DPI implementation of CE-optimal bandwidth.

ce-rot ROT implementation of CE-optimal bandwidth.

Use kdbwselect with bwselect="all" to report all available bandwidth selection procedures.

Note: MSE = Mean Square Error; IMSE = Integrated Mean Squared Error; CE = Coverage Error; DPI = Direct Plug-in; ROT = Rule-of-Thumb. For details on implementation see Calonico, Cattaneo and Farrell (2019).

bwcheck

if a positive integer is provided, then the selected bandwidth is enlarged so that at least bwcheck effective observations are available at each evaluation point. Default is bwcheck = 21.

imsegrid

number of evaluations points used to compute the IMSE bandwidth selector. Default is imsegrid = 30.

level

confidence level used for confidence intervals; default is level = 95.

subset

optional rule specifying a subset of observations to be used.

data

an optional data frame. When supplied, x and subset may be given as bare variable names referring to columns of data.

Value

Estimate

A matrix containing eval (grid points), h, b (bandwidths), N (effective sample sizes), tau.us (conventional density estimate), tau.bc (bias-corrected density estimate), se.us (standard error corresponding to tau.us), and se.rb (robust standard error).

opt

A list containing options passed to the function.

Author(s)

Sebastian Calonico, University of California, Davis, CA. scalonico@ucdavis.edu.

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

Max H. Farrell, University of California, Santa Barbara, CA. mhfarrell@gmail.com.

References

Calonico, S., M. D. Cattaneo, and M. H. Farrell. 2018. On the Effect of Bias Estimation on Coverage Accuracy in Nonparametric Inference. Journal of the American Statistical Association, 113(522): 767-779. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2017.1285776")}.

Calonico, S., M. D. Cattaneo, and M. H. Farrell. 2019. nprobust: Nonparametric Kernel-Based Estimation and Robust Bias-Corrected Inference. Journal of Statistical Software, 91(8): 1-33. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v091.i08")}.

Calonico, S., M. D. Cattaneo, and M. H. Farrell. 2022. Coverage Error Optimal Confidence Intervals for Local Polynomial Regression. Bernoulli, 28(4): 2998-3022.

See Also

kdbwselect

Examples

x   <- rnorm(500)
est <- kdrobust(x)
summary(est)

nprobust documentation built on May 19, 2026, 9:07 a.m.