Skip to main content

implementation of convergent cross mapping by Sugihara et al (2012)

Project description

causal_ccm

Package implementing Convergent Cross Mapping for causality inference in dynamical systems as defined by Sugihara et al (2012)

Example usage

For an example how to use, see: https://github.com/PrinceJavier/causal_ccm/blob/main/usage_sample.ipynb
Source code: https://github.com/PrinceJavier/causal_ccm

To install

pip install causal-ccm

To use

Say we want to check if X drives Y. We first define ccm using:

  • X and Y - time series data
  • tau - time lag (if tau=1 we get [t, t-1, t-2...] as our shadow manifold embedding
  • E - embedding dimension (default=2) for the shadow manifold
  • L - time horizon to consider, defaults at length of time series X

We import the package
from causal_ccm.causal_ccm import ccm

We define ccm:
ccm1 = ccm(X, Y, tau, E, L) # define ccm with X, Y time series

We check the strength of causality measured as correlation in prediction vs true (see Sugihara (2012))
ccm1.causality()

We can visualize cross mapping between manifolds of X and Y
ccm1.visualize_cross_mapping()

We visualize correlation of X->Y
We stronger correlation = stronger causal relationship
ccm1.plot_ccm_correls()

Finally, we can check convergence in predictions (correlations) by computing ccm1.causality() for ccm1 defined with different L values.

Additional Feature (PAI)

The pai class implements the Pairwise Asymmetric Inference (see McCracken (2014)). The major difference of pai to ccm is the shadow manifold used to predict X. To create the manifold, use the manifold_pattern and tau parameters. For example, manifold_pattern=[[0, -1, -2],[0]], tau=2 is the same as the shadow manifold (X_t, X_{t-1*2}, X_{t-2*2}, Y_t).

If this package helped you in your work, pls. cite:

@software{Javier_causal-ccm_a_Python_2021,
author = {Javier, Prince Joseph Erneszer},
month = {6},
title = {{causal-ccm a Python implementation of Convergent Cross Mapping}},
version = {0.3.3},
year = {2021}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causal_ccm-0.4.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file causal_ccm-0.4.0.tar.gz.

File metadata

  • Download URL: causal_ccm-0.4.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for causal_ccm-0.4.0.tar.gz
Algorithm Hash digest
SHA256 29bc3c239b407925f06d5f64264ba432e082d8e05d2ffc160a608000565379ed
MD5 781f51ecbbdb2d16ccb85c2fb3289286
BLAKE2b-256 9ad34a099c6397d18f6fb386fcb04705b902dc4a417f4640399244703b24c71d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page