oracle-varx 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. oracle_varx-0.1.0/.gitignore +21 -0
  2. oracle_varx-0.1.0/CHANGELOG.md +74 -0
  3. oracle_varx-0.1.0/CITATION.cff +83 -0
  4. oracle_varx-0.1.0/LICENSE +21 -0
  5. oracle_varx-0.1.0/PKG-INFO +731 -0
  6. oracle_varx-0.1.0/README.md +668 -0
  7. oracle_varx-0.1.0/docs/.nojekyll +0 -0
  8. oracle_varx-0.1.0/docs/assets/style.css +241 -0
  9. oracle_varx-0.1.0/docs/index.html +513 -0
  10. oracle_varx-0.1.0/docs/methods.md +254 -0
  11. oracle_varx-0.1.0/examples/treasury_curve.py +163 -0
  12. oracle_varx-0.1.0/pyproject.toml +100 -0
  13. oracle_varx-0.1.0/src/oracle_varx/__init__.py +78 -0
  14. oracle_varx-0.1.0/src/oracle_varx/_colors.py +293 -0
  15. oracle_varx-0.1.0/src/oracle_varx/_config.py +187 -0
  16. oracle_varx-0.1.0/src/oracle_varx/_core.py +866 -0
  17. oracle_varx-0.1.0/src/oracle_varx/_model.py +369 -0
  18. oracle_varx-0.1.0/src/oracle_varx/_nuisance.py +348 -0
  19. oracle_varx-0.1.0/src/oracle_varx/_plots.py +626 -0
  20. oracle_varx-0.1.0/src/oracle_varx/_results.py +482 -0
  21. oracle_varx-0.1.0/src/oracle_varx/_tables.py +326 -0
  22. oracle_varx-0.1.0/src/oracle_varx/_utils.py +514 -0
  23. oracle_varx-0.1.0/src/oracle_varx/datasets/SOURCES.md +103 -0
  24. oracle_varx-0.1.0/src/oracle_varx/datasets/__init__.py +334 -0
  25. oracle_varx-0.1.0/src/oracle_varx/datasets/_sources.py +373 -0
  26. oracle_varx-0.1.0/src/oracle_varx/datasets/treasury_curve.csv.gz +0 -0
  27. oracle_varx-0.1.0/src/oracle_varx/diagnostics.py +368 -0
  28. oracle_varx-0.1.0/src/oracle_varx/evaluation.py +452 -0
  29. oracle_varx-0.1.0/src/oracle_varx/portfolio.py +245 -0
  30. oracle_varx-0.1.0/src/oracle_varx/py.typed +0 -0
  31. oracle_varx-0.1.0/tests/test_api.py +248 -0
  32. oracle_varx-0.1.0/tests/test_core.py +279 -0
  33. oracle_varx-0.1.0/tests/test_inference.py +156 -0
  34. oracle_varx-0.1.0/tests/test_reference.py +154 -0
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ build/
4
+ dist/
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .venv/
9
+ .ipynb_checkpoints/
10
+ .coverage
11
+ htmlcov/
12
+
13
+ # working material, not part of the package
14
+ *.zip
15
+ *.pdf
16
+ _SOURCES_NEEDED.md
17
+ _BUILD_PLAN.md
18
+ _LIBRARY_COVERAGE.md
19
+
20
+ # generated by the example run
21
+ examples/_output.txt
@@ -0,0 +1,74 @@
1
+ # Changelog
2
+
3
+ All notable changes to `oracle-varx` are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ semantic versioning.
6
+
7
+ ## [0.1.0] - 2026-10-15
8
+
9
+ First release. Implements Tan, Zanoria, Chen, Lyu and Cucuringu (2026),
10
+ *Causal Lag Structure Discovery in Confounded Time Series via Orthogonalized
11
+ Adaptive Estimation*, `doi:10.48550/arXiv.2610.05618`, reimplemented from the
12
+ paper's equations.
13
+
14
+ ### Added
15
+
16
+ - `OracleVARX` and the one-call `oracle_varx()` wrapper, covering all six rungs of
17
+ the paper's Table 1: `var`, `varx`, `acle-var`, `acle-varx`, `or-varx` and
18
+ `oracle-varx`.
19
+ - Orthogonalised second stage with the standard errors of eq. (8), solved for
20
+ every rolling window in one batched call.
21
+ - Blocked, memoised cross-fitting: one first-stage fit per (block, lag order,
22
+ target), reused by every window that overlaps the block, giving the fit counts
23
+ of Appendix D.3 exactly.
24
+ - Adaptive causal lag estimation: sequential significance testing over a grid of
25
+ levels (Stage 1) with rolling-validation level selection (Stage 2).
26
+ - FDR-controlled edge discovery with BH-adjusted q-values per edge.
27
+ - Five first-stage learners — Extra Trees, Random Forest, LightGBM, XGBoost and
28
+ TabPFN — all with the paper's Table 10 hyperparameters, plus a fast `linear`
29
+ option and support for any scikit-learn-compatible estimator.
30
+ - `make_oracle_dgp`, reproducing the §5.1 benchmark; it regenerates the data
31
+ distributed with the paper to floating-point precision.
32
+ - `load_treasury`, a real shipped dataset: daily US Treasury yield-curve changes
33
+ with the real (TIPS) curve as confounders, public domain.
34
+ - `fetch_sector_etfs`, `fetch_industry_portfolios`, `fetch_treasury_curve` and
35
+ `fetch_fred` for data that cannot be redistributed.
36
+ - `evaluation`: the five metrics of §5.1, `benchmark_table` for Tables 2 and 4,
37
+ and a per-regime breakdown.
38
+ - `portfolio`: the three position rules, the dollar hedge and the performance
39
+ table of Appendix C.
40
+ - `diagnostics`: assumption checks for (M), (S), (W) and (R), a coefficient
41
+ constancy test, a lag-rule comparison against AIC/BIC/HQ, and a
42
+ leave-one-confounder-out sensitivity probe.
43
+ - Journal tables (`summary`, `to_latex`, `to_markdown`) and figures reproducing
44
+ the paper's Figures 3, 4 and 5, plus edge heatmaps, a causal-graph drawing, a 3-D
45
+ surface, FDR/power curves, residual diagnostics and an assumption-(W) guard.
46
+ - The Parula colour family, ported from the author's R packages, as the default
47
+ scale on every heatmap, contour and surface.
48
+
49
+ ### Additions beyond the paper
50
+
51
+ - Benjamini-Yekutieli correction (`correction="fdr_by"`), valid under arbitrary
52
+ dependence between the entry-wise tests, which the paper's §4 concedes it does
53
+ not establish for BH.
54
+ - A confidence interval and BH-adjusted q-value for every edge.
55
+ - `coef_source="p_hat"`, reporting each day's coefficients from the fit at its own
56
+ selected lag order.
57
+ - An admissible-window guard for assumption (W), which decides whether an estimate
58
+ may be read as the coefficient on the day or only as the window average.
59
+ - Edge-persistence summaries, per-regime scoring, and the diagnostics listed above.
60
+
61
+ ### Notes on faithfulness
62
+
63
+ - The synthetic benchmark reproduces the paper's deterministic rows of Table 2 and
64
+ Table 4 within 0.002 on every metric; see `tests/test_reference.py`.
65
+ - Two scoring conventions in the paper differ by column, and both are provided:
66
+ its FDR is a per-window average while its power and F1 are pooled, and its
67
+ coefficient error is measured against the truth on the output day rather than
68
+ the window average.
69
+ - The paper's own numbers are not bit-reproducible: its tree learners carry no
70
+ random state, so its Extra Trees and Random Forest rows differ run to run. This
71
+ package seeds every learner.
72
+ - No code from the authors' repository is used; it carries no licence.
73
+
74
+ [0.1.0]: https://github.com/merwanroudane/oracle-varx/releases/tag/v0.1.0
@@ -0,0 +1,83 @@
1
+ cff-version: 1.2.0
2
+ title: "oracle-varx: causal lag discovery in confounded time series"
3
+ message: "If you use this software, please cite both the package and the original paper."
4
+ type: software
5
+ authors:
6
+ - family-names: Roudane
7
+ given-names: Merwan
8
+ email: merwanroudane920@gmail.com
9
+ version: 0.1.0
10
+ date-released: "2026-10-15"
11
+ url: "https://github.com/merwanroudane/oracle-varx"
12
+ repository-code: "https://github.com/merwanroudane/oracle-varx"
13
+ license: MIT
14
+ keywords:
15
+ - econometrics
16
+ - causal discovery
17
+ - Granger causality
18
+ - vector autoregression
19
+ - double machine learning
20
+ - false discovery rate
21
+ abstract: >-
22
+ A Python implementation of ORACLE-VARX: double/debiased machine learning
23
+ removes nonlinear confounder effects from the outcomes and the lagged series,
24
+ adaptive causal lag estimation selects the lag order in each rolling window by
25
+ sequential significance testing tuned on validation forecasts, and a
26
+ Benjamini-Hochberg step selects directed, lag-annotated edges at a target false
27
+ discovery rate, with a coefficient, a standard error and a confidence interval
28
+ for every edge.
29
+ references:
30
+ - type: article
31
+ title: >-
32
+ Causal Lag Structure Discovery in Confounded Time Series via
33
+ Orthogonalized Adaptive Estimation
34
+ authors:
35
+ - family-names: Tan
36
+ given-names: Hong Kiat
37
+ - family-names: Zanoria
38
+ given-names: Isaac-Neil
39
+ - family-names: Chen
40
+ given-names: James
41
+ - family-names: Lyu
42
+ given-names: Haoyang
43
+ - family-names: Cucuringu
44
+ given-names: Mihai
45
+ year: 2026
46
+ doi: "10.48550/arXiv.2610.05618"
47
+ url: "https://arxiv.org/abs/2610.05618"
48
+ - type: article
49
+ title: "Double/Debiased Machine Learning for Treatment and Structural Parameters"
50
+ authors:
51
+ - family-names: Chernozhukov
52
+ given-names: Victor
53
+ - family-names: Chetverikov
54
+ given-names: Denis
55
+ - family-names: Demirer
56
+ given-names: Mert
57
+ - family-names: Duflo
58
+ given-names: Esther
59
+ - family-names: Hansen
60
+ given-names: Christian
61
+ - family-names: Newey
62
+ given-names: Whitney
63
+ - family-names: Robins
64
+ given-names: James
65
+ journal: "The Econometrics Journal"
66
+ volume: 21
67
+ issue: 1
68
+ year: 2018
69
+ doi: "10.1111/ectj.12097"
70
+ - type: article
71
+ title: >-
72
+ Controlling the False Discovery Rate: A Practical and Powerful Approach to
73
+ Multiple Testing
74
+ authors:
75
+ - family-names: Benjamini
76
+ given-names: Yoav
77
+ - family-names: Hochberg
78
+ given-names: Yosef
79
+ journal: "Journal of the Royal Statistical Society: Series B"
80
+ volume: 57
81
+ issue: 1
82
+ year: 1995
83
+ doi: "10.1111/j.2517-6161.1995.tb02031.x"
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Merwan Roudane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.