surrogate
Generate Surrogate Data and Statistics
Generates ns
surrogate samples from the original data x
and computes the standard error and the bias of statistic
as in
a bootstrap setup, if statistic
is given.
- Keywords
- ts
Usage
surrogate(x, ns = 1, fft = FALSE, amplitude = FALSE,
statistic = NULL, ...)
Arguments
- x
- a numeric vector or time series.
- ns
- the number of surrogate series to compute.
- fft
- a logical indicating whether phase randomized surrogate data is generated.
- amplitude
- a logical indicating whether amplitude-adjusted surrogate data is computed.
- statistic
- a function which when applied to a time series returns a vector containing the statistic(s) of interest.
- ...
- Additional arguments for
statistic
which are passed unchanged each time it is called.
Details
If fft
is FALSE
, then x
is mixed in temporal
order, so that all temporal dependencies are eliminated, but the
histogram of the original data is preserved. If fft
is
TRUE
, then surrogate data with the same spectrum as x
is
computed by randomizing the phases of the Fourier coefficients of
x
. If in addition amplitude
is TRUE
, then also
the amplitude distribution of the original series is preserved.
Note, that the interpretation of the computed standard error and bias is different than in a bootstrap setup.
To compute the phase randomized surrogate and the amplitude adjusted data algorithm 1 and 2 from Theiler et al. (1992), pp. 183, 184 are used. Missing values are not allowed.
Value
- If
statistic
isNULL
, then it returns a matrix or time series withns
columns andlength(x)
rows containing the surrogate data. Each column contains one surrogate sample.If
statistic
is given, then a list of class"resample.statistic"
with the following elements is returned: statistic the results of applying statistic
to each of the simulated time series.orig.statistic the results of applying statistic
to the original series.bias the bias of the statistics computed as in a bootstrap setup. se the standard error of the statistics computed as in a bootstrap setup. call the original call of surrogate
.
References
J. Theiler, B. Galdrikian, A. Longtin, S. Eubank, and J. D. Farmer (1992): Using Surrogate Data to Detect Nonlinearity in Time Series, in Nonlinear Modelling and Forecasting, Eds. M. Casdagli and S. Eubank, Santa Fe Institute, Addison Wesley, 163--188.
See Also
Examples
x <- 1:10 # Simple example
surrogate(x)
n <- 500 # Generate AR(1) process
e <- rnorm(n)
x <- double(n)
x[1] <- rnorm(1)
for(i in 2:n) {
x[i] <- 0.4 * x[i-1] + e[i]
}
x <- ts(x)
theta <- function(x) # Autocorrelations up to lag 10
return(acf(x, plot=FALSE)$acf[2:11])
surrogate(x, ns=50, fft=TRUE, statistic=theta)