cv_tune_seq: Purged/embargoed K-fold CV for sequence models (inside IS...

cv_tune_seqR Documentation

Purged/embargoed K-fold CV for sequence models (inside IS window)

Description

Purged/embargoed K-fold CV for sequence models (inside IS window)

Usage

cv_tune_seq(
  features_list,
  labels,
  is_start,
  is_end,
  steps_grid = c(12L, 26L, 52L),
  horizon = 4L,
  fit_fn,
  predict_fn,
  k = 3L,
  purge = NULL,
  embargo = NULL,
  group = c("pooled"),
  max_train_samples = NULL,
  max_val_samples = NULL,
  na_action = c("omit", "zero"),
  metric = c("spearman", "rmse")
)

Arguments

features_list

List of feature panels (Date + symbols) for sequences.

labels

Label panel aligned to features (Date + symbols).

is_start, is_end

Inclusive IS window indices (on aligned dates).

steps_grid

Integer vector of candidate sequence lengths.

horizon

Forecast horizon (periods ahead).

fit_fn

Function (X, y) -> model for sequences.

predict_fn

Function (model, Xnew) -> numeric scores.

k

Number of CV folds.

purge

Gap (obs) removed between train/val within folds (default uses steps).

embargo

Embargo (obs) after validation to avoid bleed (default uses horizon).

group

'pooled', 'per_symbol', or 'per_group'.

max_train_samples

Optional cap on IS samples per fold.

max_val_samples

Optional cap on validation samples per fold.

na_action

How to handle NA features ('omit' or 'zero').

metric

IC metric ('spearman' or 'pearson').

Value

data.table with columns like steps, folds, and CV score.


PortfolioTesteR documentation built on Nov. 5, 2025, 5:23 p.m.