tsl_simulate | R Documentation |
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).
tsl_simulate(
n = 2,
cols = 5,
rows = 100,
time_range = c("2010-01-01", "2020-01-01"),
data_range = c(0, 1),
seasons = 0,
na_fraction = 0,
independent = FALSE,
irregular = TRUE,
seed = NULL
)
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 |
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 |
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 |
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 |
time series list
Other simulate_time_series:
zoo_simulate()
# 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
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.