UniversitÓ di Bologna



Nonlinear Time Series Analysis with R

In the process of data analysis, the investigator is often facing highly-volatile and random-appearing observed data. A vast body of literature shows that the assumption of underlying stochastic processes was not necessarily representing the nature of the processes under investigation and, when other tools were used, deterministic features emerged. Non Linear Time Series Analysis (NLTS) allows researchers to test whether observed volatility conceals systematic non linear behaviour, and to rigorously characterize governing dynamics. Behavioral patterns detected by non linear time series analysis, along with scientific principles and other expert information, guide the specification of mechanistic models that serve to explain real-world behavior rather than merely reproducing it. Often there is a misconception regarding the complexity of the level of mathematics needed to understand and utilize the tools of NLTS (for instance Chaos theory). However, mathematics used in NLTS is much simpler than many other subjects of science, such as mathematical topology, relativity or particle physics. For this reason, the tools of NLTS have been confined and utilized mostly in the fields of mathematics and physics. However, many natural phenomena investigated I many fields have been revealing deterministic non linear structures. In this book we aim at presenting the theory and the empirical of NLTS to a broader audience, to make this very powerful area of science available to many scientific areas. This book targets students and professionals in physics, engineering, biology, agriculture, economy and social sciences as a textbook in Nonlinear Time Series Analysis (NLTS) using the R computer language.
Readership: Teachers, professors and students at universities, as well as researchers in private and public sectors.


Download R programs

The programs described in the book are downloadable here. For consistency with the printed book, the original code presented in the book are retained. Depending on the hardware, operating system, computer's processor (32-bit and 64-bit) and software version, different version of the R modules may be needed to run the programs. The programs and modules downloadable here are for R 3.3.1, for 32-bit processors and they are available on the official R website (https://www.r-project.org/). Right click to download the .R files. Some programs use User Defined Functions that are necessary to perform some computations. The user should download the file UserDefinedFunctions.zip and data.zip, listed at the bottom of this page. Then it should create a directory within the main directory where the R programs are saved, called User Defined Functions and data, and unzip all the files there. The codes were constructed with the following Packages: animation 2.5; boot 1.3-18; deSolve 1.12; extRemes 2.0-7; fields 8.4-1; FinTS 0.4-5; fractal 2.0-1; glmnet 2.0-5; graphics 3.3.1; igraph 1.0.1; MESS 0.4-3; mpoly 1.0.3; multispatialCCM 1.0; pdc 1.0.3; pdist 1.2; phaseR 1.3; plotrix 3.6-3; ppls 1.6-1; psych; Rssa 0.13-1; scatterplot3d 0.3-37; tseriesChaos 0.1-13.

Program R Files
Code 2.1. Numerical solution of linear difference equations Code 2.1
Code 2.2 Cobweb plots for linear difference equations Code 2.2
Code 2.3 Nonlinear logistic map: time series and cobweb plots Code 2.3
Code 2.4 Nonlinear logistic map: bifurcation diagram Code 2.4
Code 2.5 Nonlinear logistic map: detail of the bifurcation diagram Code 2.5
Code 2.6 Nonlinear logistic map: Lyapunov exponent Code 2.6
Code 2.7 Density of the logistic map, 1 trajectory Code 2.7
Code 2.8 Logistic map: density, M trajectories, initial distribution: uniform in (0,1) Code 2.8
Code 3.1 Ideal pendulum small oscillations Code 3.1
Code 3.2 Embedding pendulum: ideal small oscillations Code 3.2
Code 3.3 Lorenz attractor Code 3.3
Code 3.4 Lorenz system: density, 1 trajectory Code 3.4
Code 3.5 Lorenz PCA Code 3.5
Code 4.1 Logistic recurrence plot Code 4.1
Code 4.2 Random recurrence plot Code 4.2
Code 4.3 Lorenz correlation dimension Code 4.3
Code 4.4 Damped driven pendulum Code 4.4
Code 4.5 Damped driven pendulum Code 4.5
Code 5.1 Compute Entropy for the logistic map Code 5.1
Code 5.2 Compute Lorenz Surrogates Code 5.2
Code 5.3 Compute Logistic simulate annealing Code 5.3
Code 6.1 Phase Diagram for two-dimensional ODE system Code 6.1
Code 6.2 Phase Diagram for three-dimensional ODE system Code 6.2
Code 6.3 Compute correlation dimension for time series using Takens estimator Code 6.3
Code 6.4 Induce irregular dynamics with noisy linear dynamics Code 6.4
Code 6.5 Illustration of SVD-SSA mechanics Code 6.5
Code 6.6 Illustration of Toeplitz-SSA mechanics Code 6.6
Code 6.7 Code 6.7 Example of Fourier Power Spectrum for single sine wave Code 6.7
Code 6.8 Code 6.8 Fourier Power Spectrum for time series Code 6.8
Code 6.9 SSA: matrix decomposition and grouping diagnostics Code 6.9
Code 6.10 Scatterplot cosine and sine functions oscillating at identical frequency Code 6.10
Code 6.11 SSA: reconstruction of time series Code 6.11
Code 6.12 Induce complex dynamics with nonstationary linear dynamics Code 6.12
Code 6.13 Compute embedded data matrix for observed time series using statistic tests Code 6.13
Code 6.14 Nonlinear Prediction (1 step head) Code 6.14
Code 6.15 Nonlinear cross prediction (1 step head) to probe nonstationarity Code 6.15
Code 6.16 User-defined function to solve Lorenz system Code 6.16
Code 7.1 User-defined function to generate PPS surrogates Code 7.1
Code 7.2 A simple example of how to calculate C Code 7.2
Code 7.3 Compute correlation dimension for time series using Takens estimator. Code 7.3
Code 7.4 Formulate user-defined function to compute correlation dimension for time series using Takens estimator Code 7.4
Code 7.5 Illustration of Kantz-Schreiber algorithm for a single point on the Lorenz attractor Code 7.5
Code 7.6 Numerical estimation of maximum Lyapunov exponent from time series using lyap_k(tseriesChaos) Code 7.6
Code 7.7 Discriminating statistics for time series Code 7.7
Code 7.8 Surrogate data testing Code 7.8
Code 8.1 User-defined function for Convergent Cross Mapping (Logistic model Example) Code 8.1
Code 8.2 User-defined function for Delayed CCM (Logistic model Example) Code 8.2
Code 8.3 Network plots from adjacency matrices Code 8.3
Code 8.4 R code to run ccm followed by delayed ccm Code 8.4
Code 8.5 Generate sine test function for change point detection Code 8.5
Code 8.6 User defined function for change point detection Code 8.6
Code 8.7 Change-point detection with point-by-point upper confidence level Code 8.7
Code 8.8 Tipping-point detection Code 8.8
Code 9.1 Specify user-defined function to compute fourth-order centered finite differences Code 9.1
Code 9.2 Multivariate polynomial expansion and monomial terms with observed time series for three variables Code 9.2
Code 9.3 Ordinary Least Squares (OLS) Regression Code 9.3
Code 9.4 LASSO regression Code 9.4
Code 9.5 User-defined function to calculate goodness of fit with 3 variables Code 9.5
Code 9.6 User-defined function to solve phenomenological Lorenz model Code 9.6
Code 9.7 Phenomenological Model Extracted from Three Observed Variables Code 9.7
Code 9.8 Phenomenological model extracted from single observed variable Code 9.8
Code 11.1 Extreme Value Statistics Code 11.1
Download all codes as zip file NLTS.zip
Download User Defined Functions UserDefinedFunctions.zip
Download Data data.zip

Additional material and exercises.

In this section we are presenting additional material and exercises. This section will be updated with the date of the new published material. The first in the file name is the Chapter's number in the book. For instance Ex2_2.pdf is the second exercise of Chapter 2.
Exercises PDF Files R Code R Code
Exercise 2.1: Fixed points behaviour of different maps (Oct, 12, 2017) Ex2_1.pdf Ex2_1.R
Exercise 2.2: Henon map (Oct, 19, 2017) Ex2_2.pdf Ex2_2a.R Ex2_2b.R
Exercise 2.3: Ricker map (Oct, 19, 2017) Ex2_3.pdf Ex2_3a.R Ex2_3b.R
Exercise 2.4: Quasiperiodicity (Oct, 19, 2017) Ex2_4.pdf Ex2_4.R
Exercise 2.5: Fractal boundaries (Oct, 31, 2017) Ex2_5.pdf Ex2_5a.R Ex2_5b.R
Exercise 2.6: Invariant density (Nov, 16, 2017) Ex2_6.pdf Ex2_6.R
Exercise 3.1: Ideal pendula (Nov, 16, 2017) Ex3_1.pdf Ex3_1a.R Ex3_1b.R
Exercise 3.2: Real pendula (Nov, 16, 2017) Ex3_2.pdf Ex3_2a.R Ex3_2b.R Ex3_2c.R
Exercise 3.3: Reconstruction of noisy data with PCA (Dec, 6, 2017) Ex3_3.pdf Ex3_3a.R Ex3_3b.R
Exercise 4.1: Lorenz attractor (Dec, 6, 2017) Ex4_1.pdf Ex4_1.R
Exercise 4.2: Rossler attractor (Dec, 6, 2017) Ex4_2.pdf Ex4_2.R
Exercise 4.3: Duffing attractor (Mar,22, 2018) Ex4_3.pdf Ex4_3.R
Exercise 6.1: Searching for fixed points (Mar, 22, 2018) Ex6_1.pdf