Bootstrap Comparison of Attractor Dimensions
Project description
Code and data for running "bootstrap comparison of attractor dimension" (BCAD). BCAD is a method for refuting the existence of causal relations between two observables of a (noisy dynamical) system.
See the paper: Refuting causal relations for synchronized pathogen dynamics.
Installation
pip install bcad
Command line usage
bcad # Runs BCAD on all bundled US state data
Python usage example
import pandas as pd
from bcad.helpers import load_state, infer, decisions
from bcad.rypdal_sugihara import transform
from bcad.ssa import denoise
# Load bundled data for a single state
df = load_state("New_York")
df = (df - df.mean()) / df.std()
# Parameters
M = int(365 * 3 / 7) # SSA window: 3 years, weekly data
tau = 12 # time delay for embedding
window = 12 # window for reproduction number
shift = -1 # time shift for R calculation
n_bootstrap = 200 # number of bootstrap resamples
# Denoise with Singular Spectrum Analysis
dd = denoise(df, M=M)
# Compute reproduction number from pneumonia/influenza incidence
dd = dd.assign(R=transform(dd.pi_inc, window=window, shift=shift)).dropna()
# Run BCAD
res = infer(dd, n_bootstrap=n_bootstrap, tau=tau, predictors=['R', 'AH'])
aggd = decisions(res)
# BCAD refutes a causal relation X -> Y when dim(X) > dim(Y) significantly
aggd = aggd[['pval', 'theta_hat', 0.95, 0.99]].assign(refute=aggd[0.95] < 0)
print(aggd)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bcad-1.0.0.tar.gz.
File metadata
- Download URL: bcad-1.0.0.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1761bad93bb096cd05271c4fb8adf3c5cab510ab3685ed2edbdc59ba0eea5e7
|
|
| MD5 |
2ba85ee87bf869990128a67fe3b77262
|
|
| BLAKE2b-256 |
ca37535d122f7f8aca851d7c4eb1f892cab2c5d3f0ff7b7fe90cfbcd9af58906
|
File details
Details for the file bcad-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bcad-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d4e230420111473c0aab732ba65aada69d006380d19f08daec5d37c6c7baed8
|
|
| MD5 |
9d325ef17aef3be1fe656f280aba7cae
|
|
| BLAKE2b-256 |
19fc5c7bab2feb3556cf5cd0dc50b471969aa7d33a0c7fa86fe60724d9ea63a9
|