Skip to main content

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 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)

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

bcad-1.0.1.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

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

bcad-1.0.1-py3-none-any.whl (3.1 MB view details)

Uploaded Python 3

File details

Details for the file bcad-1.0.1.tar.gz.

File metadata

  • Download URL: bcad-1.0.1.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

Hashes for bcad-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8f7c87c95c6c5beaf99eebdddc60c18d8bc4419a41a55b19b872da034177c5ae
MD5 82b5c6d45342f4761d4af243f534303c
BLAKE2b-256 603d2658b04334ff3cb8ec82590497aeb7a969c1d4f72ba7aa07bb559dad39b5

See more details on using hashes here.

File details

Details for the file bcad-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: bcad-1.0.1-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

Hashes for bcad-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cb8d4f9899875c32dab61ca6e2c86f3dc5a34bd996d4cb6db5a9c68acb30007
MD5 48850d7c90e726093d19a1fc06b9749c
BLAKE2b-256 63359c371e9e700684cd7e18ddde08dfaf2e9d5eb0c1ab614e8e3796fd96e990

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