simulateDriver: Generates a random time series with temporal autocorrelation.

View source: R/simulateDriver.R

simulateDriverR Documentation

Generates a random time series with temporal autocorrelation.

Description

Generates a vector of the same legnth as the time argument, with a temporal autocorrelation length close to the defined by autocorrelation.length, and a range within output.min and output.max. The output of this function is intended to be used as an input to the function simulatePopulation. Important: note that the variable time runs from left to right in simulatePopulation, with lower values representing older samples.

Usage

simulateDriver(
  random.seed = 30,
  time = 1:10000,
  autocorrelation.length = 100,
  output.min = 0,
  output.max = 100,
  rescale = TRUE
  )

Arguments

random.seed

integer, seed to be used by set.seed(). Default is 50.

time

integer, or numeric vector of integers with constant intervals. If a single integer is provided, a time sequence is generated from 1 to the given integer as seq(1, time, by = 1). Default is 1:10000.

autocorrelation.length

integer, represents the length of the convolution filter to be used to impose a particular temporal structure on the time series. Default is 100, equivalent to a filter composed by a hundred of ones.

output.min

numeric, minimum value of the output time series. Used as input forrescaleVector. Default is 0.

output.max

numeric, maximum value of the output time series. Used as input for rescaleVector. Default is 100.

rescale

boolean. If FALSE, output.min and output.max are ignored, and the original data range provided by rnorm is preserved. Default is TRUE.

Details

It is recommended to use time vectors with a time step of 1 between consecutive values when the output is to be used as input for simulatePopulation, which considers annual time-steps while simulating virtual pollen curves. The initial random sequence of numers is generated by rnorm. Desired temporal autocorrelation are approximate, but deviation becomes higher if autocorrelation.length is larger than half the length of time. Consequently, the function limits autocorrelation.length to length(time)/2.

Value

A vector of the same length as time. Datasets driverA and driverB are outputs of this function.

Author(s)

Blas M. Benito <blasbenito@gmail.com>

See Also

rescaleVector, driverA, driverB, set.seed

Examples


x <- simulateDriver(
  random.seed = 30,
  time = 1:10000,
  autocorrelation.length = 100,
  output.min = -10,
  output.max = 20,
  rescale = TRUE
  )

#plots output
plot(x, type = "l")

#checks temporal autocorrelation
acf(x, lag.max = 300)


virtualPollen documentation built on March 18, 2022, 6:16 p.m.