generate_random_ts {tstools}R Documentation

Generate a list of random time series

Description

Useful for development or generating easily reproducible examples

Usage

generate_random_ts(
  n = 1,
  lengths = 36,
  starts = 1988,
  frequencies = 12,
  ranges_min = -1,
  ranges_max = 1,
  shifts = 0,
  ts_names = sprintf("ts%d", 1:n),
  seed = 30042018,
  random_NAs = FALSE,
  random_NA_proportions = 0.1,
  normally_distributed = FALSE,
  normal_means = 0,
  normal_sds = 1,
  frequency_shifts = FALSE,
  frequency_shift_after = 0.5
)

Arguments

n

The number of ts objects to generate

lengths

The lengths of the time series

starts

The start points of the time series in single number notation (e.g. 1990.5)

frequencies

The frequencies of the time series

ranges_min

The minimum values of the time series (if normally_distributed == FALSE)

ranges_max

The maximum values of the time series (if normally_distributed == FALSE)

shifts

The shifts of time series values per series

ts_names

The names of the ts objects in the resulting list

seed

The random seed to be used

random_NAs

Whether or not to introcude NA values at random positions in the ts

random_NA_proportions

The fraction of values to be replaced with NAs if random_NAs is TRUE for the series

normally_distributed

Use normal distribution instead of uniform

normal_means

The means to use for normal distribution. Ignored unless normally_distributed is set to TRUE.

normal_sds

The sds to use for normal distribution. Ignored unless normally_distributed is set to TRUE.

frequency_shifts

Introduce frequency shifts (from 4 to 12) in the ts

frequency_shift_after

After what fraction of the ts to shift frequencies

Details

Except for n and ts_names, all parameters accept either a single value or a vector of values. If a single value is supplied, that value is used for all time series being generated. If a vector is supplied, its values will be used for the corresponding series (e.g. starts[1] is used for the first series, starts[2] for the second and so on). Vectors are recycled if n is larger than their length.

If a ts_names vector is supplied, it must have length n and must not contain duplicates.

Value

A list of ts objects

Examples

generate_random_ts()

generate_random_ts(n = 3, ranges_min = c(-10, 0, 10), ranges_max = 20, starts = 2011)

[Package tstools version 0.4.3 Index]