ts_deterministic: Deterministic Univariate Predictor

View source: R/ts_deterministic.R

ts_deterministicR Documentation

Deterministic Univariate Predictor

Description

Forecast a univariate series using a deterministic law of formation instead of a statistical learner.

Usage

ts_deterministic(
  mode = c("periodic", "persist"),
  period = NULL,
  context_size = NULL
)

Arguments

mode

Character. Deterministic mode. Supported values are "periodic" and "persist".

period

Optional integer. Required when mode = "periodic".

context_size

Optional integer. Number of most recent values used to identify the next state in a periodic cycle. When omitted, the smallest non-ambiguous context is inferred from the learned cycle.

Details

ts_deterministic() defines a small family of rule-based predictors that can operate either on raw time series or on sliding-window inputs.

The current deterministic modes are:

  • "periodic": repeat a learned cycle of fixed length

  • "persist": repeat the most recent observed value

This family is useful for variables whose future behavior is structurally determined, such as:

  • day-of-week codes

  • weekend indicators

  • fixed operational calendars

  • slowly changing auxiliary variables

Because the forecasting rule is deterministic, the same object can be used in two contexts:

  • direct raw-series prediction, in the lineage of ts_arima()

  • sliding-window prediction, in the lineage of ts_regsw

In other words, ts_deterministic() unifies both views for cases where the predictive mechanism is a rule, not a learner over lagged attributes.

Value

A ts_deterministic object.

Examples

series <- c(4, 5, 6, 7, 1, 2, 3)
model <- ts_deterministic("periodic", period = 7)
model <- daltoolbox::fit(model, x = series)
predict(model, steps_ahead = 5)

sw <- ts_data(series, sw = 4)
io <- ts_projection(sw)
model <- daltoolbox::fit(ts_deterministic("persist"), io$input, io$output)
predict(model, io$input[1:2, ], steps_ahead = 1)

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