Package {nprobust}


Type: Package
Title: Kernel Density and Local Polynomial Regression Methods
Version: 1.0.0
Date: 2026-05-17
Author: Sebastian Calonico [aut, cre], Matias D. Cattaneo [aut], Max H. Farrell [aut]
Maintainer: Sebastian Calonico <scalonico@ucdavis.edu>
Description: Estimation, inference, bandwidth selection, and graphical procedures for kernel density and local polynomial regression methods, including robust bias-corrected confidence intervals as described in Calonico, Cattaneo and Farrell (2018, <doi:10.1080/01621459.2017.1285776>). The package includes 'lprobust()' for local polynomial point estimation and robust bias-corrected inference, 'lpbwselect()' for local polynomial bandwidth selection, 'kdrobust()' for kernel density point estimation and robust bias-corrected inference, 'kdbwselect()' for kernel density bandwidth selection, and 'nprobust.plot()' for plotting results. The main methodological and numerical features are described in Calonico, Cattaneo and Farrell (2019, <doi:10.18637/jss.v091.i08>).
Encoding: UTF-8
Depends: R (≥ 3.6.0)
License: GPL-3
URL: https://github.com/nppackages/nprobust
BugReports: https://github.com/nppackages/nprobust/issues
Imports: ggplot2
Suggests: testthat (≥ 3.0.0), broom, sandwich
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-05-18 21:54:24 UTC; ncalonic
Repository: CRAN
Date/Publication: 2026-05-19 05:10:09 UTC

Kernel Density and Local Polynomial Regression Methods

Description

This package implements estimation, inference, bandwidth selection, and graphical procedures for kernel density and local polynomial regression methods, including robust bias-corrected confidence intervals as described in Calonico, Cattaneo and Farrell (2018): lprobust for local polynomial point estimation and robust bias-corrected inference, lpbwselect for local polynomial bandwidth selection, kdrobust for kernel density point estimation and robust bias-corrected inference, kdbwselect for kernel density bandwidth selection, and nprobust.plot for plotting results. The main methodological and numerical features are described in Calonico, Cattaneo and Farrell (2019).

Details

Package: nprobust
Type: Package
Version: 1.0.0
Date: 2026-05-17
License: GPL-3

Function for LPR estimation and inference: lprobust
Function for LPR bandwidth selection: lpbwselect
Function for KDE estimation and inference: kdrobust
Function for KDE bandwidth selection: kdbwselect
Function for graphical analysis: nprobust.plot

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


Bandwidth Selection Procedures for Kernel Density Estimation and Inference

Description

kdbwselect implements bandwidth selectors for kernel density point estimators 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 bandwidth selectors available in the literature.

Companion commands are: kdrobust for kernel density point estimation and inference procedures.

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

kdbwselect(x, eval = NULL, neval = NULL, kernel = "epa",
bwselect = "mse-dpi", bwcheck=21, imsegrid=30, 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.

kernel

kernel function used to construct the kernel 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. Options are:

mse-dpi second-generation DPI implementation of MSE-optimal bandwidth. Default option.

imse-dpi second-generation DPI implementation of IMSE-optimal bandwidth (computed using grid of evaluation points selected).

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

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

ce-rot ROT implementation of CE-optimal bandwidth.

all reports 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.

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

bws

A matrix containing eval (grid points), h and b (selected bandwidths) for each evaluation point. When bwselect="all", the matrix is widened to include both MSE and CER bandwidths from each of the DPI and ROT estimators.

bws.imse

IMSE-optimal bandwidths returned when bwselect="all"; NULL otherwise.

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

kdrobust

Examples

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

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. 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. 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)

Bandwidth Selection Procedures for Local Polynomial Regression Estimation and Inference

Description

lpbwselect implements bandwidth selectors for local polynomial regression point estimators 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 bandwidth selectors available in the literature.

Companion commands: lprobust for local polynomial point estimation and inference procedures.

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

lpbwselect(y, x, eval = NULL, neval = NULL, p = NULL, deriv = NULL,
kernel = "epa", bwselect = "mse-dpi", bwcheck = 21, bwregul = 1,
imsegrid = 30, vce = "nn", cluster = NULL,
nnmatch = 3, interior = FALSE, subset = NULL,
weights = NULL, masspoints = "check", data = NULL)

Arguments

y

dependent variable.

x

independent variable.

eval

vector of evaluation point(s). By default it uses 30 equally spaced points over the support of x.

neval

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

p

polynomial order used to construct point estimator; default is p = 1 (local linear regression).

deriv

derivative order of the regression function to be estimated. Default is deriv=0 (regression function).

kernel

kernel function used to construct local polynomial estimators. Options are epa for the epanechnikov kernel, tri for the triangular kernel, uni for the uniform kernel and gau for the gaussian kernel. Default is kernel = epa.

bwselect

bandwidth selection procedure to be used. Options are:

mse-dpi second-generation DPI implementation of MSE-optimal bandwidth. Default option.

mse-rot ROT implementation of MSE-optimal bandwidth.

imse-dpi second-generation DPI implementation of IMSE-optimal bandwidth (computed using grid of evaluation points selected).

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

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

ce-rot ROT implementation of CE-optimal bandwidth.

all reports 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.

bwregul

specifies scaling factor for the regularization term added to the denominator of bandwidth selectors. Setting bwregul = 0 removes the regularization term from the bandwidth selectors. Default is bwregul = 1.

imsegrid

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

vce

procedure used to compute the variance-covariance matrix estimator. Options are:

nn heteroskedasticity-robust nearest neighbor variance estimator with nnmatch the (minimum) number of neighbors to be used. Default choice (when cluster is not supplied).

hc0 heteroskedasticity-robust plug-in residuals variance estimator without weights.

hc1 heteroskedasticity-robust plug-in residuals variance estimator with hc1 weights.

hc2 heteroskedasticity-robust plug-in residuals variance estimator with hc2 weights.

hc3 heteroskedasticity-robust plug-in residuals variance estimator with hc3 weights.

cr1 cluster-robust variance estimator with ((n-1)/(n-k)) * (G/(G-1)) multiplier (Stata-style CR1). Default choice when cluster is supplied. Requires cluster.

cr2 cluster-robust variance estimator with Bell-McCaffrey block-adjusted residuals. Requires cluster.

cr3 cluster-robust variance estimator with block jackknife-style adjustment and (G-1)/G multiplier. Requires cluster.

When cluster is supplied, vce=hc0 or vce=hc1 is remapped to cr1, vce=hc2 to cr2, and vce=hc3 to cr3 (with a warning). vce=nn with cluster silently defaults to cr1.

cluster

indicates the cluster ID variable used for cluster-robust variance estimation. When supplied, the default vce becomes cr1; cr2 and cr3 are also available.

nnmatch

to be combined with for vce=nn for heteroskedasticity-robust nearest neighbor variance estimator with nnmatch indicating the minimum number of neighbors to be used. Default is nnmatch=3

.

interior

if TRUE, all evaluation points are assumed to be interior points. This option affects only data-driven bandwidth selection via lpbwselect. Default is interior = FALSE.

subset

optional rule specifying a subset of observations to be used.

weights

optional vector of non-negative observation weights (multiplicative with kernel weights in all bandwidth-selection steps).

masspoints

how to handle evaluation points with few unique x values within bandwidth. Options: "check" (default), "off".

data

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

Value

bws

A matrix containing eval (grid points), h and b (selected bandwidths) for each evaluation point. When bwselect="all", the matrix is widened to include both MSE and CER bandwidths from each of the DPI and ROT estimators.

bws.imse

IMSE-optimal bandwidths returned when bwselect="all"; NULL otherwise.

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

lprobust

Examples

x   <- runif(500)
y   <- sin(4*x) + rnorm(500)
est <- lpbwselect(y,x)
summary(est)

Local Polynomial Methods with Robust Bias-Corrected Inference

Description

lprobust implements local polynomial regression 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: lpbwselect for local polynomial 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

lprobust(y, x, eval = NULL, neval = NULL, p = NULL, deriv = NULL,
h = NULL, b = NULL, rho = 1, kernel = "epa", bwselect = NULL,
bwcheck = 21, bwregul = 1, imsegrid = 30, vce = "nn", covgrid = FALSE,
cluster = NULL, nnmatch = 3, level = 95, interior = FALSE, subset = NULL,
weights = NULL, masspoints = "check", data = NULL)

Arguments

y

dependent variable.

x

independent variable.

eval

vector of evaluation point(s). By default it uses 30 equally spaced points over the support of x.

neval

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

p

polynomial order used to construct point estimator; default is p = 1 (local linear regression).

deriv

derivative order of the regression function to be estimated. Default is deriv=0 (regression function).

h

main bandwidth used to construct local polynomial 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 lpbwselect.

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 lpbwselect.

rho

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

kernel

kernel function used to construct local polynomial estimators. Options are epa for the epanechnikov kernel, tri for the triangular kernel, uni for the uniform kernel and gau for the gaussian kernel. Default is kernel = epa.

bwselect

bandwidth selection procedure to be used via lpbwselect. 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.

mse-rot ROT implementation of MSE-optimal bandwidth.

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 lpbwselect 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.

bwregul

specifies scaling factor for the regularization term added to the denominator of bandwidth selectors. Setting bwregul = 0 removes the regularization term from the bandwidth selectors. Default is bwregul = 1.

imsegrid

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

vce

procedure used to compute the variance-covariance matrix estimator. Options are:

nn heteroskedasticity-robust nearest neighbor variance estimator with nnmatch the (minimum) number of neighbors to be used. Default choice (when cluster is not supplied).

hc0 heteroskedasticity-robust plug-in residuals variance estimator without weights.

hc1 heteroskedasticity-robust plug-in residuals variance estimator with hc1 weights.

hc2 heteroskedasticity-robust plug-in residuals variance estimator with hc2 weights.

hc3 heteroskedasticity-robust plug-in residuals variance estimator with hc3 weights.

cr1 cluster-robust variance estimator with ((n-1)/(n-k)) * (G/(G-1)) multiplier (Stata-style CR1). Default choice when cluster is supplied. Requires cluster.

cr2 cluster-robust variance estimator with Bell-McCaffrey block-adjusted residuals. Requires cluster.

cr3 cluster-robust variance estimator with block jackknife-style adjustment and (G-1)/G multiplier. Requires cluster.

When cluster is supplied, vce=hc0 or vce=hc1 is remapped to cr1, vce=hc2 to cr2, and vce=hc3 to cr3 (with a warning). vce=nn with cluster silently defaults to cr1.

covgrid

if TRUE, it computes two covariance matrices (cov.us and cov.rb) for classical and robust covariances across point estimators over the grid of evaluation points.

cluster

indicates the cluster ID variable used for cluster-robust variance estimation. When supplied, the default vce becomes cr1; cr2 and cr3 are also available.

nnmatch

to be combined with for vce=nn for heteroskedasticity-robust nearest neighbor variance estimator with nnmatch indicating the minimum number of neighbors to be used. Default is nnmatch=3

.

level

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

interior

if TRUE, all evaluation points are assumed to be interior points. This option affects only data-driven bandwidth selection via lpbwselect. Default is interior = FALSE.

subset

optional rule specifying a subset of observations to be used.

weights

optional vector of non-negative observation weights of the same length as x. User weights multiply the kernel weights in estimation, bandwidth selection, and variance computation (weighted least squares interpretation).

masspoints

how to handle evaluation points whose bandwidth window contains few unique x values (the local polynomial may become unreliable in that case). Options: "check" (default) warns when there are fewer than p+5 unique values inside the main bandwidth; "off" disables the check.

data

an optional data frame. When supplied, y, x, cluster, weights, 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 (point estimates with p-th order local polynomial), tau.bc (bias-corrected point estimates with (p+1)-th order local polynomial), se.us (standard error corresponding to tau.us), and se.rb (robust standard error).

cov.us

Conventional-estimator covariance matrix across the evaluation grid (neval by neval). Returned only when covgrid=TRUE; NULL otherwise.

cov.rb

Robust-bias-corrected covariance matrix across the evaluation grid (neval by neval). Returned only when covgrid=TRUE; NULL otherwise.

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

lpbwselect

Examples

x   <- runif(500)
y   <- sin(4*x) + rnorm(500)
est <- lprobust(y,x)
summary(est)

Graphical Presentation of Results from nprobust Package.

Description

nprobust.plot plots estimated density and regression function using the nprobust package. A detailed introduction to this command is given in Calonico, Cattaneo and Farrell (2019).

Companion commands: lprobust for local polynomial point estimation and inference procedures, and kdrobust for kernel density point estimation and inference procedures.

For more details and related software useful for empirical analysis, visit https://nppackages.github.io/.

Usage

nprobust.plot(..., alpha = NULL, type = NULL, CItype = NULL,
  title = "", xlabel = "", ylabel = "", lty = NULL, lwd = NULL,
  lcol = NULL, pty = NULL, pwd = NULL, pcol = NULL, CIshade = NULL,
  CIcol = NULL, legendTitle = NULL, legendGroups = NULL)

Arguments

...

Objects returned by kdrobust or lprobust.

alpha

Numeric scalar between 0 and 1, the significance level for plotting confidence regions. If more than one is provided, they will be applied to data series accordingly.

type

String, one of "line" (default), "points" or "both", how the point estimates are plotted. If more than one is provided, they will be applied to data series accordingly.

CItype

String, one of "region" (shaded region, default), "line" (dashed lines), "ebar" (error bars), "all" (all of the previous) or "none" (no confidence region), how the confidence region should be plotted. If more than one is provided, they will be applied to data series accordingly.

title, xlabel, ylabel

Strings, title of the plot and labels for x- and y-axis.

lty

Line type for point estimates, only effective if type is "line" or "both". 1 for solid line, 2 for dashed line, 3 for dotted line. For other options, see the instructions for ggplot2 or par. If more than one is provided, they will be applied to data series accordingly.

lwd

Line width for point estimates, only effective if type is "line" or "both". Should be strictly positive. For other options, see the instructions for ggplot2 or par. If more than one is provided, they will be applied to data series accordingly.

lcol

Line color for point estimates, only effective if type is "line" or "both". 1 for black, 2 for red, 3 for green, 4 for blue. For other options, see the instructions for ggplot2or par. If more than one is provided, they will be applied to data series accordingly.

pty

Scatter plot type for point estimates, only effective if type is "points" or "both". For options, see the instructions for ggplot2 or par. If more than one is provided, they will be applied to data series accordingly.

pwd

Scatter plot size for point estimates, only effective if type is "points" or "both". Should be strictly positive. If more than one is provided, they will be applied to data series accordingly.

pcol

Scatter plot color for point estimates, only effective if type is "points" or "both". 1 for black, 2 for red, 3 for green, 4 for blue. For other options, see the instructions for ggplot2 or par. If more than one is provided, they will be applied to data series accordingly.

CIshade

Numeric, opaqueness of the confidence region, should be between 0 (transparent) and 1. Default is 0.2. If more than one is provided, they will be applied to data series accordingly.

CIcol

color for confidence region. 1 for black, 2 for red, 3 for green, 4 for blue. For other options, see the instructions for ggplot2 or par. If more than one is provided, they will be applied to data series accordingly.

legendTitle

String, title of legend.

legendGroups

String Vector, group names used in legend.

Details

Companion commands: lprobust for local polynomial point estimation and inference, and kdrobust for kernel density point estimation and inference.

Value

A standard ggplot2 object is returned, hence can be used for further customization.

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. 2019. nprobust: Nonparametric Kernel-Based Estimation and Robust Bias-Corrected Inference. Journal of Statistical Software, 91(8): 1-33. doi:10.18637/jss.v091.i08.

See Also

lprobust, kdrobust, ggplot2

Examples

x   <- runif(500) 
y   <- sin(4*x) + rnorm(500)
est <- lprobust(y,x)
nprobust.plot(est)