lpbwcde implements the bandwidth selection methods for local
polynomial based conditionaldensity (and derivatives) estimation proposed and studied
in bernoullilpcde.
Companion command: lpcde for estimation and robust bias-corrected inference.
Related Stata and R packages useful for nonparametric estimation and inference are
available at https://nppackages.github.io/.
lpbwcde(
y_data,
x_data,
x,
y_grid = NULL,
p = NULL,
q = NULL,
grid_spacing = "",
ng = NULL,
mu = NULL,
nu = NULL,
kernel_type = c("epanechnikov", "triangular", "uniform"),
bw_type = c("mse-rot", "imse-rot"),
regularize = NULL
)A matrix containing (1) y_grid (grid point), (2) bw (bandwidth)
A list containing options passed to the function.
Numeric matrix/data frame, the raw data of independent.
Numeric matrix/data frame, the raw data of covariates.
Numeric, specifies the evaluation point in the x-direction. Default is median of the dataset.
Numeric, specifies the grid of evaluation points. When set to default, grid points will be chosen as 0.05-0.95 percentiles of the data, with a step size of 0.05.
Nonnegative integer, specifies the order of the local polynomial for Y used to
construct point estimates. (Default is 2.)
Nonnegative integer, specifies the order of the local polynomial for X used to
construct point estimates. (Default is 1.)
String, If equal to "quantile" will generate quantile-spaced grid evaluation points, otherwise will generate equally spaced points.
Int, number of grid points to be used in generating bandwidth estimates.
Nonnegative integer, specifies the derivative with respect to Y of the
distribution function to be estimated. 0 for the distribution function,
1 (default) for the density funtion, etc.
Nonnegative integer, specifies the derivative with respect to X of the
distribution function to be estimated.
String, specifies the kernel function, should be one of
"triangular", "uniform" or "epanechnikov".
String, specifies the method for data-driven bandwidth selection. This option will be
ignored if bw is provided. Implementable with "mse-rot" (default, mean squared error-optimal
bandwidth selected for each grid point)
Boolean (default TRUE). Option to regularize bandwidth selection to have atleast 20+max(p, q)+1 datapoints when evaluating the estimator.
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu.
Rajita Chandak (maintainer), Princeton University. rchandak@princeton.edu.
Michael Jansson, University of California Berkeley. mjansson@econ.berkeley.edu.
Xinwei Ma, University of California San Diego. x1ma@ucsd.edu.
bernoullilpcde
Supported methods: coef.lpbwcde,
print.lpbwcde, summary.lpbwcde.
# Generate a random sample
set.seed(42);
x_data = rnorm(2000)
y_data = rnorm(2000, mean=x_data)
x = 0
# Construct bandwidth
bw1 <- lpbwcde(y_data = y_data, x_data = x_data, x=x, bw_type = "mse-rot")
summary(bw1)
# Display bandwidths for a subset of y_grid points
summary(bw1, y_grid=bw1$BW[2:5, "y_grid"])
Run the code above in your browser using DataLab