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.
# S3 method for ts
fit_synthesizer(
data,
method = c("copula_var", "block", "stationary", "iid"),
max_lag = 10L,
order = NULL,
block_length = NULL,
burn_in = 100L,
seed = NULL,
...
)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.
A ts object (univariate or multivariate).
One of "copula_var", "block", "stationary", "iid".
Maximum VAR order considered by "copula_var" when the
order is selected by AIC.
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") or mean block length
("stationary"). Default: ceiling(n^(1/3)).
Number of burn-in steps discarded when simulating a VAR.
Optional random seed making the fit reproducible (see
fit_synthesizer()).
Passed to fit_synthesizer.data.frame() when method = "iid".
Politis, D. N. and Romano, J. P. (1994). The stationary bootstrap. Journal of the American Statistical Association, 89(428), 1303--1313. tools:::Rd_expr_doi("10.1080/01621459.1994.10476870")
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))
Run the code above in your browser using DataLab