26/02/2018

Time Series and ODEs

  • For the growth model \(dy(t)/dt = r y(t) (1- y(t)/N)\) can be discretized into a sequence.

  • The logistic growth in a discrete time setting: \[ y_{t+1} = y_t + r y_t \left(1 - \frac{y_t}{N}\right)\] where \(y_t\) represents the population at time \(t=1,2,3,\dots\).

  • \(dy(t)/dt\) is discretized into \(y_{t+1} - y_t\).

Time Series and ODEs

  • In discrete time, an equilibrium state is a fixed point of an iteration function \(y_{t+1}=f(y_t)\) such that \(y^* = f(y^*)\).

  • Note: This \(f\) is different from the \(f(\cdot)\) in ODEs. In ODEs, the vector field \(f(\cdot)\) accounts for the small increments. In time series, \(f(\cdot)\) is a mapping to the next entity in the series.

  • Stability of an equilibrium \(y^*\): An equilibrium is globally stable if \[ \lim_{t\rightarrow \infty} y_t = y^*, \, \mbox{for any } y_0.\]

Example

logit.dis = function(time,yinit,parms){
  yt = numeric(); y=yinit; yt[1]=y
  for (t in 2:time) {
    y =  y + parms[1]*y*(1-y/parms[2])
    yt[t] = y}
  return(yt)}
yt.d = logit.dis(time=101,yinit=1,parms=c(0.1,10)); yt.c=logit[,2];
head(cbind(yt.d,yt.c))
##          yt.d     yt.c
## [1,] 1.000000 1.000000
## [2,] 1.090000 1.093671
## [3,] 1.187119 1.194945
## [4,] 1.291738 1.304227
## [5,] 1.404226 1.421890
## [6,] 1.524930 1.548278

Example

Chaos

y1=logit.dis(201,0.01,parms=c(1.5,10)); y2=logit.dis(201,0.01,parms=c(2.2,10))
y3=logit.dis(201,0.01,parms=c(3,10)); y4=logit.dis(201,yinit=0.03,parms=c(3,10))
times = 0:200

Attractors and repellers

  • An attractor: a geometric structure with noticeable regularity

  • Periodic fixed point attractors. For a 2-cycle configuration: \(y_{t+2}=y_t\) or \(y_{t+2} = f(y_{t+1})=f(f(y_t))=y_t\).

tail(y2, 6)
## [1] 11.628443  7.462466 11.628443  7.462466 11.628443  7.462466
  • That is \[y_{t+2} = y_{t+1} + r y_{t+1} \left(1 - \frac{y_{t+1}}{N}\right) = f(y_t) + r f(y_t) \left(1 - \frac{f(y_t)}{N}\right).\] It has 2 real roots (4 roots but 2 are complex).

Attractors and repellers

  • The stability of the fixed point \(y_{t+2} =f(f(y_t))\) depends on the derivative \[\frac{\partial f(f(y^*))}{\partial y} = f'(y^*) \times f'(f(y^*))=[f'(y^*) ]^2.\]

  • Let \(f'(y^*)= m\). The value of \(m\) characterizes the stability of the fixed point:

  1. \(m > 1\): unstable fixed point, exponential divergence from \(y^*\).
  2. \(0 < m < 1\): stable fixed point, monotonic convergence towards \(y^*\).
  3. \(−1 < m < 0\): stable fixed point, oscillatory convergence towards \(y^*\).
  4. \(m < −1\): unstable fixed point, oscillatory divergence from \(y^*\).

Attractors and repellers

  • A fixed point is attracting (repelling) if its \(m\) has value less (greater) than \(1\).

  • The stable (unstable) fixed points of \(f(f(y_t))\) correspond to the stable (unstable) cycles of \(f(y_t)\).

  • For \(n\)-period cycle, \[f(f(\cdots f(y_t))=y_t\] is the \(n\)-th iteration. A point on this \(n\)-cycle of \(f(y)\) is the fixed point for the \(n\)-th iteration.

  • An attractor encapsulates the long-term dynamic behaviour of the system

Phase Plots

par(mfrow=c(1,4))
plot(y1[150:200], y1[149:199]); plot(y2[150:200], y2[149:199]); 
plot(y3[150:200], y3[149:199]); plot(y3[150:200], y3[148:198]);

Cobweb: \(r=2.2, y_0=0.01\)

Cobweb: \(r=3, y_0=0.01\)

Bifurcation and Chaos

  • In the logistic example, as \(r\) increases, a stable fixed point becomes unstable and two new stable fixed points appear. Then a further increase causes two stable fixed points to become unstable.

  • At a certain value \(r\) of the parameter, the fixed point \(y^*\) goes from stable to unstable.

  • A bifurcation: a tiny variation of a parameter causes a sudden qualitative change in the system’s dynamics.

  • As we’ve seen, for a large \(r\), that is, in the chaotic regime, the system becomes sensitive to its initial conditions (a chaotic system).

  • As \(r\) increases, the bifurcations become more frequent and on a smaller scale: this is a property of fractal geometry and is named self-similarity.

Bifurcation

Lyapunov Exponents

  • (Like ODEs) Stability is measured by divergences of trajectories.

  • Let \(|y_0 - y'_0|=\delta_0\) be a perturbation. Then \[ \delta_1 = |y_1 - y'_1|= |f(y_0) - f(y'_0)| \approx |f'(y_0)| \delta_0.\]

  • For \(n\)-th iteration, there is \[ \delta_n = |y_n - y'_n|= |f(y_{n-1}) - f(y'_{n-1})| \approx |f'(y_{n-1})| \delta_{n-1} \\ \approx |f'(y_{n-1}) f'(y_{n-2}) \cdots f'(y_{0})|\delta_0.\]

Lyapunov Exponents

  • Layapunov exponent is defined as \[ \lambda = \lim_{n\rightarrow \infty} \lim_{\delta_0 \rightarrow 0} \frac{1}{n}\sum^{n-1}_{t=0} \log |f'(y_t)|\] which also implies \(\delta_n \approx e^{n \lambda_n} \delta_0\).

  • It represents the average rate of separation (expansion or contraction) per iteration of two trajectories on an attractor with very close initial conditions.

  • For the logistic equation, the derivative \(f'(y_t)\) can be computed analytically \(f'(y_t) = 1 + r(1-2y_t).\) Then code of this Lyapunov exponent is

# For an n-length loop, in the t-th iteration, we compute Lyapunov exponent as
lambda=lambda+log(abs(1+ r*(1-2*y/10))) 
# When the loop finishes, compute lambda/n 

Lyapunov Exponents

  • If \(\lambda < 0\), the trajectories converge, while if \(\lambda > 0\), they diverge. If \(\lambda = 0\), there is neither expansion nor contraction.

Bifurcation and Chaos

  • Chaotic dynamics is aperiodic: the system never returns to the same “initial state” (dissipative). A population from generation to generation never has the same number of individuals.

  • With respect to fixed points or cycles:

  • In a standard regime: the initial conditions are irrelevant, since trajectories starting from different points converge on the same attractor.

  • In a chaotic regime: differences in initial conditions are exponentially amplified.

Ergodicity

  • Chaotic systems: unpredictability as the dynamics of an individual trajectory is highly unstable

  • But from a statistical/probabilistic perspective, some form of predictability can emerge, even for a single trajectory. That is the invariant measure, or the ergodicity of dynamical systems.

  • In dissipative dynamic systems, trajectories converge to a subset of phase space where they oscillate aperiodically along an attractor.

Invariant Measure

x = seq(0,1,length=100); hx=dbeta(x,0.5,0.5); par(mfrow=c(1,2))
hist(y3/max(y3),breaks=20, freq=FALSE); lines(x,hx)
hist(y4/max(y4),breaks=20, freq=FALSE); lines(x,hx)

Embedding (Principal component)

  • Dynamical invariant is preserved in the reconstructed space.

  • Transform the original set of variables into a new set of uncorrelated variables.

  • Most of the information is stored in the first few components, called principal components.

out  = ode(y = yini, times = times, func = chaos, parms = 0)
x = embed(out[,2], 8); pc = prcomp(x); summary(pc)
## Importance of components:
##                            PC1     PC2     PC3     PC4      PC5       PC6
## Standard deviation     22.9558 4.77558 0.45745 0.06024 0.005603 0.0005687
## Proportion of Variance  0.9581 0.04147 0.00038 0.00001 0.000000 0.0000000
## Cumulative Proportion   0.9581 0.99961 0.99999 1.00000 1.000000 1.0000000
##                              PC7       PC8
## Standard deviation     4.251e-05 2.634e-06
## Proportion of Variance 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00

Embedding (Principal component)

library(scatterplot3d); pred.pc = predict(pc);
# library(rgl); rgl.linestrips(pred.pc[,1], pred.pc[,2], pred.pc[,3])
layout(matrix(c(1, 2), 1)); 
scatterplot3d(x[,c(1,4,8)],type="l"); scatterplot3d(pred.pc[,1:3],type="l")

Singular Value Decomposition (SVD)

  • SVD of a \(k \times p\) matrix \(\mathbf{X}\):\[ \mathbf{X} = \mathbf{U} \Sigma \mathbf{V}^T\] where the \(k \times p\) matrix \(\Sigma\) contains the singular values of \(\mathbf{X}\) and the \(k\) (\(p\)) columns of \(\mathbf{U}\) (\(\mathbf{V}\)) are orthogonal \[\mathbf{U}^T \mathbf{U}=\mathbf{I},\,\, \mathbf{V}^T \mathbf{V}=\mathbf{I}.\] In fact, they are the eigenvector of \(\mathbf{X}^T\mathbf{X}\) and \(\mathbf{X}\mathbf{X}^T\) \[\mathbf{X}^T\mathbf{X} = \mathbf{V} \Lambda \mathbf{V}^T, \,\, \mathbf{X}\mathbf{X}^T = \mathbf{U} \Lambda \mathbf{U}^T,\,\, \mathbf{X}\mathbf{V} = \mathbf{U} \Sigma.\]
  • The columns of \(\mathbf{V}\) are principal directions. The columns of \(\mathbf{U} \Sigma\) are principal components.

Singular spectrum analysis (SSA)

  • SSA: a data-driven method. (More eigenvectors of \(\mathbf{V}\)).
library(Rssa); xn=x[4000:9000,]; s=ssa(xn); plot(s, type="paired")

Singular Spectrum

plot(wcor(s,groups=c(1:20)))

Remark

  • Discretization

  • Stability

  • From stability to unstability (bifurcations)

  • Chaos and Invariance

  • Singular Values and Principle Components