pyEDM Examples

from pyEDM import *
import matplotlib.pyplot as plt
tentmap      = sampleData['TentMap']
tentmapNoise = sampleData['TentMapNoise']
plt.plot( tentmap['TentMap'][1:40] );

Evaluate optimal embedding dimension (via Simplex)

EmbedDimension( dataFrame = tentmap, lib = "1 100", pred = "201 500", 
                columns = "TentMap" );

Optimal embedding dimension is E = 2


Evaluate nonlinearity

PredictInterval( dataFrame = tentmap, lib = "1 100", pred = "251 500",
                 columns = "TentMap", E = 2 );

Decay in predictability as forecast interval increases is an indication of nonlinearity.


Simplex prediction

Simplex( dataFrame = tentmapNoise, lib = "1 500", pred = "501 550", 
         columns = "TentMap", E = 2, showPlot = True );

Simplex Prediction using multivariate embedding

block_3sp = sampleData['block_3sp']
block_3sp.head(3)
time x_t x_t-1 x_t-2 y_t y_t-1 y_t-2 z_t z_t-1 z_t-2
0 3 -1.917685 1.244882 -0.741863 -0.113188 1.488887 -1.268104 1.535239 -0.481583 -1.863980
1 4 -0.962318 -1.917685 1.244882 -1.106779 -0.113188 1.488887 -1.492956 1.535239 -0.481583
2 5 1.331875 -0.962318 -1.917685 2.385041 -1.106779 -0.113188 -1.119476 -1.492956 1.535239
# embedded = True
Simplex( dataFrame = block_3sp, lib = "1 99", pred = "100 195", 
         E = 3, columns = "x_t y_t z_t", target = "x_t",
         embedded = True, showPlot = True );

Evaluate optimal SMap theta parameter indicating state-dependence and extent of nonlinearity

PredictNonlinear( dataFrame = tentmapNoise, lib = "1 100", pred = "201 500",
                  columns = "TentMap", E = 2 );

SMap theta parameter in the range of [2-3] provides optimal resolution. The non-zero theta peak of predictability indicates nonlinearity.


SMap Prediction

SMap( dataFrame = tentmapNoise, lib = "1 500", pred = "501 550", 
      columns = "TentMap", E = 2, theta = 3, showPlot = True );

SMap Prediction multivariate embedding

# embedded = True
SMap( dataFrame = sampleData[ 'circle' ],
      lib = "1 100", pred = "110 190", theta = 4, E = 2, 
      embedded = True, columns = "x y", target = "x", showPlot = True );

Inference of causality via Convergent Cross Mapping (CCM)

sardine_anchovy_sst = sampleData['sardine_anchovy_sst']
sardine_anchovy_sst[['anchovy','np_sst']].plot();
CCM( dataFrame = sardine_anchovy_sst, E = 3, 
     columns = "anchovy", target = "np_sst",
     libSizes = "10 75 5", sample = 100, showPlot = True );

The CCM result anchovy::np_sst is interpreted as: sea surface temperature (np_sst) influences anchovy population. The reverse influence (np_sst::anchovy) indicates no link, consistent with the fact that anchovy population does not influence sea surface temperature.


Multiview Embedding

MV = Multiview( dataFrame = block_3sp, lib = "1 99", pred = "105 190", E = 3,
                columns = "x_t y_t z_t", target = "x_t", showPlot = True );
MV['View']
# Col_i are column indices in block_3sp
Col_1 Col_2 Col_3 rho MAE RMSE
0 1.0 2.0 7.0 0.920810 0.248512 0.316416
1 1.0 2.0 6.0 0.867700 0.329428 0.411275
2 1.0 2.0 3.0 0.931867 0.227694 0.293402
3 1.0 2.0 8.0 0.918331 0.247643 0.320505
4 1.0 7.0 9.0 0.885830 0.303054 0.373766
5 1.0 4.0 9.0 0.777399 0.419085 0.511584
6 1.0 3.0 7.0 0.872370 0.315571 0.400680
7 1.0 2.0 5.0 0.901727 0.280353 0.356719
8 1.0 2.0 4.0 0.880479 0.294107 0.386308