ts_lagmap: Lag Mapping for Sliding-Window Predictors

View source: R/ts_lagmap.R

ts_lagmapR Documentation

Lag Mapping for Sliding-Window Predictors

Description

Configure how a sliding-window predictor chooses the input_size lagged attributes that will be fed to the underlying regression model.

Usage

ts_lagmap(
  method = c("recent", "even", "geom", "acf", "pacf", "peaks", "seasonal",
    "acf_seasonal", "pacf_seasonal", "blocks", "mi", "mrmr"),
  seasonality = NULL,
  peak_basis = c("acf", "pacf"),
  block_radius = 1,
  bins = 8
)

Arguments

method

Character. Lag-selection strategy: "recent", "even", "geom", "acf", "pacf", "peaks", "seasonal", "acf_seasonal", "pacf_seasonal", "blocks", "mi", or "mrmr".

seasonality

Optional integer. Seasonal period used by the seasonal lag selectors. If NULL, an estimate is derived from the training series.

peak_basis

Character. Correlation profile used by "peaks" and "blocks": "acf" or "pacf".

block_radius

Integer. Radius around each selected center when method = "blocks".

bins

Integer. Number of quantile bins used by the mutual-information criteria.

Details

The lag mapper is fitted on the training data before the base predictor is trained. During fit(), the mapper stores a vector of selected lag columns. The default "recent" method reproduces the historical behavior of the package: it keeps the most recent input_size observations available in the sliding window.

When ts_lagmap() is used inside a ts_regsw model, the mapper is fitted after the model preprocessor has transformed the training windows. So the selected positions refer to the representation actually seen by the backend, not necessarily to the raw pre-transform window geometry.

Correlation-based methods operate on the raw training series reconstructed from the input windows and aligned outputs. Supervised methods ("mi" and "mrmr") inspect the relationship between each lagged attribute and the training target.

Value

A ts_lagmap object.

References

  • Box GEP, Jenkins GM, Reinsel GC, Ljung GM (2015). Time Series Analysis: Forecasting and Control. Fifth Edition. Wiley.

  • Peng H, Long F, Ding C (2005). Feature selection based on mutual information criteria of max-dependency, max-relevance, and min-redundancy. IEEE Transactions on Pattern Analysis and Machine Intelligence, 27(8), 1226-1238. doi:10.1109/TPAMI.2005.159

  • Leites J, Cerqueira V, Soares C (2024). Selecting time lags for time series forecasting: an empirical study. arXiv:2405.11237.

Examples

library(daltoolbox)
library(tspredit)
data(tsd)

ts <- ts_data(tsd$y, 10)
io <- ts_projection(ts)

mapper <- ts_lagmap(method = "pacf")
mapper <- daltoolbox::fit(mapper, io$input, io$output, input_size = 4)
mapper$lags
mapper$columns

tspredit documentation built on Sept. 9, 2026, 9:08 a.m.