Skip to main content

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 New York 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 with automatic optimal hard thresholding via Gavish and Donoho's method
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)

Metadata

Release files for bcad 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bcad 1.0.1
File Size Uploaded Provenance Actions
bcad-1.0.1.tar.gz 3.1 MB Without provenance Details for bcad-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bcad 1.0.1
File Interpreter ABI Platform Actions
bcad-1.0.1-py3-none-any.whl Python 3 none any Details for bcad-1.0.1-py3-none-any.whl

Total release size: 6.2 MB

Release files / bcad-1.0.1.tar.gz

Download URL bcad-1.0.1.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
8f7c87c95c6c5beaf99eebdddc60c18d8bc4419a41a55b19b872da034177c5ae
BLAKE2b-256 checksum
How to use checksums
603d2658b04334ff3cb8ec82590497aeb7a969c1d4f72ba7aa07bb559dad39b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / bcad-1.0.1-py3-none-any.whl

Download URL bcad-1.0.1-py3-none-any.whl
Size 3.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6cb8d4f9899875c32dab61ca6e2c86f3dc5a34bd996d4cb6db5a9c68acb30007
BLAKE2b-256 checksum
How to use checksums
63359c371e9e700684cd7e18ddde08dfaf2e9d5eb0c1ab614e8e3796fd96e990
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Security for bcad 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page