lpbwcde | R Documentation |
lpbwcde
implements the bandwidth selection methods for local
polynomial based conditional density (and derivatives) estimation proposed and studied
in \insertCitebernoullilpcde.
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("imse-rot", "mse-rot"),
regularize = NULL
)
y_data |
Numeric matrix/data frame, the raw data of independent. |
x_data |
Numeric matrix/data frame, the raw data of covariates. |
x |
Numeric, specifies the evaluation point in the x-direction. Default is median of the dataset. |
y_grid |
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. |
p |
Nonnegative integer, specifies the order of the local polynomial for |
q |
Nonnegative integer, specifies the order of the local polynomial for |
grid_spacing |
String, If equal to "quantile" will generate quantile-spaced grid evaluation points, otherwise will generate equally spaced points. |
ng |
Int, number of grid points to be used in generating bandwidth estimates. |
mu |
Nonnegative integer, specifies the derivative with respect to |
nu |
Nonnegative integer, specifies the derivative with respect to |
kernel_type |
String, specifies the kernel function, should be one of
|
bw_type |
String, specifies the method for data-driven bandwidth selection. This option will be
ignored if |
regularize |
Boolean (default TRUE). Option to regularize bandwidth selection to have atleast 20+max(p, q)+1 datapoints when evaluating the estimator. |
BW |
A matrix containing (1) |
opt |
A list containing options passed to the function. |
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"])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.