Title: | Analysis of Nonlinear Time Series |
---|---|
Description: | Routines for the analysis of nonlinear time series. This work is largely inspired by the TISEAN project, by Rainer Hegger, Holger Kantz and Thomas Schreiber: <http://www.mpipks-dresden.mpg.de/~tisean/>. |
Authors: | Antonio, Fabio Di Narzo |
Maintainer: | Antonio Fabio Di Narzo <[email protected]> |
License: | GPL-2 |
Version: | 0.1-13.1 |
Built: | 2024-11-10 06:43:13 UTC |
Source: | CRAN |
Sample correlation integral for the specified length scale
C2(series, m, d, t, eps)
C2(series, m, d, t, eps)
series |
time series |
m |
embedding dimension |
d |
time delay |
t |
Theiler window |
eps |
length scale |
Computes the sample correlation integral on the provided time series for the specified length scale, and considering a time window t
(see references). It uses a naif algorithm: simply returns the fraction of points pairs nearer than eps
. Normally, you would use d2
, which takes roughly the same time, but computes the correlation sum for multiple length scales and embedding dimensions at once.
The sample correlation integral at eps
length scale.
Antonio, Fabio Di Narzo
Hegger, R., Kantz, H., Schreiber, T., Practical implementation of nonlinear time series methods: The TISEAN package; CHAOS 9, 413-435 (1999)
Computes the sample correlation integral over a grid of neps
length scales starting from eps.min
, and for multiple embedding dimensions
d2(series, m, d, t, eps.min, neps=100)
d2(series, m, d, t, eps.min, neps=100)
series |
time series |
m |
max embedding dimension |
d |
time delay |
t |
Theiler window |
eps.min |
min length scale |
neps |
number of length scales to evaluate |
Computes the sample correlation integral over neps
length scales starting from eps.min
, for embedding dimension 1,...,m , considering a t
time window (see references). The slope of the linear segment in the log-log plot gives an estimate of the correlation dimension (see the example).
Matrix. Column 1: length scales. Column i=2, ..., m+1: sample correlation integral for embedding dimension i-1.
Antonio, Fabio Di Narzo
Hegger, R., Kantz, H., Schreiber, T., Practical implementation of nonlinear time series methods: The TISEAN package; CHAOS 9, 413-435 (1999)
d2(lorenz.ts, m=6, d=2, t=4, eps.min=2)
d2(lorenz.ts, m=6, d=2, t=4, eps.min=2)
Duffing oscillator system, to be used with sim.cont
To be used with sim.cont
Antonio, Fabio Di Narzo
Embedding of a time series with provided time delay and embedding dimension parameters.
embedd(x, m, d, lags)
embedd(x, m, d, lags)
x |
time series |
m |
embedding dimension (if lags missed) |
d |
time delay (if lags missed) |
lags |
vector of lags (if m and d are missed) |
Embedding of a time series with provided delay and dimension parameters.
Matrix with columns corresponding to lagged time series.
Antonio, Fabio Di Narzo. Multivariate time series patch by Jonathan Shore.
library(scatterplot3d) x <- window(rossler.ts, start=90) xyz <- embedd(x, m=3, d=8) scatterplot3d(xyz, type="l") ## embedding multivariate time series series <- cbind(seq(1,50),seq(101,150)) head(embedd(series, m=6, d=1))
library(scatterplot3d) x <- window(rossler.ts, start=90) xyz <- embedd(x, m=3, d=8) scatterplot3d(xyz, type="l") ## embedding multivariate time series series <- cbind(seq(1,50),seq(101,150)) head(embedd(series, m=6, d=1))
Method of false nearest neghbours to help deciding the optimal embedding dimension
false.nearest(series, m, d, t, rt=10, eps=sd(series)/10)
false.nearest(series, m, d, t, rt=10, eps=sd(series)/10)
series |
time series |
m |
maximum embedding dimension |
d |
delay parameter |
t |
Theiler window |
rt |
escape factor |
eps |
neighborhood diameter |
Method of false nearest neighbours to help deciding the optimal embedding dimension.
Fraction of false neighbors (first row) and total number of neighbors (second row) for each specified embedding dimension (columns)
Antonio, Fabio Di Narzo
Hegger, R., Kantz, H., Schreiber, T., Practical implementation of nonlinear time series methods: The TISEAN package; CHAOS 9, 413-435 (1999)
Kennel M. B., Brown R. and Abarbanel H. D. I., Determining embedding dimension for phase-space reconstruction using a geometrical construction, Phys. Rev. A, Volume 45, 3403 (1992).
(fn.out <- false.nearest(rossler.ts, m=6, d=8, t=180, eps=1, rt=3)) plot(fn.out)
(fn.out <- false.nearest(rossler.ts, m=6, d=8, t=180, eps=1, rt=3)) plot(fn.out)
Lorenz system, to be used with sim.cont
To be used with sim.cont
Antonio, Fabio Di Narzo
Lorenz simulated time series, without noise. Of each state of the system, we observe the euclidean norm.
Lorenz simulated time series, without noise, obtained with the call:
lorenz.ts <- sim.cont(lorenz.syst, 0, 100, 0.05, start.x=c(5,5,5), parms=c(10, 28, -8/3), obs.fun = function(x) sqrt(sum(x^2)))
Antonio, Fabio Di Narzo
Tools to evaluate the maximal Lyapunov exponent of a dynamic system from a univariate time series
lyap_k(series, m, d, t, k=1, ref, s, eps) lyap(dsts, start, end)
lyap_k(series, m, d, t, k=1, ref, s, eps) lyap(dsts, start, end)
series |
time series |
m |
embedding dimension |
d |
time delay |
k |
number of considered neighbours |
eps |
radius where to find nearest neighbours |
s |
iterations along which follow the neighbours of each point |
ref |
number of points to take into account |
t |
Theiler window |
dsts |
Should be the output of a call to |
start |
Starting time of the linear bite of |
end |
Ending time of the linear bite of |
The function lyap_k
estimates the largest Lyapunov exponent of a given scalar time series using the algorithm of Kantz.
The function lyap
computes the regression coefficients of a user specified segment of the sequence given as input.
lyap_k
gives the logarithm of the stretching factor in time.
lyap
gives the regression coefficients of the specified input sequence.
Antonio, Fabio Di Narzo
Hegger, R., Kantz, H., Schreiber, T., Practical implementation of nonlinear time series methods: The TISEAN package; CHAOS 9, 413-435 (1999)
M. T. Rosenstein, J. J. Collins, C. J. De Luca, A practical method for calculating largest Lyapunov exponents from small data sets, Physica D 65, 117 (1993)
mutual
, false.nearest
for the choice of optimal embedding parameters.
embedd
to perform embedding.
output <-lyap_k(lorenz.ts, m=3, d=2, s=200, t=40, ref=1700, k=2, eps=4) plot(output) lyap(output, 0.73, 2.47)
output <-lyap_k(lorenz.ts, m=3, d=2, s=200, t=40, ref=1700, k=2, eps=4) plot(output) lyap(output, 0.73, 2.47)
Estimates the average mutual information index (ami) of a given time series for a specified number of lags
mutual(series, partitions = 16, lag.max = 20, plot=TRUE, ...)
mutual(series, partitions = 16, lag.max = 20, plot=TRUE, ...)
series |
time series |
partitions |
number of bins |
lag.max |
largest lag |
plot |
logical. If 'TRUE' (the default) the ami is plotted |
... |
further arguments to be passed to the plot method |
Estimates the mutual information index for a specified number of lags. The joint probability distribution function is estimated with a simple bi-dimensional density histogram.
An object of class "ami", which is a vector containing the estimated mutual information index for each lag between 0 and lag.max
.
Antonio, Fabio Di Narzo
Hegger, R., Kantz, H., Schreiber, T., Practical implementation of nonlinear time series methods: The TISEAN package; CHAOS 9, 413-435 (1999)
mutual(lorenz.ts)
mutual(lorenz.ts)
Plotting method for objects inheriting from class '"ami"'.
## S3 method for class 'ami' plot(x, main = NULL, ...)
## S3 method for class 'ami' plot(x, main = NULL, ...)
x |
'"ami"' object |
main , ...
|
additional graphical arguments |
Plots the ami for each lag in x
.
Antonio, Fabio Di Narzo
Plotting method for objects inheriting from class '"d2"'.
## S3 method for class 'd2' plot(x, ...)
## S3 method for class 'd2' plot(x, ...)
x |
'"d2"' object |
... |
additional graphical arguments |
Plots the sample correlation integrals in x
in log-log scale, as a line for each considered embedding dimension.
Antonio, Fabio Di Narzo
Plotting method for objects inheriting from class '"false.nearest"'.
## S3 method for class 'false.nearest' plot(x, ...)
## S3 method for class 'false.nearest' plot(x, ...)
x |
'"false.nearest"' object |
... |
additional graphical arguments |
Plots the results of false.nearest
.
Antonio, Fabio Di Narzo
Printing method for objects inheriting from class '"d2"'.
## S3 method for class 'd2' print(x, ...)
## S3 method for class 'd2' print(x, ...)
x |
'"d2"' object |
... |
additional arguments to 'print' |
Simply calls plot.d2
.
Antonio, Fabio Di Narzo
Printing method for objects inheriting from class '"false.nearest"'.
## S3 method for class 'false.nearest' print(x, ...)
## S3 method for class 'false.nearest' print(x, ...)
x |
'"false.nearest"' object |
... |
additional arguments to 'print' |
Prints the table of results of false.nearest
.
Antonio, Fabio Di Narzo
plot.false.nearest
, false.nearest
Recurrence plot
recurr(series, m, d, start.time=start(series), end.time=end(series), ...)
recurr(series, m, d, start.time=start(series), end.time=end(series), ...)
series |
time series |
m |
embedding dimension |
d |
time delay |
start.time |
starting time window (in time units) |
end.time |
ending time window (in time units) |
... |
further parameters to be passed to |
Produces the recurrence plot, as proposed by Eckmann et al. (1987). White is maximum distance, black is minimum.
Be awared that number of distances to store goes as n^2
, where n = length(window(series, start=start.time, end=end.time))
!
Antonio, Fabio Di Narzo
Eckmann J.P., Oliffson Kamphorst S. and Ruelle D., Recurrence plots of dynamical systems, Europhys. Lett., volume 4, 973 (1987)
recurr(lorenz.ts, m=3, d=2, start.time=15, end.time=20)
recurr(lorenz.ts, m=3, d=2, start.time=15, end.time=20)
Roessler system of equations
To be used with sim.cont
.
Antonio, Fabio Di Narzo
Roessler simulated time series, without noise. Of each state of the system, we observe the first component.
Roessler simulated time series, without noise, obtained with the call:
rossler.ts <- sim.cont(rossler.syst, start=0, end=650, dt=0.1, start.x=c(0,0,0), parms=c(0.15, 0.2, 10))
Antonio, Fabio Di Narzo
Simulates a dynamic system of provided ODEs
sim.cont(syst, start.time, end.time, dt, start.x, parms=NULL, obs.fun=function(x) x[1])
sim.cont(syst, start.time, end.time, dt, start.x, parms=NULL, obs.fun=function(x) x[1])
syst |
ODE system |
start.time |
starting time |
end.time |
ending time |
dt |
time between observations |
start.x |
initial conditions |
parms |
parameters for the system |
obs.fun |
observed function of the state |
Simulates a dynamic system of provided ODEs.
Uses lsoda
in odesolve
for numerical integration of the system.
The time series of the observed function of the system's state
Antonio, Fabio Di Narzo
lorenz.syst
, rossler.syst
, duffing.syst
rossler.ts <- sim.cont(rossler.syst, start=0, end=650, dt=0.1, start.x=c(0,0,0), parms=c(0.15, 0.2, 10))
rossler.ts <- sim.cont(rossler.syst, start=0, end=650, dt=0.1, start.x=c(0,0,0), parms=c(0.15, 0.2, 10))
Space-time separation plot
stplot(series, m, d, idt=1, mdt)
stplot(series, m, d, idt=1, mdt)
series |
time series |
m |
embedding dimension |
d |
time delay |
idt |
observation steps in each iteration |
mdt |
number of iterations |
Produces the space-time separation plot, as introduced by Provenzale et al. (1992), which can be used to decide the Theiler time window t
, which is required in many other algorithms in this package.
It plots the probability that two points in the reconstructed phase-space have distance smaller than epsilon in function of epsilon and of the time t between the points, as iso-lines at levels 10%, 20%, ..., 100%.
lines of costant probability at 10%, 20%, ..., 100%.
Antonio, Fabio Di Narzo
Kantz H., Schreiber T., Nonlinear time series analysis. Cambridge University Press, (1997)
Provenzale A., Smith L. A., Vio R. and Murante G., Distiguishing between low-dimensional dynamics and randomness in measured time series. Physica D., volume 58, 31 (1992)
stplot(rossler.ts, m=3, d=8, idt=1, mdt=250)
stplot(rossler.ts, m=3, d=8, idt=1, mdt=250)