Generates simulated time series lists for testing and learning.
This function supports progress bars generated by the progressr
package, and accepts a parallelization setup via future::plan()
(see examples).
Arguments
- n
(optional, integer) Number of time series to simulate. Default: 2.
- cols
(optional, integer) Number of columns of each time series. Default: 5
- rows
(optional, integer) Length of each time series. Minimum is 10, but maximum is not limited. Very large numbers might crash the R session. Default: 100
- time_range
(optional character or numeric vector) Time interval of the time series. Either a character vector with dates in format YYYY-MM-DD or or a numeric vector. If there is a mismatch between
time_range
androws
(for example, the number of days intime_range
is smaller thanrows
), the upper value intime_range
is adapted torows
. Default: c("2010-01-01", "2020-01-01")- data_range
(optional, numeric vector of length 2) Extremes of the time series values. Default: c(0, 1)
- seasons
(optional, integer) Number of seasons in the resulting time series. The maximum number of seasons is computed as
floor(rows/3)
. Default: 0- na_fraction
(optional, numeric) Value between 0 and 0.5 indicating the approximate fraction of NA data in the simulated time series. Default: 0.
- independent
(optional, logical) If TRUE, each new column in a simulated time series is averaged with the previous column to generate dependency across columns, and each new simulated time series is weighted-averaged with a time series template to generate dependency across time series. Irrelevant when
cols < 2
orn < 2
, and hard to perceive in the output whenseasons > 0
. Default: FALSE- irregular
(optional, logical) If TRUE, the time intervals between consecutive samples and the number of rows are irregular. Default: TRUE
- seed
(optional, integer) Random seed used to simulate the zoo object. If NULL (default), a seed is selected at random. Default: NULL
See also
Other simulate_time_series:
zoo_simulate()
Examples
# generates a different time series list on each iteration when seed = NULL
tsl <- tsl_simulate(
n = 2,
seasons = 4
)
if(interactive()){
tsl_plot(
tsl = tsl
)
}
# generate 3 independent time series
tsl_independent <- tsl_simulate(
n = 3,
cols = 3,
independent = TRUE
)
if(interactive()){
tsl_plot(
tsl = tsl_independent
)
}
# generate 3 independent time series
tsl_dependent <- tsl_simulate(
n = 3,
cols = 3,
independent = FALSE
)
if(interactive()){
tsl_plot(
tsl = tsl_dependent
)
}
# with seasons
tsl_seasons <- tsl_simulate(
n = 3,
cols = 3,
seasons = 4,
independent = FALSE
)
if(interactive()){
tsl_plot(
tsl = tsl_seasons
)
}