bw_cv_kre_polysph: Cross-validation bandwidth selection for...

View source: R/kre.R

bw_cv_kre_polysphR Documentation

Cross-validation bandwidth selection for polyspherical-on-scalar regression

Description

Computes least squares cross-validation bandwidths for kernel regression estimation with polyspherical response and scalar predictor. It computes both the bandwidth that minimizes the cross-validation loss and its "one standard error" variant.

Usage

bw_cv_kre_polysph(X, Y, d, p = 0, h_grid = bw.nrd(X) * 10^seq(-2, 2, l =
  100), plot_cv = TRUE, fast = TRUE)

Arguments

X

a vector of size n with the predictor sample.

Y

a matrix of size c(n, sum(d) + r) with the response sample on the polysphere.

d

vector of size r with dimensions.

p

degree of local fit, either 0 or 1. Defaults to 0.

h_grid

bandwidth grid where to optimize the cross-validation loss. Defaults to bw.nrd(X) * 10^seq(-1, 1, l = 100).

plot_cv

plot the cross-validation loss curve? Defaults to TRUE.

fast

use the faster and equivalent version of the cross-validation loss? Defaults to TRUE.

Details

A similar output to glmnet's cv.glmnet is returned.

Value

A list with the following fields:

h_min

the bandwidth that minimizes the cross-validation loss.

h_1se

the largest bandwidth within one standard error of the minimal cross-validation loss.

cvm

the mean of the cross-validation loss curve.

cvse

the standard error of the cross-validation loss curve.

Examples

n <- 50
X <- seq(0, 1, l = n)
Y <- r_path_s2r(n = n, r = 1, sigma = 0.1, spiral = TRUE)[, , 1]
bw_cv_kre_polysph(X = X, Y = Y, d = 2, p = 0)
bw_cv_kre_polysph(X = X, Y = Y, d = 2, p = 1, fast = FALSE)

polykde documentation built on April 16, 2025, 1:11 a.m.