EconBase
← Back to paper

An Adaptive Moving Average for Macroeconomic Monitoring

Extracted main text — title through conclusion, appendix excluded. This is what our citation measures are computed over, published so the extraction can be checked by eye.

64,965 characters · 10 sections · 30 citation commands

Rendered from LaTeX for readability, not typeset faithfully. Citation keys are highlighted; maths is left as source; figures, tables and equation environments are summarised rather than reproduced; unrecognised commands are greyed out so nothing is silently dropped. Email addresses are removed.

0.9cm 18.9522 dpd An Adaptive Moving Average for Macroeconomic Monitoring . 0.25cm

\sloppy

\\[-0.2cm] \fontfamily{phv}\selectfont \@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\notsolarge{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14} Université du Québec à Montréal \and Karin Klieber \\[-0.2cm] \fontfamily{phv}\selectfont \@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\@setfontsize\notsolarge{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14}{12}{14} Oesterreichische Nationalbank }

abstractThe use of moving averages is pervasive in macroeconomic monitoring, particularly for tracking noisy series such as inflation. The choice of the look-back window is crucial. Too long of a moving average is not timely enough when faced with rapidly evolving economic conditions. Too narrow averages are noisy, limiting signal extraction capabilities. As is well known, this is a bias-variance trade-off. However, it is a time-varying one: the optimal size of the look-back window depends on current macroeconomic conditions. In this paper, we introduce a simple adaptive moving average estimator based on a Random Forest using as sole predictor a time trend. Then, we compare the narratives inferred from the new estimator to those derived from common alternatives across series such as headline inflation, core inflation, and real activity indicators. Notably, we find that this simple tool provides a different account of the post-pandemic inflation acceleration and subsequent deceleration.

\thispagestyle{empty}

\setcounter{page}{1}

\newgeometry{left=2 cm, right= 2 cm, top=2.3 cm, bottom=2.3 cm}

Introduction

comment\begin{itemize} • Barunik, Hanus, Vacha: Deep Learning the Persistence Structure of Economic Variables (not available yet) • Thomas, Fries, De Truchis: Path Prediction of Anticipative Alpha-Stable Moving Averages Using Semi-Norm Represetations (incomprehensible for KK) \end{itemize}

Moving averages are widely used in macroeconomic monitoring. For example, the practice is so entrenched for inflation that many news outlets report year-over-year growth rates as the monthly inflation rate. However, there is little sacred about the twelve-months moving average, and the length of the window is very much a tuning parameter, as practitioners are well aware.

Figure (ref) below shows month-over-month US headline CPI inflation during two turbulent periods, overlaid with three-months (MA(3)) and twelve-months (MA(12)) moving averages. In both cases, the commonly used MA(12) not only lags behind MA(3) but also distorts visual interpretations of inflation dynamics. The three sharp drops in energy prices (November 2008, April 2020, July 2022) are given an extended release by the longer moving average, creating an impression of gradual change when, in reality, these were abrupt shifts. During the Great Recession, MA(3) inflation appears to be on target by early 2009, not 2010 as observed for MA(12). Throughout the post-Covid disinflation phase, the perceived slowdown in MA(12) is actually an elongation of a single abrupt shift in July 2022. Notably, from March 2022 to March 2024, inflation had stabilized 1.5 percentage points above the 2% target when viewed through MA(3).

figure[figure omitted — 254 chars of source]

While the benefits of shorter moving averages are self-evident in crisis periods, the longer average usually gets the upper hand in stable times, as it reduces variance without significant bias. Therefore, we are facing a time-varying bias-variance trade-off in the construction of the rolling window, and more generally, in the weighting of recent to distant realized values.

Given this, our research question is simple: can we design a moving average estimator with a window size that adapts automatically to changing macroeconomic conditions? The answer is yes, and our proposed estimator is a Random Forest (RF) with the time series of interest as target and a time trend as sole predictor. We refer to this as Adaptive learning-based Moving Average, by the more compact {\selectfont \fontfamily{phv}\color{darkpowderblue} AlbaMA}.

Adaptability to smooth versus abrupt changes is procured by RF natural qualities as an adaptive nearest neighbor estimator lin2006random. Intuitively, this occurs because if there is a clear break point, most randomized trees identify the key feature and split the sample at that point (using the trend). Therefore, their average will also feature the distinct shift. In the opposite scenario, i.e., gradual change, splits are randomly scattered along the underlying slope, and their aggregation elicits the slope as an average of a “staircases” distribution. MRFjae documents this behavior in a time series context, recommending the inclusion of time trends in RF's features set to nonparametrically approximate exogenous structural change of any form in generalized time-varying coefficients. This paper leverages these insights for the simpler task of constructing adaptive moving averages, interpreted as a time-varying intercept model. As such, AlbaMA can be implemented with two or three lines of code using standard RF packages.

\vskip 0.15cm { \sc Results.} We begin by illustrating the adaptive behavior of AlbaMA using simulated data that includes both abrupt and gradual changes. As anticipated, we find that when a clear shift occurs, herd behavior dominates among the trees in the ensemble, while smoother changes lead to more dispersed splits. In the case of abrupt changes, repeated averaging of similar splits makes the break point stand out within AlbaMA. Conversely, for gradual changes, the dispersed splits average out to reflect a smooth transition, provided they are scattered evenly between the old and new state.

In our empirical analysis, we apply AlbaMA to key US and Euro Area (EA) variables commonly reported as moving averages, such as inflation, core inflation, Purchasing Managers Index (PMI), and industrial production. For each case, we visually compare AlbaMA to various benchmark averages and examine its one-sided versus two-sided behavior around economic turning points. Additionally, we analyze the weighting of recent observations implied by AlbaMA to identify when and where the weights adapt rapidly to changing conditions.

During stable periods, we find that AlbaMA’s alignment with traditional moving averages, such as MA(12) and MA(6), varies based on the target variable. For example, AlbaMA’s weighting for US headline inflation closely resembles that of an MA(6), whereas for core inflation, its “resting” average aligns almost exactly with an MA(12). When rapid changes occur, AlbaMA swiftly adjusts its weighting to emphasize recent observations. We study in depth the US headline and core inflations cases. First, we find that AlbaMA does not signal a gradual post-pandemic slowdown in US headline inflation but instead identifies a sharp decline in July 2022, followed by a stabilization around 3%. We report the weight allocated to the most recent observation nearly doubles at that critical juncture.

A similar but more pronounced pattern is observed for the core inflation surge of 2021-2022, marked by a regime shift in June 2021, followed by a lengthy, gradual decline. Analysis of the implied RF weights shows that this behavior stems from AlbaMA abandoning its MA(12) structure for a near MA(3) composition for the period between March 2021 and August 2021-- before gradually reverting back to MA(12). We observe comparable patterns in the Euro Area series and US PMI during the Great Recession.

Lastly, we document AlbaMA’s superior ability to approximate its ideal, yet unattainable, two-sided behavior. This assessment is based on comparing, across our nine series, how closely the one-sided estimate used throughout the paper matches the ex-post optimal weighted moving average in terms of mean-squared error. AlbaMA consistently performs well against all other moving averages, particularly surpassing the other adaptive option in our analysis, the Savitzky-Golay filter.

\vskip 0.15cm { \sc Literature -- Moving Averages.} We now survey briefly the existing (and inevitably extensive) literature along three axes. The ubiquitous smoothing techniques are moving averages with a predefined, fixed window size. For macroeconomic variables, these are typically the average over a quarter, half-year, or year (3, 6, 12, respectively). A simple and equally popular extension is the exponential moving average, where past observations receive exponentially decreasing weights brown1956,holt2004forecasting. These can be seen as one-sided exponential kernels, putting greater weight on recent observations compared to more distant ones. While the measure reduces noise and emphasizes more recent price changes, it is not adaptive as the bandwidth is fixed to a single value throughout the sample.

The Savitzky-Golay (SG) filter is a more sophisticated, adaptive approach for smoothing noisy data savitzky1964smoothing. It works by fitting a polynomial to a small subset of neighboring data points, allowing the filter to adapt locally to variations in the data. Smooth estimates are obtained by minimizing the sum of squared distances between the polynomial and the original points—yielding a least squares polynomial fit with closed-form linear coefficients. This filter is particularly valued in fields like chemistry and engineering, where preserving the signal’s shape and derivative information is crucial. However, it is well-known that the SG filter is not well-suited for one-sided (real-time) analysis, most notably, because of its reliance on a symmetric window around each point. As we see in our empirical results, two-sided results for AlbaMA and SG sometimes closely resemble one another, but AlbaMA has a definitive edge on one-sided results.

In finance, although used less frequently, SG serves in technical analysis by retaining critical slopes and peaks, thereby enhancing the accuracy of, e.g., momentum assessments. Other related suggestions in the finance literature include moving averages that adjust smoothing based on the volatility of the data, i.e,. Kaufman's Adaptive Moving Average kaufman2013trading, or leveraging fractal geometry to adapt to market price movements, as in the Fractal Adaptive Moving Average ehlers2005frama.

\vskip 0.15cm { \sc Literature -- Trend-Cycle Decompositions.} Separating time series into their trend and cyclical components has a long tradition in macroeconomics. While we focus on smoothing noisy stationary series, which is the usual prerogative of moving averages, smoothers designed for non-stationary series can also be applied to this task. One of the most influential works is the Hodrick-Prescott filter hodrick1997postwar, which extracts the trend by minimizing the sum of squared deviations subject to a penalty ensuring smoothness. This concept has inspired numerous variations.

For example, $l_1$ trend filtering proposed by kim2009ell_1 adjusts the penalization by replacing the sum of squares with the sum of absolute values (i.e., an $l_1$ norm). This results in a smooth, piecewise linear trend. By being both fast and locally adaptive, the measure has beneficial features compared to wavelets and smoothing splines hastie1990generalized,donoho1998minimax, which are fast but not adaptive, and to locally adaptive regression splines mammen1997locally, which are adaptive but not fast tibshirani2014adaptive,tibshirani2011solution. Blending insights from both the machine learning and econometrics literature, phillips2021boosting suggest iterating the HP filter in multiple steps by using the residuals from previous iterations, which is conceptually similar to $l_2$-boosting.

Instead of relying on smoothing parameters and penalizing the smoothness of the trend, Hamilton2018 employs a linear regression-based approach. The trend component is extracted as the residuals from a direct forecasting regression of the series on its own lags for a pre-speficied horizon (a tuning parameter, often set to two years in macroeconomic context). We note that a special case of the Hamilton filter, where one includes a single lag and sets its coefficient to one (which is not always far from estimated coefficients results) implies a one-sided moving average of two years. Therefore, in this case, but also more generally, the filter's shape is not intended to be adaptive.

\vskip 0.15cm { \sc Literature -- Zooming on Inflation.} While we consider various macroeconomic variables in our empirical results, the central focus will follow from our initial motivation: inflation. From the forecasting literature, an important contribution is stock2007has who introduce the unobserved components model with stochastic volatility (UC-SV), a time-varying trend-cycle model. This is, in fact, a time-varying integrated moving average, where the MA coefficient adapts inversely with the ratio of the variances of the permanent and transitory disturbances. Relatedly, barunik2023dynamic identify the heterogeneous persistence in time series via wold decomposition and localized regressions. Their proposed time-varying extended wold decomposition allows for smoothly changing persistence in economic data.

In the spirit of exponential moving averages, eeckhout2023instantaneous suggests to use a kernel-based measure for inflation. This ensures that greater weight is assigned to recent observations compared to more distant ones, with the degree of smoothing controlled by a bandwidth parameter. Kernel approaches to moving averages (and time-varying parameters, giraitis2014inference) partly deal with issues like base effects caused by hard-threshold inclusion/exclusion rules of traditional rolling windows. While the measure reduces noise and emphasizes more recent price changes, it is not adaptive as the bandwidth is fixed to a single value throughout the sample.

\vskip 0.15cm { \sc Outline.} The paper is organized as follows. Section (ref) reviews Random Forest and showcases its adaptive moving average properties on simulated data. Section (ref) presents a comparison of empirical estimates derived from our method with alternative approaches, using key US and EA time series. Section (ref) concludes.

Methodology

We begin by reviewing Random Forest and discussing the specifics of the case with a single deterministic regressor, including how to retrieve AlbaMA's time-varying weights. Next, we use simulations to illustrate how the wisdom of crowds (of trees) elicits abrupt or gradual changes, depending on the underlying DGP. Finally, we demonstrate how AlbaMA's weights adapt to evolving dynamics.

A Review of Random Forest

Random Forest breiman2001 is a diversified ensemble of regression trees. We first introduce regression trees, present their estimation algorithm, and discuss the ensembling procedure.

\vskip 0.15cm

{ \sc A Tree.} Consider a time-series scenario where $y_t$ represents a time series for which we want to compute some sort of moving average. A simple decision tree's prediction, using a time trend as sole predictor, could look like

\Tree[.{2022m6 to 2023m12} [.{$t \geq \text{2023m1}$} [.{$t \geq \text{2023m8}$} {Leaf \( A \) : $\phantom{–} \hat{y}_t= \overline{y}_{t \in A} \phantom{-}$} ] [.{$t < \text{2023m8}$} {Leaf \( B \) : $\phantom{–} \hat{y}_t = \overline{y}_{t \in B} \phantom{-}$} ] ] [.{$t < \text{2023m1}$} {Leaf \( C \) : $\phantom{–} \hat{y}_t = \overline{y}_{t \in C} \phantom{-}$} ] ]

where $\overline{y}_{t \in A}$ denotes the average of the target's observations falling into leaf $A$. In practice, the cutting points (e.g., $t \geq \text{2023m8}$) are unknown unless we assume a window size. \textcolor{black}{In order to build an adaptive MA, we wish to learn these window sizes and their location, which is precisely what regression trees can offer.}

\vskip 0.15cm { \sc Estimation.} The usual strategy -- introduced as Classification and Regression Trees (CART) in breiman1984classification -- is to deploy a {greedy} algorithm that {recursively} partitions the data according to

equation[equation omitted — 334 chars of source]

Here, $\min\limits_{k\in \mathcal{K}, c \in {\rm I\!R}}$ denotes the minimization over all possible splits, where $k$ indexes a variable in $\mathcal{K}$, representing available features, and $c$ is a real number representing the split point. Note that $\mathcal{K}$ will be fairly limited in our application, as we set $\mathcal{K}=[\, t \,]$. $L$ is a leaf, representing the sub-sample of data utilized by (ref) to estimate the next split. The first $L$ in the recursion is the whole training sample, then the algorithm proceeds recursively by using the subsamples created by the previous partition as the subsequent $L$'s in the next iteration. This process mechanically creates partitions of progressively smaller size until a stopping criterion is met, resulting in a set of terminal nodes where the prediction is the average of the $y_t$’s within each leaf. For example, the simple case illustrated above has three terminal nodes.

The overall goal of a single step is to find the optimal pair $( k^*, \, c^*)$ and the predicted values ($\mu_{1}, \, \mu_{2}$) that minimize the total within-leaf sum of squared errors. In our application, $ k^*$ is redundant and only $c^*$ is optimized along with $\mu_{1}$ and $ \mu_{2}$. In standard trees (such as (ref)), the latter are always the within-leaf average.

A single tree with many splits can capture complex data structures but suffers from high variance. In the extreme, we have $\hat{y}_t = y_t$, akin to a “moving average” with a window size of 1. Pruning reduces variance by merging terminal nodes and removing insignificant splits, but this approach is limited: the pruned tree remains locally optimized, and its performance heavily depends on the extent of pruning, a sensitive tuning parameter. Even more importantly, for our goal of creating a smooth moving average, a single tree is inadequate, as it can only capture abrupt changes.

\vskip 0.15cm { \sc Diversifying the Portfolio.} A highly effective strategy in machine learning is to create a diversified portfolio of trees, treating each tree ${\mathcal{T}}$ as a base learner and averaging their predictions. Turning a single tree into a forest involves three main steps:

enumerate• First, each tree should be allowed to grow deep, producing a large number of terminal nodes through extensive splitting. This depth results in overfitted trees if used individually, but when averaged, their collective output smooths the series. From a moving average application perspective, this signifies that we want single trees to deliver series that are more wiggly than not, because further averaging is on the way. • Second, we apply Bagging (Bootstrap Aggregation, breiman1996bagging), generating $B$ bootstrapped samples of the data and estimating each tree on a separate sample $b \in 1,\dots, B$. Bagging mitigates the inherent instability of individual trees and, in our MA application, improves the method’s ability to capture both smooth and abrupt changes by addressing the limitations of a single tree in representing continuous patterns. • Third, RF typically introduces perturbation by randomly selecting a subset of predictors at each split. However, in our application, we use a single predictor (a time-trend), so \texttt{ P} is not applicable here. Thus, properly speaking, AlbaMA is a bagged trees estimator.

The RF "prediction" at time $t$ is the average of the predictions from all $B$ trees: $\hat{y}_t^{\text{RF}} = \frac{1}{B} \sum_{b=1}^B {\mathcal{T}}_{b}(t)$. Therefore, it is an average of averages, and thus, a properly defined weighted average of $y_t$ and neighboring observations. It can also be interpreted as stochastic model averaging where the underlying models are MAs of different size and composition for each $t$. In the traditional bias-variance trade-off view, D lowers bias, while B (and P, where applicable) reduces variance. In our context, D and B work together to distinguish between abrupt and smooth changes, dynamically adapting the moving average window.

In this simplified case with a single regressor, the CART algorithm could theoretically be replaced by Lasso with indicator functions for each $t$, with bagging applied to the Lasso model. Nonetheless, we use Random Forest (RF), as its greedy tree optimization introduces more randomness, enabling bagging to more effectively reduce variance. Additionally, RF hyperparameters, like minimal leaf sizes, offer intuitive control for moving average applications.

Retrieving Moving Average Weights from Random Forest

To gain insights into the look-back window selected by the RF, we show how to back out the weights assigned to each observation in the training set. These weights correspond to the moving average coefficients, $w_t$, which, as discussed in DUAL, can be derived through post-processing of estimation outputs. This builds on the related literature on adpative nearest neighbors in RF lin2006random,koster2024simplifying and uses the insight that each individual tree's contribution to the final prediction can be expressed as: \[ \mathcal{T}_b(t) = \frac{1}{\sum_{\tau=1}^T I\left(\tau \in \mathcal{P}_b(t)\right)}\sum_{\tau=1}^T y_\tau I\left(\tau \in \mathcal{P}_b(t)\right) = \sum_{\tau=1}^T w_{b\tau} y_\tau. \] We define \(\mathcal{P}_b\) as the partition of the input space created by the tree's structure, corresponding to the specific region or leaf node where observation $t$ resides, based on the tree's splits and associated conditioning information. The final prediction, obtained by averaging over $B$ regression trees, provides the desired representation: \[ \hat{y}_t = \frac{1}{B} \sum_{b=1}^B \mathcal{T}_b(t) = \frac{1}{B} \sum_{b=1}^B \sum_{\tau=1}^T w_{b\tau t} y_\tau = \sum_{\tau=1}^T \underbrace{\frac{1}{B} \sum_{b=1}^B w_{b\tau t}}_{w_{\tau t}} y_\tau = \boldsymbol{w}_t \boldsymbol{y}. \] In summary, the sequence of operations can be described as follows. First, we determine $w_\tau$ by identifying the leaf node in which observation $t$ resides for a given tree. Within that leaf, we locate the corresponding in-sample observations and assign weights to them, calculated as $\sfrac{1}{\text{leaf size}}$. These weights are attributed to the relevant in-sample observations ($w_{b\tau}$). Finally, we aggregate these contributions across all trees in the ensemble.

By construction, the resulting $\hat{y}_t$ is a weighted average (i.e., ${w}_{\tau} \in \Delta$), as the elements of $\boldsymbol{w}_{t}$ are themselves averages of ${w}_{b\tau t}$, which are weighted average weights.

Illustrating RF's Adaptability with Synthetic Data

Our simulation example comprises three distinct scenarios: (i) abrupt change, (ii) gradual change, and (iii) a combination of both. In the abrupt change scenario, the response variable undergoes a sudden shift (from -1 to 1) at the midpoint of the time series, while the gradual change scenario features a continuous, smooth linear transition from one state to another (from -1 to 1). The combined scenario integrates both patterns, starting with an upward slope followed by a structural break. In each scenario, our data-generating process (DGP) includes normal white noise with mean 0 and standard deviation 0.5. A formal exposition is provided in Appendix (ref).

In the top panel of Figure (ref), we present the resulting time series observations with the AlbaMA overlay, derived from a Random Forest using 500 trees and a minimum node size of 40. In the bottom panel, we show predictions from four individual trees within the forest to illustrate whether herd behavior or dispersion prevails across our three scenarios.

figure[figure omitted — 1,336 chars of source]

In the abrupt change scenario, nearly all trees identify the significance of the split around observation 150. Indeed, when there is a clear regime shift in the data, all randomized trees recognize this split as a key feature. This is evident in the first column of Figure (ref), where all four trees excerpts capture the break. As a result, the Random Forest fit distinctly reflects the abrupt change.

In the gradual change scenario, there is no consensus on a specific split point because, in the true DGP, none exists. Instead, individual trees attempt to approximate a linear trend by introducing splits at various points, each creating a series of step functions to approximate a straight line.\footnote{In a noise-free setting, the ideal approximation would involve 300 steps, increasing monotonically from -1 to 1 in increments of $\frac{2}{300}$.} Bagging introduces significant diversity across the ensemble, as shown in the second column of Figure (ref), where split points across the four trees are scattered between observations 1 and 300. Despite this apparent lack of coordination, some collective wisdom emerges in the shape of a nearly straight line---thanks to Bagging reducing variance by smoothing hard-thresholding rules buhlmann2002analyzing.

figure[figure omitted — 1,003 chars of source]

The final case is the combined scenario, shown in the third column of Figure (ref). First, we observe strong tree consensus around the break date. Second, there is significant dispersion among trees in the linear run-up phase, resulting in a mostly straight line. Finally, while individual trees may display extreme changes in the second half of the sample, these idiosyncratic variations average out in AlbaMA, yielding a mostly flat line that aligns with the true DGP.

Figure (ref) illustrates the importance of lagged (and, when applicable, leading) observations in AlbaMA, shown for both one-sided and two-sided configurations. RF’s flexibility in adjusting the weighting of the look-back window over time is evident, particularly around structural breaks. In the two-sided case, we observe a sharp increase in the importance of recent lags just before an abrupt change, while leading observation weights peak right after the break. This pattern reflects RF’s ability, in the two-sided case, to capture breaks by not mixing pre- and post-break data together when computing a moving average around the sudden shift date.

The one-sided configuration, shown in the lower panels, displays a similar tendency, with recent observations gaining weight around structural breaks before quickly reverting to a more inclusive average. In the gradual change scenario, as well as in smooth segments of other cases, the filter’s weighting occasionally responds to what is effectively noise in the DGP. With a sample of 300 observations, AlbaMA will inevitably miss on some opportunities for smoothing.

Lastly, as a reference point, we apply traditional time series filters on the combined DGP—standard moving averages, the SG adaptive moving average, $l_1$ trend filtering, and boosted HP filters (see Appendix (ref) for details). All of these filters, directly or indirectly, imply that $\hat{y}_t$ is a local average of $y_t$. In the combined scenario, however, none of these benchmarks match RF’s adaptability to rapid changes (see Figure (ref) in the appendix), even in a two-sided application. Standard moving averages demonstrate the challenging trade-off discussed in the introduction for the case of inflation, while the SG adaptive moving average introduces unnecessary peaks in the flat portion of the DGP. For standard time series filters, avoiding the artificial smoothing of structural breaks often introduces significant noise and artificial cycles, a tendency that is evident in both the gradual change sections and the flat portions of the DGP. This arises from tuning parameters that work well for abrupt changes being unsuitable for smoother segments, and vice versa.

Empirical Application

We apply AlbaMA to a broad set of macroeconomic variables for the US and the Euro Area (EA). These include CPI/HICP headline and core inflation, industrial production, unemployment and the Purchasing Managers Index (PMI) on a monthly frequency.\footnote{For the US, the series are taken from FRED and span the periods 1963m1 to 2024m9 for industrial production and CPI inflation, and 2024m10 for unemployment. The PMI is extracted from Macrobond with start date 1963m1 and end date 2024m10. Data for the EA is provided by Eurostat and ranges from 1997m1 to 2024m8 for industrial production, 2024m9 for unemployment, and 2024m10 for HICP inflation.} We compare AlbaMA's solution to three-, six-, and twelve-months moving averages as well as the Savitzky–Golay filter for various historical time periods including tranquil times and periods of economic turmoil.

AlbaMA for Inflation Monitoring

In Figures (ref) and (ref), we present detailed results on AlbaMA for both US headline and core inflation. The time series panels illustrate a comparison among various moving average techniques, including AlbaMA, spanning from the early 2000s to the present. We focus closely on two key periods: (a) the Great Recession, and (b) the recent inflation surge beginning in 2021. Finally, we offer insights into the time-variation of the weighted average by reporting the weights AlbaMA assigns to recent observations for each $\hat{y}_t$.

\vskip 0.15cm { \sc Headline Inflation.} The upper panel of Figure (ref) contrasts AlbaMA’s readings with the widely-used twelve-months moving average of headline inflation. Notably, the RF-based solution is more responsive and exhibits greater volatility than the year-over-year (YoY) rate, particularly in the face of significant economic shocks. One illustrative episode is the sharp decline in 2008. MA(12) lags in responding to both the steep drop and subsequent mean reversion. It also shows pronounced base effects once the extreme November 2008 value falls out of its look-back window. In contrast, AlbaMA swiftly captures the downturn \textcolor{black}{from 3.2% in September 2008 to -11.3% in December} and quickly returns to pre-crisis levels by summer 2009, underscoring the transitory nature of the dip. Interestingly, while MA(12) indicates a significant inflation increase in late 2009, AlbaMA reveals that this uptick actually began six months earlier and, if anything, was already trending downward by that time.

figure[figure omitted — 2,643 chars of source]

During the post-pandemic inflation surge, we observe a strong and steady upward trend in AlbaMA, with its inflation readings consistently exceeding those of MA(12) and the SG filter. AlbaMA peaks at 11.2% in June 2022, before dropping to below 4% within the following two months. In contrast, the commonly used MA(12) shows a more gradual and persistent slowdown, taking until June 2023 to converge to the values of short-run measures. \textcolor{black}{As shown in the lower right panel of Figure (ref), $y_{t-1:t-5}$ account for half the weight in capturing the persistent upward trend. At the critical juncture, the role of longer lags shrinks significantly as the weight assigned to $y_t$, the most recent observation, doubles -- from 19% in May 2022 to 41% in July 2022. }

In comparing AlbaMA to additional benchmarks (see middle panels of Figure (ref)), we observe similarities with the MA(3) and the SG filter around inflection points. However, the SG filter fails to capture the upward trend during the post-Covid inflation surge, whereas AlbaMA aligns more closely with the MA(6) in these trending periods.

This alignment can be examined more rigorously by analyzing the time-varying weights that the RF model assigns to past observations (see lower panels of Figure (ref)). On average, AlbaMA assigns substantial weight—approximately 90%—to the last five months, suggesting a general preference for the MA(3) and MA(6) benchmarks. Around key inflection points, such as the 2008 oil shock, the initial Covid shock, and the post-pandemic slowdown, the weight on recent data sharply increases. In its “steady-state,” the weight on the last three to end-of-sample observations ($y_{t-3:t-\text{end}}$) hovers around 40%, but it drops to less than 20% during these periods, with the difference reallocated to $y_t$ or $y_{t-1:t-3}$. As discussed in the literature, high volatility may lead to faster price adjustments, highlighting the benefits of measures that are more responsive to recent observations hall2023major,eeckhout2023instantaneous.

The two-sided version, displayed in Figure (ref) in the appendix, reinforces our conclusions on AlbaMA’s responsiveness. As one should expect, standard moving averages symmetrically smooth $y_t$ using both past and future data, thereby shifting turning points forward. AlbaMA behaves differently. It initially downweights future observations before a breakpoint, upweights them after it, and eventually reassigns weights to both sides after the dust has settled. Consequently, the one-sided assessment of AlbaMA closely aligns with its two-sided counterpart—a consistency infrequently seen among time series filters orphanides2002unreliability. This consistency is further examined in Section (ref), where we quantify, for AlbaMA and various benchmarks, the average correspondence between one-sided and two-sided estimates across a broader set of series.

\vskip 0.15cm { \sc Core Inflation.} It is evident that oil price volatility contributes significantly to the adaptive behavior observed in AlbaMA for headline inflation. This raises the question of whether similar gains from adaptive moving averages can be achieved for inflation measures that exclude oil prices. The answer is yes. In fact, we find more significant adaptive behavior when applying AlbaMA to US core inflation. We observe a close alignment between MA(12) and AlbaMA during stable periods (see upper panel in Figure (ref)). This alignment is markedly disrupted, however, during the Great Recession and the post-Covid inflation surge. In these instances, the RF-based AlbaMA swiftly detects structural breaks, whereas the MA(12) responds sluggishly, smoothing out much of the impact. Notably, AlbaMA surges in April 2021, maintaining elevated levels that later converge with the MA(12).

Among other benchmark measures (see middle panel of Figure (ref)), only the MA(3) matches AlbaMA’s timeliness at inflection points. While the SG filter accurately captures short-lived downturns, such as those at the end of 2009 and in 2020, it significantly underestimates inflation trends in other periods. Longer moving averages effectively track the high-inflation period in 2022 and 2023 but are slow to capture its onset.

figure[figure omitted — 2,649 chars of source]

Examining the bottom panel of Figure (ref), we observe more pronounced swings in weights than those seen for headline inflation. This is attributable to AlbaMA assigning during stable periods a substantial portion of its weight to distant lags, with approximately 70% of weights allocated to \(y_{t-3:t-\text{end}}\). This share is found to be significantly smaller in the headline inflation application. In quieter times, such as throughout 2019, AlbaMA's core inflation weight distribution closely resembles that of an equally weighted MA(12), where \(y_t\) holds about \(\sfrac{1}{12}\) of the weight, and \(y_{t-6:t-\text{end}}\) holds around \(\sfrac{6}{12}\).

AlbaMA's adaptability lies in its swift departure from the MA(12) baseline by upweighting short lags after significant shocks, before eventually reverting to a near MA(12) distribution. For instance, following the initial Covid shock, the weight on \(y_t\) triples, while the weight on \(y_{t-6:t-\text{end}}\) drops from 51% in 2019m12 to 5% in 2020m8. Simultaneously, \(y_{t-1:t-2}\) gains importance at the expense of \(y_{t-3:t-5}\). A similar adjustment occurs in the spring of 2021, once again transforming the effective weight distribution from an MA(12) to an MA(3). As noted in stock2007has, the focus on recent observations intensifies during periods dominated by transitory shocks but shifts toward distant lags when the variance of permanent shocks increases. The high persistence following the post-Covid surge reflects this, with over 50% weights assigned to lags 6 and beyond, considerably slowing the disinflation process.

These findings are closely mirrored by those from the two-sided analysis presented in Figure (ref) (Appendix). Once again, AlbaMA generally aligns with the MA(12), except around the abrupt shifts occurring in October 2009 and April 2021. In both instances, AlbaMA continues to detect high persistence in the aftermath of those, consistent with the one-sided results. As desired, in the two-sided case, AlbaMA assigns greater weight to recent past observations just before the break and to more distant future observations immediately after.

figure[figure omitted — 1,692 chars of source]

\vskip 0.15cm { \sc Further Comparison: UC-SV and Exponential MA.} As additional benchmarks, we compare AlbaMA to the UC-SV model of stock2007has and an exponential moving average with a twelve-month smoothing parameter (EMA). Both models share key characteristics with AlbaMA and have been widely employed in inflation analysis. The UC-SV model decomposes inflation into trend and cyclical components, allowing the variances of their respective shocks to evolve stochastically over time. This enables the model to dynamically adjust the weighting of recent versus past observations in response to changes in volatility. In contrast, EMA imposes a fixed exponential decay structure, progressively diminishing the influence of older observations in a predetermined manner. While EMA lacks the adaptivity of UC-SV, it shares with AlbaMA the ability to upweight recent observations more sharply than a standard moving average.

As shown in Figure (ref), the series align closely up to the onset of the Covid-19 pandemic.\footnote{A full-sample comparison is available in Figures (ref) and (ref) in the appendix.} Notably, UC-SV and AlbaMA track similar paths for both headline and core inflation up to the Covid-19 shock. The primary divergence occurs around inflection points, where AlbaMA identifies abrupt shifts that the benchmarks smooth over. For headline inflation, all models capture the initial surge with comparable magnitude and speed, but UC-SV and EMA exhibit a gradual decline afterward, contrasting with AlbaMA’s abrupt downward adjustment in early 2022. For core inflation, the pattern reverses: while all models agree on a protracted disinflation process over the past three years, AlbaMA captures a sharper spike during the surge in 2021, diverging from the benchmarks’ more gradual upward trajectory.

A Look at Additional Series

In this subsection, we present selected results for additional macroeconomic variables, focusing specifically on the Great Recession and the post-Covid inflation surge to illustrate AlbaMA’s adaptability in these contexts. We include inflation series for the Euro Area, along with real activity data for both the Euro Area and the US (see Figure (ref)). Complete panels, analogous to Figures (ref) and (ref), are provided in Appendix (ref).

\vskip 0.15cm { \sc EA Inflation Series.} In all cases, AlbaMA demonstrates the adaptability highlighted in previous sections, responding promptly to economic inflection points by placing greater weight on recent observations. This behavior is especially evident in the inflation data for the Euro Area during the Great Recession. \textcolor{black}{In July 2008, AlbaMA captures a rapid deceleration in inflation from 4.8% to 1.9%, marked by strong contributions from recent data points, with $y_t$ almost trippling its weight from 13% to 33%.} Unlike the US, where AlbaMA indicated a brief downturn, inflation in the Euro Area shows a slower rebound, similar to an MA(12), driven by the increasing significance of distant lags.

A comparable pattern emerges in AlbaMA’s estimates for Euro Area core inflation during the post-Covid inflation surge. Initially, it rises in line with the MA(3) and transitions into a sustained upward trend until April 2023, resembling the MA(12). Following the peak, AlbaMA captures a relatively rapid disinflation (in contrast to the US), with heightened weight on recent observations beginning in mid-2023. Regarding consistency with the two-sided estimates, the use of both past and future data results in minor forward revisions within the Euro Area inflation subsample, although we note that the adjustments are more pronounced in the top panel.

\newgeometry{left=2 cm, right= 2 cm, top=2.1 cm, bottom=2.3 cm}

figure[figure omitted — 3,647 chars of source]

\restoregeometry

\vskip 0.15cm { \sc Real Activity Series.} Other series, beyond inflation, are often expressed in year-over-year growth rates. This is the case of US PMI and Euro Area industrial production, shown in panels (c) and (d) of Figure (ref). These real activity examples emphasize the delayed response of the MA(12) in signaling disruptions. For example, AlbaMA captures a sharp decline in US PMI, reaching -11% in October 2008, followed by a rapid recovery peaking in August 2009. In contrast, the MA(12) registers only a modest contraction (bottoming out at -3.1% in December 2009) with a delayed recovery that peaks in early 2010. AlbaMA’s more responsive assessment of PMI stems from (i) assigning higher steady-state weight to recent observations and (ii) doubling the weight on $y_t$ in the fall of 2008.

Similarly, in the Euro Area, the MA(12) lags both the decline and subsequent recovery in industrial production, whereas AlbaMA more closely tracks the MA(3), as evidenced by approximately 60% of the weighting assigned to the most recent three months. In both cases, the timeliness of AlbaMA is corroborated by its two-sided counterpart, which consistently captures the slowdown and only marginally accelerates the recovery indication.

A More Formal Evaluation of One-Sided vs Two-Sided Consistency

We complement our qualitative assessment with a more systematic examination of the consistency between one-sided and two-sided results. One-sided moving averages and time series filters can experience substantial revisions as new data arrives, even without the data itself being revised. Consequently, real-time estimates may diverge from ex-post optimal two-sided estimates, which incorporate both past and future data points. This issue is known under various names, such as the "boundary problem” in kernel-based approaches and the “filter vs smoother problem” in filtering applications. Thus, it is pertinent to assess how well the ex-post optimal two-sided AlbaMA estimates align with its feasible one-sided counterpart, and to compare AlbaMA’s "performance" with that of traditional moving averages in this context.

figure[figure omitted — 1,486 chars of source]

We use $R^2$ between one-sided and two-sided estimates to assess each MA intertemporal consistency, treating the one-sided estimate as the “prediction” and the two-sided version as the realized value. The choice of $R^2$ over alternatives, such as root mean squared error, reflects the need to account for differences in target series variance; for instance, the variance of MA(12) is inherently lower than that of MA(3). Because the coefficient on the one-sided MA is fixed at 1 and the intercept at 0, meaning they are not estimated, $R^2$ values can sometimes fall below zero indicating that the prediction performs worse than the full-sample average. However, the maximal value for this $R^2$ remains 1.

Figure (ref) displays boxplots for each model and evaluation sample, summarizing performance across nine variables. These include the six previously analyzed variables and three additional ones: US and Euro Area unemployment rate, and US industrial production. Detailed panels for these additional variables are available in Figures (ref) to (ref). Note that the highest-ranked $R^2$ boxplot indicates the best overall model performance across all variables, though it does not imply top performance for each individual variable. For a detailed evaluation, please refer to Tables (ref) and (ref) in the appendix.

\textcolor{black}{Overall, AlbaMA performs well across all three evaluation samples, achieving the highest median $R^2$ in each test set: 0.81 for the full sample excluding Covid, 0.78 for post-1990, and 0.75 for post-2020. Moreover, the interquantile range is notably narrow, with the 25$^{th}$ quantile remaining at 0.64 (for post-2020) or higher (0.65 for post-1990 and 0.7 for the full sample excluding Covid). While benchmarks such as MA(3) and MA(6) vs (3) come in close seconds for the full sample excluding Covid, they fall short for the post-1990 and post-2020 samples. Overall, Figure (ref) illustrates that AlbaMA offers higher consistency levels that are robust to the choice of target and evaluation sample, as evidenced by the limited dispersion within and across boxes.}

A closer analysis (see Tables (ref) and (ref)) reveals that standard moving averages are challenging benchmarks for inflation data, which tend to change gradually with the overall price level. For real activity variables, the SG filter provides competitive consistency, followed by shorter-run moving averages, as real activity often exhibits sharper fluctuations that benefit from more responsive measures. AlbaMA adapts effectively to both types of dynamics, consistently ranking among the top performers based on the one-sided to two-sided $R^2$ criterion.

Conclusion

This paper introduced a simple adaptive moving average estimator tailored for macroeconomic monitoring, addressing the challenge of balancing timeliness and stability in tracking noisy series like inflation. By dynamically adjusting the look-back window, our Random Forest-based approach offers a flexible alternative to fixed moving averages. Comparisons with traditional filters reveal that this adaptive method provides unique insights, particularly in capturing shifts such as the 2022 inflation surge and subsequent slowdown in the US and Euro Area.

There are a few avenues for future research. Here are two of them leveraging MRFjae's more sophisticated Macro Random Forest (MRF) algorithm. First, by moving beyond the straightforward moving average interpretation of Random Forest towards a more general time series filter approach, one could implement MRF with a trend as the linear component. This setup would address some of plain RF’s finite-sample limitations in capturing smooth changes.

A second option would be to incorporate $y_t$ and its lags into the MRF’s linear component, and enforce a sum-to-one constraint on the time-varying coefficients at each point in time. Leveraging large datasets such as FRED-MD mccrackenng could enable generalized, time-varying MA weights influenced by external variables. The resulting moving average could adapt as a function of economic fundamentals and potentially exhibit forward-looking behavior in its choice of weights.

\setlength\bibsep{5pt}

\setstretch{0.75}