Skip to content

Commit f24f487

Browse files
committed
Reversion to pynats for compatability with paper
1 parent ef478a8 commit f24f487

File tree

175 files changed

+25348
-2995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+25348
-2995
lines changed

README.md

Lines changed: 130 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,137 @@
1-
# Python Library of Statistics for Pairwise Interactions (pyspi)
1+
# pynats
22

3-
*pyspi* provides a comprehensive library for computing pairwise interactions from multivariate time-series data.
4-
5-
The code provides easy access to evaluating hundreds of methods for evaluating the relationship between pairs of time series, from simple statistics (like correlation and coherence) to advanced multi-step algorithms (like convergent cross mapping and transfer entropy).
6-
7-
# Pre-installation
8-
9-
The code requires GNU's [Octave](https://www.gnu.org/software/octave/index) by default. Install octave using your favourite package manager, e.g.,
10-
```
11-
apt-get install octave
12-
```
13-
for Ubuntu;
14-
```
15-
pacman -S octave
16-
```
17-
for Arch; and
18-
```
19-
brew install octave
20-
```
21-
22-
for MacOS.
3+
Python-based network analysis for time series.
234

245
# Installation
256

26-
Download or clone the [latest version](https://github.com/olivercliff/pyspi) from GitHub, unpack and run (from the folder containing `pyspi` setup.py file):
27-
28-
```
29-
pip install .
30-
```
31-
32-
or
33-
34-
```
35-
pip install -e .
36-
```
37-
38-
for editable mode.
39-
40-
We recommend the [installation in a conda environment](#conda-install).
7+
Requires Octave if using the integrated information statistics.
418

429
## Getting started
4310

44-
Check out the demo scripts in `demos/demo.py` and `demos/demo.ipynb`
45-
46-
# <a name="conda-install"></a>Conda installation
47-
48-
```
49-
git clone https://github.com/olivercliff/pyspi.git
50-
conda create -n pyspi python=3.9.0
51-
conda activate pyspi
52-
cd pyspi
53-
pip install .
54-
python demos/demo.py
55-
```
11+
When it's ready you'll be able to download it via `pip`
12+
> pip install pynats
13+
14+
## Issues
15+
16+
- You need `llvmlite`, which requires `LLVM 10.0.x` or `LLVM 9.0.x` and should be fine for most systems however in `arch` this needs to be installed via the AUR (`python-llvmlite`) or by installing `llvm10` using `pacman` (which will overwrite the latest version)
17+
- Same for `PyTorch` (install with `python-pytorch`). If you cannot, then torch might be able to be installed via `pip`, however I would use the `--no-cache-dir` flag otherwise there's a `MemoryError` raised.
18+
19+
# List of functions
20+
21+
### Correlation coefficients
22+
23+
Association coefficients that assume the observations are paired but not necessarily values of a time series. As coefficients these statistics are signed in their raw form.
24+
25+
| Function | Description |
26+
| ----------- | ----------- |
27+
| `pearsonr` | Pearson's product-moment correlation coefficient |
28+
| `spearmanr` | Spearman's rank-correlation coefficient |
29+
| `kendalltau` | Kendall's rank-correlation coefficient |
30+
| `pcorr` | Partial correlation (conditioned on all other processes) |
31+
| `prec` | Precision (inverse of partial correlation) |
32+
| `xcorr` | Cross correlation (with output statistic dependent on parameters, see below) |
33+
34+
### Independence criterion
35+
36+
statistics that assume a certain model of paired observations (not necessarily time series) to be important in distinguishing independence or integration.
37+
38+
| Function | Description |
39+
| ----------- | ----------- |
40+
| `hsic` | Hilbert-Schmidt Independence Criterion |
41+
| `hhg` | Heller-Heller-Gorfine independence criterion |
42+
| `dcorr` | Distance correlation |
43+
| `mgc` | Multi-scale graph correlation |
44+
| `anm` | Additive noise model |
45+
| `gpfit` | Gaussian process bivariate fit |
46+
| `cds` | Conditional distribution similarity fit |
47+
| `igci` | Information-geometric conditional independence |
48+
| `reci` | Neural correlation coefficient |
49+
50+
### Discrete-time statistics
51+
52+
statistics that assume the temporal precendence in discrete-time time series are important in distinguishing independence or integration.
53+
54+
| Function | Description |
55+
| -------- | ----------- |
56+
| `coint_aeg` | Cointegration computed with the Engle-Granger two-step method |
57+
| `coint_johansen` | Cointegration computed with the Johansen test |
58+
| `ccm` | Convergent-cross mapping |
59+
| `dcorrx` | Distance correlation for time series |
60+
| `mgc` | Multi-scale graph correlation for time series |
61+
| `dtw` | (Fast) dynamic time warping |
62+
63+
### Spectral statistics
64+
65+
statistics that involve a Fourier or wavelet transformation prior to computing statistics.
66+
Each statistic is averaged over some frequency (and time, for wavelet transformations) range specified by the parameters (see below).
67+
68+
| Function | Description |
69+
| -------- | ----------- |
70+
| `coherency` | Coherency |
71+
| `phase` | Coherence phase |
72+
| `cohmag` | Coherence magnitude |
73+
| `icoh` | Imaginary part of coherence |
74+
| `plv` | Phase-locking value |
75+
| `pli` | Phase-lag index |
76+
| `wpli` | Weighted phase-lag index |
77+
| `dspli` | Weighted phase-lag index |
78+
| `dswpli` | Debiased squared weighted phase-lag index |
79+
| `pcoh` | Partial coherence |
80+
| `pdcoh` | Partial directed coherence |
81+
| `gpdcoh` | Generalized partial directed coherence |
82+
| `dtf` | Directed transfer function |
83+
| `ddtf` | Direct directed transfer function |
84+
| `psi` | Phase-slope index |
85+
| `gd` | Group delay |
86+
| `sgc` | Spectral Granger causality |
87+
| `ppc` | Pairwise-phase consistency |
88+
| `pec` | Power envelope correlation |
89+
90+
### Information-theoretic statistics
91+
92+
General bivariate information-theoretic statistics that are computed with either a kernel or a Gaussian estimator.
93+
94+
| Function | Description |
95+
| -------- | ----------- |
96+
| `mi` | Mutual information |
97+
| `tl_mi` | Time-lagged mutual information |
98+
| `te` | Transfer entropy |
99+
| `ce` | Conditional entropy |
100+
| `cce` | Causally-conditioned entropy |
101+
| `di` | Directed information |
102+
| `si` | Stochastic interaction |
103+
| `xme` | Cross-map entropy (similarity index) |
104+
105+
# List of parameters
106+
107+
The output of a number of the functions use parameters to define the statistics.
108+
The shorthand for each parameter (LHS of the table) is appended to the function name with underscores between each parameter.
109+
110+
| Parameter | Description |
111+
| -------- | ----------- |
112+
| `sq` | Square the output |
113+
| `mean` | Take the mean of the output sequence (for functions such as `xcorr` and `ccm`) |
114+
| `max` | Take the max of the output sequence |
115+
| `diff` | Take the mean of the difference between two output sequences |
116+
| `empirical` | Maximum likelihood estimator for covariance matrix (non rank-based correlation coefficients only) |
117+
| `shrunk` | Shrunk estimate for the covariance matrix |
118+
| `ledoit_wolf` | Ledoit-Wolf estimator for the covariance matrix |
119+
| `oas` | Oracle Approximating Shrinkage estimator for the covariance matrix |
120+
| `tstat` | Outputs a t-statistic (for cointegration) |
121+
| `pvalue` | Outputs a p-value (for cointegration) |
122+
| `max_eig_stat` | Outputs the maximum eigenvalue (for cointegration) |
123+
| `trace_stat` | Outputs the trace of the matrix (for cointegration) |
124+
| `kernel_W-X` | Kernel estimator for information-theoretic statistics with width of `X` (default: `0.5`) |
125+
| `kraskov_NN-X` | Kraskov-Strogaz-Grassberger estimator for mutual information-based statistics with nearest-neighbours `X` (default: `4`) |
126+
| `gaussian` | Gaussian estimator for information-theoretic statistics |
127+
| `kozachenko` | Kozachenko estimator for entropy-based statistics |
128+
| `k-X` | History length of target process for transfer entropy/Granger causality (default: `1`) |
129+
| `kt-X` | Time delay of target process for transfer entropy/Granger causality (default: `1`) |
130+
| `l-X` | History length of source process for transfer entropy/Granger causality (default: `1`) |
131+
| `lt-X` | Time delay of source process for transfer entropy/Granger causality (default: `1`) |
132+
| `DCE` | Dynamic correlation exclusion (a.k.a Theiler Window) for information-theoretic statistics (not yet suitable for Gaussian estimator) |
133+
| `fs-X` | Sampling frequency of `X` (default: `1`) |
134+
| `fmin-X` | Minimum frequency for averaging spectral/wavelet statistics (default: `0`) |
135+
| `fmax-X` | Maximum frequency for averaging spectral/wavelet statistics (default: `nyquist = fs/2`) |
136+
| `order-X` | AR Order for parametric spectral Granger causality, choose `None` for optimisation by BIC (default: `None`) |
137+
| `cwt` | Continuous wavelet transformation (for spectral statistics) |

demos/config.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

demos/demo.ipynb

Lines changed: 0 additions & 181 deletions
This file was deleted.

demos/demo.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

demos/sinusoid.npy

-39.2 KB
Binary file not shown.

docs/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/logo.png

-258 KB
Binary file not shown.

0 commit comments

Comments
 (0)