tune_vem_by_gcv: Tune Basis Complexity via GCV

View source: R/tune_vem_by_gcv.R

tune_vem_by_gcvR Documentation

Tune Basis Complexity via GCV

Description

Fits vem_smooth across a grid of candidate basis sizes K_grid and selects the best K using GCV scores from gcv_vem. Called internally by vem_fit when a vector of K values is supplied; not typically called directly.

Two selection modes are supported: "mean" selects the single K minimizing the mean GCV across all curves; "per_curve" selects the K that minimizes the GCV criterion for each individual curve, producing a composite fit.

Usage

tune_vem_by_gcv(
  y,
  Xt,
  K_grid,
  build_B,
  initial_values_fn,
  threshold = 0.5,
  mode = c("mean", "per_curve"),
  ...
)

Arguments

y

List of curves.

Xt

Numeric vector of time points.

K_grid

Integer vector of candidate K values.

build_B

Function with signature function(K, Xt, y) that returns a list of n \times K basis matrices.

initial_values_fn

Function with signature function(K, m) that returns an initial_values list for vem_smooth.

threshold

Posterior inclusion probability (PIP) threshold passed to gcv_vem. Default 0.5.

mode

Character. "mean" for a single global K; "per_curve" for curve-specific K. Default "mean".

...

Additional arguments passed to vem_smooth.

Value

A list with:

fits

Named list of fitted vem_smooth objects, one per candidate K.

gcv_matrix

Numeric matrix (m \times length(K_grid)) of per-curve GCV scores.

best_K_mean

Integer. Best K by mean GCV.

best_K_per_curve

Integer vector of length m. Best K for each curve.

References

da Cruz, A. C., de Souza, C. P. E., & Sousa, P. H. T. O. (2024). Fast Bayesian basis selection for functional data representation with correlated errors. arXiv:2405.20758. https://arxiv.org/abs/2405.20758

See Also

vem_fit, gcv_vem


fda.vi documentation built on June 20, 2026, 5:06 p.m.