AI智能总结
A Python Package toAssist Macroframework Concepts and Examples Sakai Ando, Shuvam Das, Sultan Orazbayev WP/25/172 progress by the author(s) and are published toelicit comments and to encourage debate.The views expressed in IMF Working Papers are 2025AUG IMF Working PaperResearch Department A Python Package to Assist Macroframework Forecasting: Concepts and ExamplesPrepared bySakai Ando, Shuvam Das, and Sultan Orazbayev* Authorized for distribution byEmine Boz IMF Working Papersdescribe research in progress by the author(s) and are published to elicitcomments and to encourage debate.The views expressed in IMF Working Papers are those of the ABSTRACT:In forecasting economic time series, statistical models often need to be complemented withaprocess to impose variousconstraintsin a smooth manner.Systematicallyimposingconstraintsand retainingsmoothness are important but challenging.Ando (2024) proposes a systematic approach, but a user-friendlypackage to implementithas not been developed.This paper addresses this gap by introducing a Python RECOMMENDED CITATION:Ando, Sakai, Shuvam Das, and Sultan Orazbayev (2025),“A Python Package toAssist Macroframework Forecasting: Concepts and Examples,”IMF Working Paper. WORKING PAPERS A Python Package to AssistMacroframework Forecasting Concepts and Examples Prepared by Sakai Ando, Shuvam Das, Sultan Orazbayev 1.Introduction In forecasting economic time series, statistical models often need to be supplemented with procedures thatimpose constraints whilepreserving smoothnessover time. For example, GDP forecasts generated usingmodels such as autoregressions or decision trees may not align with the long-term growth rates anticipated byforecasters. In such cases, forecasters aim to adjust the time series so that it convergessmoothlyto thedesired long-term growth path. However, ad hoc constraint imposition,such as manually alteringonlythe Systematically imposing constraints while retaining smoothness is importantbutchallenging. Constraints oftenstem from accounting identities and expert judgment, making their incorporation essential forinternalconsistency. Smoothness is equally critical, as optimal forecasts typically exhibit less volatility than historicaldata. For instance, in a random walk, historical data are volatile, but the optimal forecast is constant over time, Ando (2024)proposesasystematic approach to impose constraints andmaintainsmoothness, but a user-friendly package to implementithas not been developed. Buildingon the forecast reconciliation literature,notablyreviewed by Athanasopoulos et al. (2024)andthe smoothing method of Hodrick and Prescott (1997),Ando (2024)definesa quadraticprogrammingproblem thatcan impose both the constraints and temporal Existingpackages in R and Pythonassistforecast reconciliation and smoothing separatelybut not jointly. Forinstance, thehts(Hyndman et al.,2021)andFoReco(Girolimetto andDiFonzo, 2023)packages in Rsupportreconciliation,but the reconciled forecast may not be smooth over time.This is also the caseforhierarchicalforecast(Olivares et al., 2024)packagein Python.On the other hand,packages,such as This paper introducesmacroframe-forecast, a Python packagethat enables users to generate forecasts thatare temporally smooth and meet user-defined constraints.The packageproducesforecasts in two stepsa laAndo and Kim (2023)and Ando (2024).The framework ismodel agnosticin its first step, allowing users to 2019), including machine learning pipelines or traditional econometric methods.Compatibility withthe richmachine learning packagesis one of the benefitsof writinga package in Python.In the second step, theseforecasts undergo a reconciliation processa la Ando (2024)that enforces equality or inequality constraintswhile smoothing the forecast trajectory over time.The two-step approach contrastswithChan et al. (2025), The packagefeaturesplug-and-playsimplicityandflexibilityto fine-tunethe details.The interface is designedso that forecasters can use thepackage’smain classMFFwithoutexplicitlyproviding various mathematicalinputs forthe reconciliation problem.For example, users can specify constraints using strings, rather thaninputtingmatricesas required by other packages.Byunderstanding theconceptual framework and internal We demonstrate the package’s functionality with two examples. The first example focuses on a simple case inwhich a single variable,U.S. GDP,is forecasted subject to the constraint that the growth rate at the end of theforecast horizonmatches a predefined value. The second example illustrates a multivariable scenario, The rest of the paper isstructuredas follows. Section 2 outlines the conceptual frameworkofthe methodsimplemented in the package. Section 3providesinstructions forinstalling and using the package,with 2.Conceptual framework This section presents the conceptual framework behind thePythonpackage.The framework consists of twosteps, where the first step provides users with a flexible choi