| fit_synthesizer.ts | R Documentation |
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 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,
...
)
data |
A |
method |
One of |
max_lag |
Maximum VAR order considered by |
order |
Optional fixed VAR order for |
block_length |
Block length ( |
burn_in |
Number of burn-in steps discarded when simulating a VAR. |
seed |
Optional random seed making the fit reproducible (see
|
... |
Passed to |
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.
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")}
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.