Function to compute 0-1 test for chaos

Share:

Description

This function computes results of the 0-1 test for chaos from the numeric vector (time series).

Usage

1
2
testChaos01(vec.x, c.rep = 100, alpha = 0, out = FALSE, c.int = c(pi/5,
  4 * pi/5), c.gen = "random", par = "seq", num.threads = NA)

Arguments

vec.x

the input vector. This should be a numeric vector.

c.rep

integer, defines how many different parameters "c" should be used for the computation. Default is 100.

alpha

numeric, the noise dampening parameter. If 0, no noise dampening is done. For more details see the Gottwald and Melbourne (2004). Default is 0.

out

logical, if TRUE return the list of class "chaos01.res". This list contain lists of "chaos01" list with values of pc, qc, Mc, Dc, Kc and c. These can be then easily plotted by the plot function. Default is FALSE.

c.int

set the interval from which the parameter "c" should be chosen. The input is numeric vector. The minimal and maximal value in the vector is then chosen as the minimum and maximum for the generation of parameters "c". Generally it is not needed to change this value. Default is c(pi/5, 4*pi/5).

c.gen

character string, which defines how the parameter "c" should be generated from the interval defined by c.int.

  • "random" - draws from uniform distribution

  • "equal" - equidistant distribution

Default is "random". Note: If there is unrecognized input, it will use default.

par

character string, determine whether make the computation for every parameter "c" sequentially or in parallel. Parallelization is provided by the package "parallel" for one machine, or the cluster option using package "Rmpi" is available.

  • "seq" - sequential run

  • "parallel" - parallel on one machine

  • "MPI" - run parallel using Rmpi.

When the work with MPI is finished, the Rmpi::mpi.finalize(), must be used to properly close the MPI. After that command, it is impossible to run MPI until restarting the R session, therefore use it after all runs of the test.

Default is "seq". Note: If there is unrecognized input, it will use default.

num.threads

integer, number of threads use for the computation. When the computation is sequential, this is ignored. Default is NA.

Details

Note that this test does not work in several cases.

  • In general, time series have to approach steady state, that is it's attractor. E.g. if the time series corresponds to homoclinic trajectory, the output of the test should not be close to 0 or 1.

  • The time series contain too much noise. See examples.

  • The time series is behaving like a white noise.

In these cases you may receive unclear results, or in special cases the false results. You can find more on the validity of the test in Gottwald and Melbourne (2009).

Value

A numeric from the interval (0,1). 0 stands for the regular dynamics and 1 for the chaotic dynamics. If the parameter out = TRUE, the output is list of list of all the computed variables. This is mainly for research and testing purposes.

References

Gottwald G.A. and Melbourne I. (2004) On the implementation of the 0-1 Test for Chaos, SIAM J. Appl. Dyn. Syst., 8(1), 129–145.

Gottwald G.A. and Melbourne I. (2009) On the validity of the 0-1 Test for Chaos, Nonlinearity, 22, 6

See Also

plot.chaos01, plot.chaos01.res

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
vec.x <- gen.logistic(mu = 3.55, iter = 2000)

#The median of Kc
res <- testChaos01(vec.x)
print(res)

#Output for each value of c
res2 <- testChaos01(vec.x, out = TRUE)

summary(res2[[1]])
head(res2[[1]]$pc)
print(res2[[1]]$Kc)

class(res2)
class(res2[[1]])

## Not run: 
#Introducing noise
vec.x2 <- vec.x + runif(2000, 0, 0.1)

res.orig <- testChaos01(vec.x, alpha = 0)
res.damp <- testChaos01(vec.x, alpha = 2.5)

sprintf(Original test result %s\n Dampened test result %s, res.orig, res.damp)

#Parallel
res <- testChaos01(vec.x, par = "parallel", num.treads = 2)

#Parallel cluster
res <- testChaos01(vec.x, par = "MPI", num.treads = 2)
Rmpi::mpi.finalize()

#Different interval for generating c
res <- testChaos01(vec.x, c.int = c(0, pi))

## End(Not run)