nowcast-midas 0.0.1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bank of England
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.
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: nowcast-midas
3
+ Version: 0.0.1
4
+ Summary: Staggered-Combination MIDAS model
5
+ Author-email: James Kensett <James.Kensett@bankofengland.co.uk>, Paul Labonne <Paul.Labonne@bankofengland.co.uk>, Andre Moreira <Andre.Moreira@bankofengland.co.uk>
6
+ Maintainer-email: James Kensett <James.Kensett@bankofengland.co.uk>, Paul Labonne <Paul.Labonne@bankofengland.co.uk>
7
+ License: MIT
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: jax
13
+ Requires-Dist: scipy
14
+ Requires-Dist: matplotlib
15
+ Requires-Dist: pandas
16
+ Requires-Dist: tqdm
17
+ Provides-Extra: dev
18
+ Requires-Dist: pre-commit; extra == "dev"
19
+ Requires-Dist: pydoclint; extra == "dev"
20
+ Requires-Dist: ruff; extra == "dev"
21
+ Requires-Dist: pyarrow; extra == "dev"
22
+ Requires-Dist: pyfame; extra == "dev"
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: syrupy; extra == "dev"
25
+ Provides-Extra: docs
26
+ Requires-Dist: zensical; extra == "docs"
27
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
28
+ Provides-Extra: realtime
29
+ Requires-Dist: forecast-realtime>=0.5.3; extra == "realtime"
30
+ Requires-Dist: news_decomp>=0.0.7; extra == "realtime"
31
+ Dynamic: license-file
32
+
33
+ # Staggered-Combination MIDAS
34
+ Mixed-frequency nowcasting and short-horizon forecasting of quarterly targets (e.g. GDP) from monthly indicators, with forecast combination.
35
+
36
+ Experimental Python implementation of [Moreira (2025)](https://www.bankofengland.co.uk/macro-technical-paper/2025/nowcasting-gdp-at-the-bank-of-england-a-staggered-combination-midas-approach)
37
+
38
+ Read the [user manual](docs/index.md) for the full guide.
39
+
40
+ ## Features
41
+ * MIDAS regression with Almon, exponential-Almon, Beta and unrestricted lag polynomials.
42
+ * Quarterly OLS counterpart (`OLS` / `OLSSpec`) for hard quarterly
43
+ indicators, sharing the same forecasting and dummy interface.
44
+ * Direct multi-horizon forecasting: one model per horizon `h`, fit and stored together.
45
+ * Outlier dummies on the target (`dummy_periods`) absorbed at the target frequency.
46
+ * End-to-end combination pipeline `MidasCombo`:
47
+ * Average, inverse-error (`mae`, `mse`, `rmse`) and regression
48
+ weights across indicators.
49
+ * Rolling-window and discounted-error variants.
50
+ * Combinations of combinations (a `ComboSpec` can reference other `ComboSpec`s as sources).
51
+ * NLS estimation of non-linear weight schemes (Almon-exp, Beta).
52
+
53
+ ## Project Structure
54
+
55
+ ├── src/nowcast_midas/ # Source code
56
+ ├── docs/ # Zensical documentation site
57
+ ├── examples/ # Example scripts
58
+ ├── tests/midas/ # Unit tests
59
+ └── ...
60
+
61
+ ## Installation
62
+ ```bash
63
+ pip install -e . # runtime
64
+ pip install -e ".[dev]" # + test / lint tooling
65
+ pip install -e ".[docs]" # + Zensical docs build
66
+ ```
67
+
68
+ Python ≥ 3.10.
69
+
70
+ ## Quick start
71
+ ```python
72
+ from nowcast_midas import MidasCombo, MidasSpec, OLSSpec, ComboSpec
73
+ from nowcast_midas.utils import sample_combo_data
74
+
75
+ # Simulated data: three monthly series, one quarterly regressor, and a quarterly target.
76
+ target, regressors, info = sample_combo_data(n_quarters=60, seed=42)
77
+ outlier = info["outlier_date"]
78
+
79
+ # Two monthly MIDAS indicators and one quarterly OLS indicator.
80
+ midas_monthly_1 = MidasSpec(
81
+ "monthly_1", method="almon", n_lags=6, dummy_periods=[outlier]
82
+ )
83
+ midas_monthly_2 = MidasSpec(
84
+ "monthly_2", method="almon", n_lags=6, dummy_periods=[outlier]
85
+ )
86
+ ols_quarterly_1 = OLSSpec("quarterly_1", n_lags=1, dummy_periods=[outlier])
87
+
88
+ # Two MIDAS models combined via inverse-MSE weights ...
89
+ soft_combo = ComboSpec(
90
+ name="soft_combo",
91
+ sources=[midas_monthly_1, midas_monthly_2],
92
+ method="mse",
93
+ window=8,
94
+ discount_rate=0.95,
95
+ )
96
+
97
+ # ... then merged with a quarterly OLS model via constrained regression.
98
+ final_combo = ComboSpec(
99
+ name="final_combo",
100
+ sources=[soft_combo, ols_quarterly_1],
101
+ method="regression",
102
+ )
103
+
104
+ model = MidasCombo(combo_specs=final_combo, horizons=3)
105
+
106
+ model.fit(target=target, regressors=regressors)
107
+ oos = model.forecast() # wide table: one column per (variable, horizon)
108
+ print(model.summary(horizon=0))
109
+ ```
110
+
111
+ ## Selected documentation
112
+ * [SC-MIDAS framework](docs/methods/sc_midas_framework.md)
113
+ * [Weighting schemes](docs/methods/combo.md)
114
+ * [MIDAS model](docs/guide/midas_model.md)
115
+ * [SC-MIDAS pipeline](docs/guide/sc_midas.md)
116
+ * [Real-time analysis](docs/guide/realtime.md)
117
+
118
+ ## Selected examples
119
+ * [MIDAS, MultiMIDAS, and SC-MIDAS](examples/midas.py)
120
+ * [SC-MIDAS with forecast-realtime](examples/realtime_midas.py)
121
+
122
+ ## Contributing
123
+ * See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the code.
124
+ * Open an issue with questions or ideas.
125
+
126
+ ## Main references
127
+ * [Moreira (2025)](https://www.bankofengland.co.uk/macro-technical-paper/2025/nowcasting-gdp-at-the-bank-of-england-a-staggered-combination-midas-approach)
128
+ * [Ghysels, Santa-Clara and Valkanov (2004)](https://escholarship.org/uc/item/9mf223rs)
129
+ * [Ghysels, Sinko and Valkanov (2007)](https://doi.org/10.1080/07474930600972186)
130
+
131
+ ## Data Classification
132
+ Bank of England Data Classification: OFFICIAL BLUE
@@ -0,0 +1,100 @@
1
+ # Staggered-Combination MIDAS
2
+ Mixed-frequency nowcasting and short-horizon forecasting of quarterly targets (e.g. GDP) from monthly indicators, with forecast combination.
3
+
4
+ Experimental Python implementation of [Moreira (2025)](https://www.bankofengland.co.uk/macro-technical-paper/2025/nowcasting-gdp-at-the-bank-of-england-a-staggered-combination-midas-approach)
5
+
6
+ Read the [user manual](docs/index.md) for the full guide.
7
+
8
+ ## Features
9
+ * MIDAS regression with Almon, exponential-Almon, Beta and unrestricted lag polynomials.
10
+ * Quarterly OLS counterpart (`OLS` / `OLSSpec`) for hard quarterly
11
+ indicators, sharing the same forecasting and dummy interface.
12
+ * Direct multi-horizon forecasting: one model per horizon `h`, fit and stored together.
13
+ * Outlier dummies on the target (`dummy_periods`) absorbed at the target frequency.
14
+ * End-to-end combination pipeline `MidasCombo`:
15
+ * Average, inverse-error (`mae`, `mse`, `rmse`) and regression
16
+ weights across indicators.
17
+ * Rolling-window and discounted-error variants.
18
+ * Combinations of combinations (a `ComboSpec` can reference other `ComboSpec`s as sources).
19
+ * NLS estimation of non-linear weight schemes (Almon-exp, Beta).
20
+
21
+ ## Project Structure
22
+
23
+ ├── src/nowcast_midas/ # Source code
24
+ ├── docs/ # Zensical documentation site
25
+ ├── examples/ # Example scripts
26
+ ├── tests/midas/ # Unit tests
27
+ └── ...
28
+
29
+ ## Installation
30
+ ```bash
31
+ pip install -e . # runtime
32
+ pip install -e ".[dev]" # + test / lint tooling
33
+ pip install -e ".[docs]" # + Zensical docs build
34
+ ```
35
+
36
+ Python ≥ 3.10.
37
+
38
+ ## Quick start
39
+ ```python
40
+ from nowcast_midas import MidasCombo, MidasSpec, OLSSpec, ComboSpec
41
+ from nowcast_midas.utils import sample_combo_data
42
+
43
+ # Simulated data: three monthly series, one quarterly regressor, and a quarterly target.
44
+ target, regressors, info = sample_combo_data(n_quarters=60, seed=42)
45
+ outlier = info["outlier_date"]
46
+
47
+ # Two monthly MIDAS indicators and one quarterly OLS indicator.
48
+ midas_monthly_1 = MidasSpec(
49
+ "monthly_1", method="almon", n_lags=6, dummy_periods=[outlier]
50
+ )
51
+ midas_monthly_2 = MidasSpec(
52
+ "monthly_2", method="almon", n_lags=6, dummy_periods=[outlier]
53
+ )
54
+ ols_quarterly_1 = OLSSpec("quarterly_1", n_lags=1, dummy_periods=[outlier])
55
+
56
+ # Two MIDAS models combined via inverse-MSE weights ...
57
+ soft_combo = ComboSpec(
58
+ name="soft_combo",
59
+ sources=[midas_monthly_1, midas_monthly_2],
60
+ method="mse",
61
+ window=8,
62
+ discount_rate=0.95,
63
+ )
64
+
65
+ # ... then merged with a quarterly OLS model via constrained regression.
66
+ final_combo = ComboSpec(
67
+ name="final_combo",
68
+ sources=[soft_combo, ols_quarterly_1],
69
+ method="regression",
70
+ )
71
+
72
+ model = MidasCombo(combo_specs=final_combo, horizons=3)
73
+
74
+ model.fit(target=target, regressors=regressors)
75
+ oos = model.forecast() # wide table: one column per (variable, horizon)
76
+ print(model.summary(horizon=0))
77
+ ```
78
+
79
+ ## Selected documentation
80
+ * [SC-MIDAS framework](docs/methods/sc_midas_framework.md)
81
+ * [Weighting schemes](docs/methods/combo.md)
82
+ * [MIDAS model](docs/guide/midas_model.md)
83
+ * [SC-MIDAS pipeline](docs/guide/sc_midas.md)
84
+ * [Real-time analysis](docs/guide/realtime.md)
85
+
86
+ ## Selected examples
87
+ * [MIDAS, MultiMIDAS, and SC-MIDAS](examples/midas.py)
88
+ * [SC-MIDAS with forecast-realtime](examples/realtime_midas.py)
89
+
90
+ ## Contributing
91
+ * See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the code.
92
+ * Open an issue with questions or ideas.
93
+
94
+ ## Main references
95
+ * [Moreira (2025)](https://www.bankofengland.co.uk/macro-technical-paper/2025/nowcasting-gdp-at-the-bank-of-england-a-staggered-combination-midas-approach)
96
+ * [Ghysels, Santa-Clara and Valkanov (2004)](https://escholarship.org/uc/item/9mf223rs)
97
+ * [Ghysels, Sinko and Valkanov (2007)](https://doi.org/10.1080/07474930600972186)
98
+
99
+ ## Data Classification
100
+ Bank of England Data Classification: OFFICIAL BLUE
@@ -0,0 +1,72 @@
1
+ [project]
2
+ name = "nowcast-midas"
3
+ version = "0.0.1"
4
+
5
+ description = "Staggered-Combination MIDAS model"
6
+
7
+ authors = [
8
+ {name="James Kensett", email="James.Kensett@bankofengland.co.uk"},
9
+ {name="Paul Labonne", email="Paul.Labonne@bankofengland.co.uk"},
10
+ {name="Andre Moreira", email="Andre.Moreira@bankofengland.co.uk"},
11
+ ]
12
+
13
+ maintainers = [
14
+ {name="James Kensett", email="James.Kensett@bankofengland.co.uk"},
15
+ {name="Paul Labonne", email="Paul.Labonne@bankofengland.co.uk"},
16
+ ]
17
+
18
+ license = {text = "MIT"}
19
+
20
+ readme = "README.md"
21
+
22
+ requires-python = ">=3.10"
23
+
24
+ dependencies = [
25
+ "numpy",
26
+ "jax",
27
+ "scipy",
28
+ "matplotlib",
29
+ "pandas",
30
+ "tqdm",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ dev = [
35
+ "pre-commit",
36
+ "pydoclint",
37
+ "ruff",
38
+ "pyarrow",
39
+ "pyfame",
40
+ "pytest",
41
+ "syrupy",
42
+ ]
43
+
44
+ docs = [
45
+ "zensical",
46
+ "mkdocstrings[python]",
47
+ ]
48
+
49
+ realtime = [
50
+ "forecast-realtime >= 0.5.3",
51
+ "news_decomp >= 0.0.7",
52
+ ]
53
+
54
+ [build-system]
55
+ requires = ["setuptools"]
56
+ build-backend = "setuptools.build_meta"
57
+
58
+ [tool.ruff.lint]
59
+ # Exclude files and directories
60
+ exclude = [
61
+ ".git",
62
+ ".ruff_cache",
63
+ "__pycache__",
64
+ "build",
65
+ "dist",
66
+ ]
67
+
68
+ [tool.ruff.lint.per-file-ignores]
69
+ "__init__.py" = ["F401"] # Ignore unused imports in __init__.py files
70
+
71
+ [tool.pytest.ini_options]
72
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ from .midas import MIDAS, FittedMidas
2
+ from .midas_combo import MidasCombo
3
+ from .multi_midas import FittedMultiMidas, MultiMIDAS, VariableFit
4
+ from .ols import OLS, FittedOLS
5
+ from .specs import ComboSpec, MidasSpec, MultiMidasSpec, OLSSpec, VariableSpec
6
+
7
+ __all__ = [
8
+ "MIDAS",
9
+ "OLS",
10
+ "ComboSpec",
11
+ "FittedMidas",
12
+ "FittedMultiMidas",
13
+ "FittedOLS",
14
+ "MidasCombo",
15
+ "MidasSpec",
16
+ "MultiMIDAS",
17
+ "MultiMidasSpec",
18
+ "OLSSpec",
19
+ "VariableFit",
20
+ "VariableSpec",
21
+ ]