# Spectral Granger causality test data This folder contains the data used for the spectral Granger causality (GC) unit tests. Specifically, it contains the time series data generated using an autoregressive model (ARM) as well as the R `grangers` [1] parametric GC spectrum. # Description `authors` -- list of authors and contributors `LICENSE.md` -- summary of `scripts/` and `data/` licenses `scripts/` * `LICENSE` (BSD 3-clause) * `generate_test_data.py` -- Python script that generates time series data using parameters from [2]. * `grangers_estimate.R` -- R script that loads the generated `time_series_small.npy` and estimates the directional causalities using `Granger.unconditional` (see [3] for details). * `requirements.txt` -- requirements containing the exact package versions used in `generate_test_data.py` to generate `time_series.npy` and `time_series_small.npy` in `data/` folder. The requirements file was generated using `pipreqs-0.4.11` package. `data/` * `LICENSE` (CC-BY) * `weights.npy` -- weight parameter values for ARM used to generate the time series taken from [2]. * `noise_covariance.npy` -- noise covariance parameter values for ARM used to generate the time series taken from [2]. * `time_series.npy` -- artificial time series data (2, 300000) generated using ARM. * `time_series_small.npy` -- artificial time series data (2, 30000) generated using ARM. * `gc_matrix.npy` -- Granger causality estimate resulting from the `grangers_estimate.R`. ### Running the scripts #### generate_test_data.py * Create and activate a conda environment: `conda create -n test_data_env python` `conda activate test_data_env` * Navigate to the `scripts/` folder * Install required packages: `pip install -r requirements.txt` * Run the script: `python generate_test_data.py` #### grangers_estimate.R * Download and install [R and RStudio](https://posit.co/download/rstudio-desktop/) * Install the required packages within the RStudio console: `install.packages(c("RcppCNPy", "grangers"))` * Navigate to the `scripts/` folder * Run `grangers_estimate.R` interactively ### Copyright :copyright: 2023 by the [development team](authors). ### References and links 1. https://cran.r-project.org/web/packages/grangers/index.html 2. Ding, M., Chen, Y., & Bressler, S. L. (2006) "Granger Causality: Basic Theory and Application to Neuroscience." arXiv preprint q-bio/0608035. 3. https://cran.r-project.org/web/packages/grangers/grangers.pdf