# Nonlinear systems

**quantsignals » R**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There is a long standing debate if financial systems are truly random or contain some structure. From the study of non-linear dynamical systems and chaos one finds it is possible that even perfectly deterministic systems can appear to be random. Those systems tend to be predictable on short time scales but neighboring states quickly diverge, leaving the operator incapable of forecasting future outcomes beyond a characteristic time scale. Still, the study of these systems provides insights and technics for forecasting, state classification and control. For machine learning applications data from chaotic model systems can be a benchmark for tuning and selection of learning algorithms.

In this post I will briefly explore the ‘R’ package “tseriesChaos” and demonstrate its usage to generate chaotic sample data. In the following example mapping out the time-delay embedded signal reveals the simple structure that governs this particular system.

#load the library tseriesChaos and scatterplot3d for graphing library(tseriesChaos) library(scatterplot3d) #generate and plot times series data for the Rössler system rossler.ts plot(rossler.ts)

Represent and plot the times series as a 3 dimensional delayed vector [x(t), x(t-d), x(t-2*d)]

xyz scatterplot3d(xyz, type="l")

Taking the Poincaré section, which is to read a slice off the continuous attractor if it crosses a lower dimensional subspace. Here the z dimension is recorded whenever the x dimension crosses the value 0 from above.

pc<-xyz[1000+which(sapply( 1000:(length(xyz[,1])-1) , function(i) ( (xyz[i+1,1]<xyz[i,1]) * (xyz[i,1]*xyz[i+1,1]) ) )<0),3]

Plotting the return map reveals the law that governs the evolution of the states. In particular one can identify a fixed-point that where the 45 degree line crosses the return map. If the system were brought to this state it would always remain on it.

plot(pc[1:(length(pc)-1)],pc[2:length(pc)],pch=16,cex=.4,xlab="current state", ylab="next state",main="Return Map") abline(0,1)

Similarly plotting states two iterations apart reveals the location of period-2 orbits.

plot(pc[1:(length(pc)-2)],pc[3:length(pc)],pch=16,cex=.4,xlab="previous state", ylab="next state",main="Return Map") abline(0,1)

An area of research in this type of systems is to dynamically identify and control such special states. The ability of learning algorithms to recover the hidden model structure can be benchmarked against clean test data as generated in the example above and also against chaotic data with added noise. In addition, in order to avoid over-fitting (high variance) learning of real model data can also be compared against surrogate data. Here surrogate data refers to a generated random time series that shares the same frequency power spectrum and probability distribution with the original signal, but contains no deterministic structure. See also D. Prichard and J. Theiler in “Generating surrogate data for time series with several simultaneously measured variables” and J.D Farmer and others in “Testing for nonlinearity in time series: the method of surrogate data”.

**leave a comment**for the author, please follow the link and comment on their blog:

**quantsignals » R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.