Learn R Programming

lg (version 0.4.1)

bw_select_cv_univariate: Cross-validation for univariate distributions

Description

Uses cross-validation to find the optimal bandwidth for a univariate locally Gaussian fit

Usage

bw_select_cv_univariate(x, tol = 10^(-3))

Arguments

x

The vector of data points.

tol

The absolute tolerance in the optimization, passed to the optim-function using the BFGS-method.

Value

The function returns a list with two elements: bw is the selected bandwidth, and convergence is the convergence flag returned by the optim-function.

Details

This function provides the univariate version of the Cross Validation algorithm for bandwidth selection described in Otneim & Tj<U+00F8>stheim (2017), Section 4. Let \(\hat{f}_h(x)\) be the univariate locally Gaussian density estimate obtained using the bandwidth \(h\), then this function returns the bandwidth that maximizes $$CV(h) = n^{-1} \sum_{i=1}^n \log \hat{f}_h^{(-i)}(x_i),$$ where \(\hat{f}_h^{(-i)}\) is the density estimate calculated without observation \(x_i\).

References

Otneim, H<U+00E5>kon, and Dag Tj<U+00F8>stheim. "The locally gaussian density estimator for multivariate data." Statistics and Computing 27, no. 6 (2017): 1595-1616.

Examples

Run this code
# NOT RUN {
  x <- rnorm(100)
  bw <- bw_select_cv_univariate(x)

# }

Run the code above in your browser using DataLab