Custom delay reconstruction
To create delay embeddings from sequential data, use customembed
. This function returns allows for more flexibility than embed
in DynamicalSystems.jl1, but also returns a Dataset
, so these embedding methods may be used interchangeably.
Delay reconstruction
#
CausalityToolsBase.customembed
— Function.
customembed(pts, positions::Positions, lags::Lags)
Do custom state space reconstructions with customembed(pts, positions::Positions, lags::Lags)
. This function acts almost as DynamicalSystems.reconstruct
, but allows for more flexibility in the ordering of dynamical variables and allows for negative lags. The positions
variable indicates which dynamical variables are mapped to which variables in the final reconstruction, while lags
indicates the lags for each of the embedding variables.
Note: customembed
expects an array of state vectors, i.e. pts[k]
must refer to the k
th point of the dataset, not the k
th dynamical variable/column.*. To embed a vector of time series, load DynamicalSystems
and wrap the time series in a Dataset
first, e.g. if x = rand(100); y = rand(100)
are two time series, then customembed(Dataset(x, y), Positions(1, 2, 2), Lags(0, 0, 1)
will create the embedding with state vectors (x(t), y(t), y(t + 1))
.
Pre-embedded points may be wrapped in a CustomReconstruction
instance by simply calling customembed(preembedded_pts)
without any position/lag instructions.
Examples
Example 1
customembed([rand(3) for i = 1:50], Positions(1, 2, 1, 3), Lags(0, 0, 1, -2)
gives a 4-dimensional embedding with state vectors (x1(t), x2(t), x1(t + 1), x3(t - 2))
.
Example 2
Say we want to construct an appropriate delay reconstruction for transfer entropy (TE) analysis
so that we're computing the following TE
We'll use a prediction lag \eta = 2 and use first minima of the lagged mutual information function for the embedding delay \tau.
using CausalityToolsBase, DynamicalSystems
x, y = rand(100), rand(100)
D = Dataset(x, y)
embedlag = optimal_delay(y)
CustomReconstruction(D, Positions(2, 2, 2, 1), Lags(2, 0, embedlag, 0))
Variable mapping
#
CausalityToolsBase.Positions
— Type.
Positions
Type specifying the positions the different dynamical variables appear in when constructing a custom state space reconstruction. Used in combination with Lags
to specify how a CustomReconstruction
should be constructed. Each of the positions must refer to a dynamical variable (column) actually present in the dataset.
Examples
Positions(1, 2, 1, 5)
indicates a 4-dimensional state space reconstruction where the 1st coordinate axis of the reconstruction should be formed from the first variable/column of the input data, the 2nd coordinate axis of the reconstruction should be formed from the 2nd variable/column of the input data, the 3rd coordinate axis of the reconstruction should be formed from the 1st variable/column of the input data, the 4th coordinate axis of the reconstruction should be formed from the 5th variable/column of the input data.Positions(-1, 2)
indicates a 2-dimensional reconstruction, but will not work, because each position must refer to the index of a dynamical variable (column) of a dataset (indexed from 1 and up, so negative values will not work).
Reconstruction lag mapping
#
CausalityToolsBase.Lags
— Type.
Lags
Wrapper type for lags used when performing custom state space reconstructions. Used in combination with Positions
to specify how a CustomReconstruction
should be constructed.
Examples
Lags(2, 0, -3, 1)
indicates a 4-dimensional state space reconstruction where the first variable has a positive lag of 2, the second variable is not lagged, the third variable has a lag of -3, and the fourth variable has a positive lag of 1.Lags(0, 0)
indicates a 2-dimensional state space reconstruction where both variables are not lagged.
-
Datseris, George. "DynamicalSystems. jl: A Julia software library for chaos and nonlinear dynamics." J. Open Source Software 3.23 (2018): 598. ↩