macroframe-forecast


Namemacroframe-forecast JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryMacroframework forecasting with accounting identities
upload_time2025-08-04 16:50:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords econometrics forecasting high-dimensional forecasting macroeconomic identities macroframework
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `macroframe-forecast`: a Python package to assist with macroframework forecasting


[![!pypi](https://img.shields.io/pypi/v/macroframe-forecast?color=green)](https://pypi.org/project/macroframe-forecast/) [![Downloads](https://static.pepy.tech/personalized-badge/macroframe-forecast?period=total&units=international_system&left_color=grey&right_color=blue&left_text=cumulative%20(pypi))](https://pepy.tech/project/macroframe-forecast)

This repository contains the Python code to assist macroframework forecasting. The methodologies are described in [Systematizing Macroframework Forecasting: High-Dimensional Conditional Forecasting with Accounting Identities](https://link.springer.com/article/10.1057/s41308-023-00225-8) and [Smooth Forecast Reconciliation](https://www.imf.org/en/Publications/WP/Issues/2024/03/22/Smooth-Forecast-Reconciliation-546654).

# Documentation

Please refer to [this link](https://sakaiando.github.io/macroframe-forecast/) for documentation.

# Installation

To install the `macroframe-forecast` package, run the following from the repository root:

```shell
pip install macroframe-forecast
```

# Quick start

```python
import numpy as np
import pandas as pd
from sktime.datasets import load_macroeconomic

from macroframe_forecast import MFF

df_true = load_macroeconomic().iloc[:, :5]

# input dataframe
df = df_true.copy()
fh = 5
df.iloc[-fh:, 0] = np.nan

# apply MFF
m = MFF(df, equality_constraints=[])
df2 = m.fit()
df0 = m.df0
df1 = m.df1
df1_model = m.df1_model
smoothness = m.smoothness
shrinkage = m.shrinkage

# plot results
t0 = -30
ax = df0.iloc[t0:, 0].plot(label="df0")
df1.iloc[t0:, 0].plot(ax=ax, label="df1")
df2.iloc[t0:, 0].plot(ax=ax, label="df2")
df_true.iloc[t0:, 0].plot(ax=ax, label="df_true")
ax.axvline(x=df0.index[-fh])
ax.legend()

print("smoothness", smoothness.values)
print("shrinkage", np.round(shrinkage, 3))
for ri, ci in np.argwhere(df.isna()):
    print(df1_model.index[ri], df1_model.columns[ci], df1_model.iloc[ri, ci].best_params_)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "macroframe-forecast",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "Sakai Ando <sando@imf.org>, Sultan Orazbayev <sorazbayev@imf.org>",
    "keywords": "econometrics, forecasting, high-dimensional forecasting, macroeconomic identities, macroframework",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/c7/da/78910e2dfece030d9e5a2fea6bc59c6915d853d3c01532b8ae52eb643408/macroframe_forecast-0.1.5.tar.gz",
    "platform": null,
    "description": "# `macroframe-forecast`: a Python package to assist with macroframework forecasting\n\n\n[![!pypi](https://img.shields.io/pypi/v/macroframe-forecast?color=green)](https://pypi.org/project/macroframe-forecast/) [![Downloads](https://static.pepy.tech/personalized-badge/macroframe-forecast?period=total&units=international_system&left_color=grey&right_color=blue&left_text=cumulative%20(pypi))](https://pepy.tech/project/macroframe-forecast)\n\nThis repository contains the Python code to assist macroframework forecasting. The methodologies are described in [Systematizing Macroframework Forecasting: High-Dimensional Conditional Forecasting with Accounting Identities](https://link.springer.com/article/10.1057/s41308-023-00225-8) and [Smooth Forecast Reconciliation](https://www.imf.org/en/Publications/WP/Issues/2024/03/22/Smooth-Forecast-Reconciliation-546654).\n\n# Documentation\n\nPlease refer to [this link](https://sakaiando.github.io/macroframe-forecast/) for documentation.\n\n# Installation\n\nTo install the `macroframe-forecast` package, run the following from the repository root:\n\n```shell\npip install macroframe-forecast\n```\n\n# Quick start\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom sktime.datasets import load_macroeconomic\n\nfrom macroframe_forecast import MFF\n\ndf_true = load_macroeconomic().iloc[:, :5]\n\n# input dataframe\ndf = df_true.copy()\nfh = 5\ndf.iloc[-fh:, 0] = np.nan\n\n# apply MFF\nm = MFF(df, equality_constraints=[])\ndf2 = m.fit()\ndf0 = m.df0\ndf1 = m.df1\ndf1_model = m.df1_model\nsmoothness = m.smoothness\nshrinkage = m.shrinkage\n\n# plot results\nt0 = -30\nax = df0.iloc[t0:, 0].plot(label=\"df0\")\ndf1.iloc[t0:, 0].plot(ax=ax, label=\"df1\")\ndf2.iloc[t0:, 0].plot(ax=ax, label=\"df2\")\ndf_true.iloc[t0:, 0].plot(ax=ax, label=\"df_true\")\nax.axvline(x=df0.index[-fh])\nax.legend()\n\nprint(\"smoothness\", smoothness.values)\nprint(\"shrinkage\", np.round(shrinkage, 3))\nfor ri, ci in np.argwhere(df.isna()):\n    print(df1_model.index[ri], df1_model.columns[ci], df1_model.iloc[ri, ci].best_params_)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Macroframework forecasting with accounting identities",
    "version": "0.1.5",
    "project_urls": {
        "homepage": "https://github.com/sakaiando/macroframe-forecast",
        "repository": "https://github.com/sakaiando/macroframe-forecast"
    },
    "split_keywords": [
        "econometrics",
        " forecasting",
        " high-dimensional forecasting",
        " macroeconomic identities",
        " macroframework"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2c1d3d7c42707c40e3079625c51cc349103496e6e7e45b281efc113d967690bd",
                "md5": "9af021823793913f0db03c0be0a09453",
                "sha256": "e1e94e4290d6da384b182a95cc01789e82ff35209bb9b998e6561b0da5169edf"
            },
            "downloads": -1,
            "filename": "macroframe_forecast-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9af021823793913f0db03c0be0a09453",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 26312,
            "upload_time": "2025-08-04T16:50:17",
            "upload_time_iso_8601": "2025-08-04T16:50:17.106352Z",
            "url": "https://files.pythonhosted.org/packages/2c/1d/3d7c42707c40e3079625c51cc349103496e6e7e45b281efc113d967690bd/macroframe_forecast-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c7da78910e2dfece030d9e5a2fea6bc59c6915d853d3c01532b8ae52eb643408",
                "md5": "cb11e7c84cc956c83d8ee2b3e1491d6c",
                "sha256": "db657a0db2566f12ed1921be1506c5bdf86fde56e94ae1630354ba9e54681551"
            },
            "downloads": -1,
            "filename": "macroframe_forecast-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "cb11e7c84cc956c83d8ee2b3e1491d6c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 146258,
            "upload_time": "2025-08-04T16:50:18",
            "upload_time_iso_8601": "2025-08-04T16:50:18.453856Z",
            "url": "https://files.pythonhosted.org/packages/c7/da/78910e2dfece030d9e5a2fea6bc59c6915d853d3c01532b8ae52eb643408/macroframe_forecast-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 16:50:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sakaiando",
    "github_project": "macroframe-forecast",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "macroframe-forecast"
}
        
Elapsed time: 4.22391s