Simulation of a stationary Gaussian time series.
rSnorm(n = 1, acf, Z, fft = TRUE, nkeep, tol = 1e-06)
Number of time series to generate.
Length-N
vector giving the autocorrelation of the series.
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.
Logical, whether or not to use the superfast FFT-based algorithm of Chan and Wood or the more stable Durbin-Levinson algorithm. See Details.
Length of time series. Defaults to N = length(acf)
. See Details.
Relative tolerance on negative eigenvalues. See Details.
Length-nkeep
vector or size nkeep x n
matrix with time series as columns.
The superfast method fails when the circulant matrix is not positive definite. This is typically due to one of two things, for which the FFT algorithm can be tuned with tol
and nkeep
:
tol
Roundoff error can make tiny eigenvalues appear negative. If evMax
is the maximum eigenvalue, then all negative eigenvalues of magnitude less than tol * evMax
are mapped to this threshold value. This does not guarantee a positive definite embedding.
nkeep
The autocorrelation is decaying too slowly on the given timescale. To mitigate this it is possible to increase the time horizon, i.e. input a longer acf
and keep the first nkeep
time series observations. For consistency, nkeep
also applies to Durbin-Levinson method.
# NOT RUN {
N <- 10
acf <- exp(-(1:N - 1))
rSnorm(n = 3, acf = acf)
# }
Run the code above in your browser using DataLab