fit_synthesizer.ts: Fit a synthesizer to a (multivariate) time series

View source: R/timeseries.R

fit_synthesizer.tsR Documentation

Fit a synthesizer to a (multivariate) time series

Description

Methods for ts objects. Four generators are available:

  • "copula_var" (default): each series is mapped to normal scores through its empirical marginal distribution; a vector autoregression (order chosen by AIC) is fitted to the scores, and simulated paths are mapped back through the marginal quantile functions. This reproduces the marginal distributions and the auto- and cross-correlation structure. Innovations are resampled from the fitted residuals, so their joint distribution is preserved.

  • "block": moving (circular) block bootstrap of the observed series.

  • "stationary": stationary bootstrap (Politis and Romano, 1994) with geometrically distributed block lengths.

  • "iid": ignores serial dependence; rows are drawn from a cross-sectional copula model (see fit_synthesizer()).

Missing values are linearly interpolated before fitting (with a warning).

Scope. All four methods treat the series as (approximately) stationary: the empirical marginal distribution and the dependence structure are assumed constant over time. A trend, a level shift, changing variance or strong deterministic seasonality is reproduced only imperfectly (e.g. a trending series is resampled around its overall distribution, and a seasonal pattern only as far as the VAR order or block length covers it). For such data, model the deterministic part yourself (detrend, difference or deseasonalise), synthesise the stationary remainder, and add the deterministic part back. Arguments that the chosen method does not use trigger a warning.

Usage

## S3 method for class 'ts'
fit_synthesizer(
  data,
  method = c("copula_var", "block", "stationary", "iid"),
  max_lag = 10L,
  order = NULL,
  block_length = NULL,
  burn_in = 100L,
  seed = NULL,
  ...
)

Arguments

data

A ts object (univariate or multivariate).

method

One of "copula_var", "block", "stationary", "iid".

max_lag

Maximum VAR order considered by "copula_var" when the order is selected by AIC.

order

Optional fixed VAR order for "copula_var" (skips AIC selection). Useful for seasonal data on short series, where AIC tends to choose an order below the seasonal period, e.g. order = 12 for monthly data.

block_length

Block length ("block") or mean block length ("stationary"). Default: ceiling(n^(1/3)).

burn_in

Number of burn-in steps discarded when simulating a VAR.

seed

Optional random seed making the fit reproducible (see fit_synthesizer()).

...

Passed to fit_synthesizer.data.frame() when method = "iid".

Value

An object of class sp_ts_synthesizer. Use generate() to draw synthetic series of any length; the result is a ts with the same frequency (and, by default, the same start) as data.

References

Politis, D. N. and Romano, J. P. (1994). The stationary bootstrap. Journal of the American Statistical Association, 89(428), 1303–1313. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1994.10476870")}

Examples

fit <- fit_synthesizer(ldeaths)
syn <- generate(fit, seed = 1)
plot_ts(ldeaths, syn)

# window() keeps the ts class (row-subsetting with [1:500, ] would not)
eu <- window(EuStockMarkets, end = time(EuStockMarkets)[500])
fit_mv <- fit_synthesizer(eu, method = "stationary")
head(generate(fit_mv, n = 100, seed = 1))

SynthesizerPlus documentation built on Oct. 16, 2026, 5:10 p.m.