Bandwidth Selection
- sw2023.bandwidth_loocv_product(Z, y, h_ref=None, n_grid=10, max_iter=5, tol=0.001, verbose=False)[source]
Per-dimension LOO-CV bandwidth (true product kernel).
Independently optimizes h_k for each dimension k via coordinate descent, matching the published per-dimension bandwidth structure in SW(2023), which reports separate bandwidths.
- Kernel: K[i,j] = exp(-0.5 × Σ_k ((Z_ik - Z_jk) / h_k)²)
= ∏_k exp(-0.5 × ((Z_ik - Z_jk) / h_k)²)
Maintains
log_K = -0.5 × Σ_k D_k / c_k²(n×n, O(n²) memory). For each dimension k, removes its contribution, optimizesc_kvia coarse grid + golden-section, and updateslog_K. Stops when the maximum relative change in anyc_kis belowtol.Memory: O(n²) — D_k computed on-the-fly, never stored as (d,n,n) tensor.
- Parameters:
Z ((n, d) conditioning variables)
y ((n,) dependent variable)
h_ref ((d,) reference bandwidth (Silverman rule if None))
n_grid (coarse grid points per 1-D search (default 10))
max_iter (maximum coordinate-descent iterations (default 5))
tol (relative convergence tolerance (default 1e-3))
verbose (print iteration progress)
- Returns:
h_opt
- Return type:
(d,) per-dimension optimal bandwidths
- sw2023.bandwidth_loocv(Z, y, h_ref=None, n_grid=15, verbose=False)[source]
Scalar multiplier LOO-CV bandwidth optimization.
Search for c* minimizing h_k = c* × h_ref_k. h_ref_k = σ̂_k × n^{-1/(d+4)} (optimal convergence rate reference)
SW(2023) constraints: lower bound c >= max(0.1, c_neff) ensures average effective neighbors >= max(5, 2(d+2)); upper bound h_k <= 3 × range(Z_k).
- Parameters:
Z ((n, d) explanatory variables)
y ((n,) dependent variable)
h_ref ((d,) reference bandwidth (auto-computed if None))
n_grid (number of coarse grid search points)
verbose (whether to print search progress)
- Returns:
h_opt
- Return type:
(d,) optimal bandwidth