Learn R Programming

SuperGauss (version 2.0.3)

rnormtz: Simulate a stationary Gaussian time series.

Description

Simulate a stationary Gaussian time series.

Usage

rnormtz(n = 1, acf, Z, fft = TRUE, nkeep, tol = 1e-06)

Arguments

n

Number of time series to generate.

acf

Length-N vector giving the autocorrelation of the series.

Z

Optional size (2N-2) x n or N x n matrix of iid standard normals, to use in the FFT and Durbin-Levinson methods, respectively.

fft

Logical; whether or not to use the O(N log N) FFT-based algorithm of Wood and Chan (1994) or the more stable O(N^2) Durbin-Levinson algorithm. See Details.

nkeep

Length of time series. Defaults to N = length(acf). See Details.

tol

Relative tolerance on negative eigenvalues. See Details.

Value

Length-nkeep vector or size nkeep x n matrix with time series as columns.

Details

The FFT method fails when the embedding circulant matrix is not positive definite. This is typically due to one of two things:

  1. Roundoff error can make tiny eigenvalues appear negative. For this purpose, argument tol can be used to replace all negative eigenvalues by tol * ev_max, where ev_max is the largest eigenvalue.

  2. The autocorrelation is decaying too slowly on the given timescale. To mitigate this, argument nkeep can be used to supply a longer acf than is required, and keep only the first nkeep time series observations. For consistency, nkeep also applies to Durbin-Levinson method.

Examples

Run this code
# NOT RUN {
N <- 10
acf <- exp(-(1:N - 1)/N)
rnormtz(n = 3, acf = acf)
# }

Run the code above in your browser using DataLab