Skip to main content

Multivariate Granger causality for time-series data in python

Project description

pyMVGC: Python Multivariate Granger causality

A Python implementation of multivariate Granger causality (MVGC) for time-series data, based on algorithms from Barnett & Seth's MVGC toolbox [1]. This method avoids explicit estimation of the reduced VAR via moving between autocovariance-sequence and regression-parameter representations of the VAR model. This reduces estimation error and imporoves statistical power and speed of estimation compared to the traditional estimation of separate full and reduced models.

Usage

pyMVGC can be downloaded from PyPI via pip:

$ pip install pyMVGC

Multivariate granger causality may be estimated in one line of code:

import pyMVGC as gc

# Multivariate Granger causality from one set of variables to another
ts_to_MVGC(data, to_idx = [0], from_idx = [1], p = 2)

#Pairwise granger causality between all variables in the system
ts_to_pMVGC(data, p = 2)

Optimal model order can be estimated from "AIC" or "BIC" scores:

estimate_model_order(data, maxLag = 30, criterion = "AIC")

Functions allowing movement between autocovariance and VAR representations, used in MVGC calculation, are also available:

Phi, resCov = gc.ts_to_var(data = data, p = p) # learn VAR from time series data.
autocov = gc.var_to_autocov(Phi = Phi, resCovMat = resCov) # learn autocovariance sequence from VAR.
Phi, resCov = gc.autocov_to_var(autocov = autocov)

GC = gc.autocov_to_MVGC(autocov, to_idx,from_idx) # get multivariate granger causality from from autocovarance sequence.
pGC = gc.autocov_to_pMVGC(autocov) # get pairwise granger causality from autocovariance sequnce.
    

See notebooks/tutorial.ipynb for a more detailed tutorial.

References

[1] L. Barnett and A. K. Seth, "The MVGC Multivariate Granger Causality Toolbox: A new approach to Granger-causal inference", J. Neurosci. Methods 223, pp 50-68, 2014.

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

pymvgc-1.0.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymvgc-1.0.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file pymvgc-1.0.0.tar.gz.

File metadata

  • Download URL: pymvgc-1.0.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pymvgc-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4b00fd10b008e2e008ecb40448ce8e9ee0f589538d76f3139126ac7e94628750
MD5 d67e890fe6244311024511ab2c56d059
BLAKE2b-256 a858b2a4e7570ec8724b714b78a2020c4608eae9ba311201d37bf5e3fb2936dc

See more details on using hashes here.

File details

Details for the file pymvgc-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pymvgc-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pymvgc-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6365a32cdecd3875e20b162484084fa1d05469c54d1196c6092002b9fef461a1
MD5 a19fafd88c0c435ed175d0dfe95fce00
BLAKE2b-256 edd5bede2761278cf21aef18bbe23a512b439e0eaef7ce6c865f031308673f47

See more details on using hashes here.

Supported by

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