Learn R Programming

quantdr (version 1.2.2)

llqrcv: Cross-Validation for bandwidth selection of local linear quantile regression

Description

llqrcv estimates the bandwidth necessary for the local linear fit of the \(\tau\)th conditional quantile of y given x. The estimation is performed using the Cross-Validation criterion.

Usage

llqrcv(x, y, tau = 0.5)

Arguments

x

A design matrix (n x p). The rows represent observations and the columns represent predictor variables.

y

A vector of the response variable.

tau

A quantile level, a number strictly between 0 and 1.

Value

llqrcv returns the optimal bandwidth selected using Cross-Validation criterion for the local linear fit of the \(\tau\)th conditional quantile of y given x.

Details

A grid of bandwidth values is created and the local linear fit is estimated using all the data points except for one point, which is used to make the prediction. This procedure is repeated n times, where n is the number of observations. Then, the bandwidth is selected as the one with the smallest average error.

When the dimension of the predictor variable is large compared with the sample size, local linear fitting meets the 'curse of dimensionality' problem. In situations like that, the grid bandwidth values might be too small and cause the function to fail. For these cases, we advice the user to directly use the llqr function of the package and specify a bandwidth in the function.

Examples

Run this code
# NOT RUN {
set.seed(1234)
n <- 100
x <- rnorm(n)
error <- rnorm(n)
y <- x^2 + error
tau <- 0.5
llqrcv(x, y, tau = tau)
# }

Run the code above in your browser using DataLab