Abstract
The application of the Hodrick-Prescott (HP) and other linear filters to remove trend and extract business cycles in macroeconomic time series is a common practice despite its limitations, namely, in signaling recessions. Median filters and other nonlinear techniques can perform better by accommodating sharp but fundamental changes in the growth trend and passing only the relevant information to the cycle component, a possible measure of the output gap of an economy. An application to the Portuguese relevant macroeconomic series confirmed the robustness of nonlinear filters in signaling the recessions and recoveries. In particular, the Mosheiov-Raveh (MR) filter estimates piecewise trend growth paths that naturally date the specific periods of the Portuguese economy since 1977.
Similar content being viewed by others
Avoid common mistakes on your manuscript.
1 Introduction
Many economic time series like GDP increase steadily over time. A simple way to describe such upward trends is to consider a linear model of the data \(y_t\) on a deterministic time trend plus a noise component (Enders 1995; Greene 2003; Hamilton 1994):
Processes with such representation are typically described as trend stationary, in the sense that if one subtracts the trend \(\alpha + \delta t\) from (1), the result is a stationary process, that is, whose mean and autocovariances do not depend on the date t. However, this regression technique may not be appropriate to detrend series whose growth component is time varying, depends on other endogenous or exogenous conditions, or is stochastic. In fact, macroeconomic time series are frequently represented by the random walk plus drift model, a special case of unit root processes:
Given the initial condition \(y_0\), the general solution for this difference equation is (Enders 1995):
Thus, detrending a process such (2) is not sufficient to eliminate the stochastic trend \(\sum \varepsilon _t\) where each shock \(\varepsilon _i\) with \(i \le t\) has a permanent effect on the mean of \(y_t\). Nevertheless, its representation in first-differences:
where L is the lag operator, is stationary. Thus, the random walk with drift is an example of a difference stationary model that can be transformed into a stationary process by differencing (Enders 1995).
Detrending and differencing are popular practices in macroeconometrics because the autoregressive moving average (ARMA) framework is applicable only to stationary time series. However, both practices have several drawbacks. On one hand, the linear model (1) assumes that trend is unchanging over time with a secular growth rate \(\delta\) that could not accommodate technological, demographic or other fundamental shocks that might occur overtime. On the other hand, the first-difference filter (4) removes the zero (long-run) frequency and accentuates the high-frequencies in the data \(y_t\), producing a noisier stationary component \(\varepsilon _t\) (Cooley and Prescott 1995; Hamilton 1994).
In practice, detrending and differencing may not be adequate to describe the business cycle, that is, the more or less regular pattern of expansion and contraction in economic activity around the path of trend growth that is observed in most macroeconomic series. In fact, business cycles can vary widely across methods that extract different types of information from data (Canova 1998). Ideally, the business cycles should depict the deviations from a long-term trend using, namely, a stylised circular clock (Lourenço and Rua 2022). Given a seasonally adjusted time series \(y_t\), the business cyclical component \(c_t\) can be defined as
where \(x_t\) and \(\epsilon _t\) are the trend (low-frequency) and irregular (high-frequency) components of \(y_t\), respectively. Thus, the cycle \(c_t\) should capture the medium-frequencies with periods lasting no fewer than six and no more than thirty-two quarters as defined by the National Bureau of Economic Research (NBER) researchers (St-Amant and van Norden 1997).
The trend is generally seen as a slow movement over time that could be extracted with appropriate filtering techniques. Ideally, they should capture not only the deterministic but also the stochastic dimension of the growth as described. In several cases, filtering consists in applying a smooth operator M to a moving-centred window of the data with length \(l = 2k + 1\) in order to estimate the trend component
Linear and nonlinear techniques can be mobilised to perform this task. Moving Average (MA), that is, using the arithmetic mean as smooth operator in equation (6) is a simple way to do it:
This is an example of a Linear Time-Invariant (LTI) low-pass filter which does not affect low frequencies, rejects high-frequencies and avoid phase shifts through its symmetry (Smith 2011). Setting \(k = 15\), the MA filter can be used to block business cycles with length up to \(l=31\) quarters in coherence with the NBER definition. And it can be applied once again to the residual \(\tilde{\varepsilon }_t = y_t - \tilde{x}_t\) to separate the pure cycle component \(c_t\) from the high-frequencies \(\epsilon _{t}\) by fixing \(k=2\) (window length of 5 quarters) as in the decomposition (5), even when the trend \(x_t\) was estimated with other techniques including the linear time trend regression (1).
A special case of moving average and linear filtering is the widely used Hodrick and Prescott (1997) filter (HP). In this method, the trend sequence \(\{x_t\}\) is chosen to minimise either the sum of the squares of deviations from data series \(\{y_t\}\) plus the weighted sum of the squares of the trend’s second difference, a possible measure of its smoothness.
In a recent critique, Hamilton (2017) stressed that the HP filter produces extremely predictable cyclical components whose rich dynamics are purely artefacts created by the filter rather than reflecting any true dynamics of the data-generating process itself, following an argument similar to Harvey and Jaeger (1993) that found that the HP filter may create spurious cycles and cross-correlations between different variables. In fact, when applied to persistent data, the HP filter can generate business cycle dynamics even if none are present in the original data (Cogley and Nason 1995; Cogley 2001). This is a common feature of linear filters including the symmetric Baxter and King (1999) and asymmetric Christiano and Fitzgerald (1999) band-pass filters which tend to eliminate large fluctuations either in expansions or contractions (Wen and Zeng 1999). Thus, linear filters produce smooth trends that might not capture fundamental sharp changes in the growth component of the time series under study. This problem is particularly acute with the HP method because it produces a trend with a very regular, predictable, pattern and passes everything else to the cyclical component, including high-frequencies.
As suggested by Wen and Zeng (1999), nonlinear filters could perform better than linear filters in capturing occasional, discrete shifts in the growth dynamics of economic series. In particular, the Median (MED) filter provides a simple noise attenuation with robustness against impulsive-type noise and it has proved to be effective in signalling recessions. However, it produces a very noisy trend that might fail the test of either smoothness or persistence. The alternative metric for the HP minimisation problem proposed by Mosheiov and Raveh (MR) (1997) could deal with this problem, producing a suggestive piecewise trend. A similar result can be obtained by applying the \(\ell_1\) trend filter proposed by Kim et al. (2009).
We start by describing those different filtering techniques (MED, HP and MR). Then, we compare the different insights in describing the business cycles of the Portuguese economy since 1977. One conclusion of our analysis is that the trend and the cyclical components are both informative about economic conditions. As framework, we dated the Portuguese contractions (recessions) and expansions (recoveries) by applying the Bry and Boschan (1971) algorithm to GDP, private consumption, investment and employment (see Appendix 2).
In this paper, we do not distinguish between trend GDP growth and potential GDP growth, nor between cyclical component and output gap.Footnote 1
2 Alternative filtering techniques
2.1 The Median (MED) filter
Linear filters implicitly assign all sharp changes in time series to shifts in non-fundamentals, assuming away the possibility that the growth trend can also experience sudden shifts or jumps. In fact, linear filters can only suppress undesired parts of the signal and retain the desired information about business cycles if and only if the noise and the signal occupy different frequency bands. In reality, however, signals reflecting sudden but fundamental changes could share the same frequency band with noise.
To deal with these limitation of linear filters, Wen and Zeng (1999) introduced a class of nonlinear filters, called the median filters, that has been proven useful and powerful for removing time trend and noise in several contexts. To compute the output of the Median (MED) filter, an odd number of sample values are sorted, and the middle or median value is used as the trend component \(x_t\). In practice, the MED filter adopted the median X as smooth operator M in equation (6):
for \(t = 1, \dots , N\) and \(k = 15\) with quarterly data. To be able to filter also the outermost observations, where the filter window partially fall outside the input signal, those authors replicated the \(y_1\) and \(y_N\) values as many times as needed, the so-called “first and last values carry-on appending strategy” (Wen and Zeng 1999).
The MED output has good deterministic and statistical properties. Namely, it is optimal in the mean absolute error sense because the median of \(y_1, \dots , y_N\) can be defined as the value \(\beta\) minimising the following expression when \(\gamma = 1\)
In fact, the sample median is the maximum likelihood estimate for the location parameter of the Laplace probability distribution (Wen and Zeng 1999).
Wen and Zeng (1999) compared the MED with the HP, BK and MA filters and concluded that the MED cycle \(\hat{c}_t \equiv y_t - \hat{x}_t\) for GDP coincides almost exactly with the NBER dated recessions for the United States of America, while the linear filters are too noisy outside contraction periods. This result indicates that linear filters are not efficient in retaining the growth component of GDP in terms of effectively capturing sharp changes in growth trend. Those authors also stressed that the HP and MA filters generate very similar trend paths which could be explained by the moving average representation of the HP filter, as described below.
2.2 The Hodrick-Prescott (HP) filter
Let denote \(y=(y_1,y_2,\dots ,y_N)\) as the \((N \times 1)\) vector of the seasonally adjusted time series \(y_t\). The Hodrick-Prescott (HP) trend \(x^* = (x_1,x_2,\dots ,x_N)\) is chosen to minimise the sum of the square residuals \(\varepsilon _t=y_t-x_t\) plus the weighted smoothness of the trend component
where \(\lambda > 0\) is a penalty for the square of the difference of the trend growth \(g_t \equiv x_t - x_{t-1}\), which is the second difference (acceleration) of the trend component \(x_t\). Thus, the larger the value of \(\lambda\), the smoother will be the HP trend. In particular, as \(\lambda\) approaches infinity, the limit of solutions to program (10) is the least squares fit of the linear time trend model (1). If the residual \(\varepsilon _t\) and the difference \(g_t - g_{t-1}\) are uncorrelated white noise processes with means zero and variances \(\sigma _{\varepsilon }^2\) and \(\sigma _g^2\), then the conditional expectation of \(x_t\) on data \(y_t\) would be the solution to program (10) when \(\lambda = \sigma _{\varepsilon }^2 / \sigma _g^2\) (Dermoune et al. 2009; Hamilton 2017; Hodrick and Prescott 1997). The view of Hodrick and Prescott (Hodrick and Prescott 1997) is that a 5 percent cyclical component is moderately large, as is a one-eighth of 1 percent change in the growth rate in a quarter. This assumption led them to select \(\sqrt{\lambda } = 5/(1/8) = 40\) or \(\lambda = 1600\) as the value for the filter’s smoothing parameter in order to extract business cycles from quarterly data.
It is convenient to express the problem (10) in matrix form
where \(D \in \mathbb {R}^{(N-2) \times N}\) is an upper triangular Toeplitz matrix with first row \([1 \, -2 \, 1 \, 0 \, \cdots \, 0]\). As noted by Kim et al. (2009), this objective function is strictly convex in x, thus has a unique minimiser
From the optimality condition \(y - x^* = \lambda D^T D x^*\), we could obtain the optimal fitting error, that is, the cyclical component of the HP filter
From the first order condition (12), the HP trend estimate is simply a moving average of the original unfiltered data y whose weights change as we move from the mid-sample to the end (or the begin) of the sample, as stressed by St-Amant and van Norden (1997).
The HP filter is an example of an heuristic two-part decomposition of time series that could be represented by a high-pass transfer function. As found by King and Rebelo (1993), the transfer function of the cycle component (13) is given by
where the frequency \(\omega\) measures the number of cycles completed during \(2\pi\) periods which is unity for the cosine function. The HP transfer function is also the gain of the filter because it assumes only real (non imaginary) values. This result is a direct consequence of the symmetry of the HP filter and from Euler equations (see also Hamilton 1994). Thus, the HP filter is similar to a high-pass filter where choosing different values for \(\lambda\) is comparable to fix different values for the cut-off point of the filter (Ravn and Uhlig 2002).
Solving in \(\lambda\) the equation (14) for a gain of 0.5 as suggested by Mohr (2005), we found that the critical frequency of \(\pi /20 = 2\pi /40 = 0.157\), which corresponds to a period of 40 quarters (10 years), requires a value of \(\lambda \approx 1600\) as proposed by Hodrick and Prescott (1997) to filter quarterly data. Moreover, for a gain of 0.7, the critical frequency associated with \(\lambda = 1600\) is approximately \(\pi /16\), the cut-off frequency of a filter that passes oscillations lasting 32 quarters (8 years) or less. Thus, the HP filter with \(\lambda = 1600\) high-passes business cycle frequencies with no more than thirty-two quarters as defined by NBER (St-Amant and van Norden 1997) for a reasonable gain of the filter. Nevertheless, the HP cyclical component may have residual seasonality and other high frequencies with period less than 6 quarters mixed with business cycle frequencies because the HP is not a band-pass filter. Applying the MA filter (7) with \(k=2\) (\(l=5\)) to the HP cycle (13) can mitigate this problem.
2.3 The Mosheiov-Raveh (MR) filter
As suggested above, the median filter output minimises the sum of the absolute values of the fitting residual \(\varepsilon _t = y_t - x_t\). Thus, the MED trend \(\hat{x_t}\) is well-fitted to the original time series \(y_t\) and it is always one of the input observations from (8). The fidelity or closeness to data is an important property of the trend but the smoothness should also be considered. So, we could imagine a generalised median filter which results from the following problem (Mosheiov and Raveh 1997):
where \(\alpha\) and \(1 - \alpha\) are the weights assigned by the user to fidelity and smoothness, respectively, with \(0 \le \alpha \le 1\). The choice of the parameter \(\alpha\) is somewhat arbitrary, but has a significant effect on the final trend estimate. From visual inspection, Mosheiov and Raveh (1997) chose only small values of \(\alpha\), namely, \(\alpha = 0.1\) in the sense that their natural preference for smoothness was more significant than fidelity.
Nevertheless, the trade-off between fidelity and smoothness can be fixed to assure the same fitting error is provided either by the HP or the MR filters, following the practice of Kim et al. (2009) in the scope of \(\ell _1\) trend filtering. To apply this criterion, it is convenient to rewrite the previous problem as
where \(\theta = (1 - \alpha ) / \alpha\) indicates how much the degree of smoothness is more important than fidelity. Then, we fix \(\theta\) such that the resulting MR trend \(x_t(\theta )\) provides a mean squared fitting error similar to the one provided by the HP trend \(x_t(\lambda )\), that is
The objective function (16) is a variation of the HP objective function (10) which substitutes the sum of squares, that is, the squared \(\ell _2\) Euclidean norm, for the sum of absolute values, the \(\ell _1\) norm, to measure either the fidelity or the smoothness of the trend \(x_t\).Footnote 2 Thus, the smoothing parameter \(\theta\) can be interpreted in a similar manner than the \(\lambda\) parameter, noting that, in the MR filter, the errors are measured in absolute terms while, in the HP filter, they are quadratic errors. Therefore, it would be expected that, for the same data set, the value of \(\theta\) should be close to the square root of \(\lambda\). The concept of business cycles in a developed economy is a mechanism that usually is considered to last between 6 and 10 years. In the context of the HP filter, \(\lambda = 1600\) is appropriate for quarterly data to separate the trend and cycle components in that time horizon, as said. Similarly, the MR filter with a \(\theta\) between 30 and 50 should obtain similar cycles.
The problem (16) can be solved through a linear programming framework. We propose an improvement to that method to allow non-positive trend growth, see Appendix 1 for details. Other methods are available, namely the interior point approach that uses a logarithmic barrier potential-function, widely applied to solve the least absolute deviation and quantile regression problems (Portnoy and Koenker 1997).
2.4 Filter properties
The reason for the popularity of the HP filter among practitioners rests on a few properties. First, it smooths the data. This property is common to all filters, except the linear filter that smooths the data too much. Second, it allows for an estimate of the trend growth. Once again, this is a common property to all statistical filters. Third, it provides an estimate of the cyclical position of an economy in every period. This property is also common to all filters, even though the linear filter accepts too large cyclical components, and the HP and the other filters may underestimate the cyclical component. This is one important advantage of nonlinear filters, providing a potentially better measure of the cyclical position, that is, the slack or overheating of the economy. Fourth, the key distinctive feature of the HP filter is that it allows trend growth to be different throughout the time line. In this perspective, the HP filter is the simplest statistical method that assumes time-varying growth. Moreover, it allows this growth to follow the data, even though in much smoother form than actual observed growth.
The MR filter shares this fitting property, in contrast with other statistical techniques that either force a constant trend growth, or model this growth as a function of other covariates, or even allowing it to vary according to predefined periods. Of course, some of the limitations of the HP filter are well known, especially its bias near the end of the sample period, which can severely affect the estimates of trend growth and cyclical component. This bias can be serious and therefore most researchers treat with great care the estimates of GDP trend growth and cyclical position near the end, usually the present, of the available data.
The most interesting feature of the MR filter when compared with the HP filter is that it provides a more robust estimate of the trend growth, only changing this estimate if the signal coming from the data is sufficiently strong. Thus, the MR filter could delay the recognition of a change in regime, but it would be robust in signalling a new trend once sufficient evidence is present in the data.
3 Findings
The above described statistical methods were applied to the quarterly real (chain linked) national accounts of GDP, private consumption, gross fixed capital formation (GFCF) and employment level provided by the Portuguese National Statistics Office (INE) since the first quarter of 1995 till the second quarter of 2023. This seasonally adjusted data was complemented with long-term series from Banco de Portugal (BdP) to produce a set of 186 observations since the first quarter of 1977. Moreover, a procedure described in Appendix 2 was used to date the Portuguese recessions by tracking the peaks and troughs in the various series.
The smoothing parameter \(\theta\) of the MR filter was fixed to assure that the fitting error is approximately equal to the one provided by the HP filter with \(\lambda = 1600\). For GDP, the main series of interest, this criterion provides a value of \(\theta\) of 42, quite close to 40, which is the square root of 1600 (see Table 1). We fix \(\theta = 42\) for all series, noting that the parameter \(\lambda = 1600\) of the HP filter was adopted in all cases too.
In Figs. 1 and 2, we show the trend component of GDP according to the five methods. The linear time model provides substantially different results from the other four. Notice how recessions, denoted by the shaded regions in the graphs, tend to slow down growth in all other four methods. Moreover, notice how the four methods, bar linear trend, show a declining trend GDP between 2008 and 2013.
In Figs. 3 and 4, we plot the trend GDP growth, which brings more or less cyclical patterns accordingly with the model. What is most striking, however, is that after 2000 the estimate of GDP growth never returned to the highest values observed around the previous peaks, even at the recovery after 2013. Moreover, trend GDP growth was smaller than the constant (0.47%) estimated by the linear model in almost all quarters, except for the HP filter at the end of sample. The private consumption, investment and employment follow similar patterns. It is striking that the general shape of alternation between trend growth levels is quite similar across statistical methods, except the constant linear model.
The behaviour of investment (GFCF) is worth an additional note. According to most models, investment trend growth was negative between 2001 and early 2014. Moreover, Fig. 5 shows how far is the fixed investment from the levels observed in 2001. This is a good measure for the severity of slowdown in investment observed for about 20 years (from 2002 to the present), a much extended period indeed.
An immediate approach is to interpret the different trend growth rates as different natural periods of the Portuguese economy. We do it in Table 2, which proved to be a complement of the recessions dated in the Appendix 2. While all filtering techniques (moving average, median filter, HP and MR) provide similar estimates for GDP trend growth that highlight different periods, the MR filter provides this dating in a very natural fashion. In fact, the MR filter appears to capture a broad pattern of strong growth periods followed by weak periods that can be interpreted as the change in pace during expansions and contractions. Thus, we identify eight distinctive periods for the evolution of the Portuguese economy since 1977.
The first period, ending in late 1980, represents a strong expansionary period (average growth of 1.1% per quarter, see Fig. 4). It was followed by a period of low growth (average growth of 0.3%) which ends in late 1985 and includes a short recession. The third period is again strongly expansionary (average quarterly growth of 1.2%) until late 1990. The fourth period, which includes a small recession at the beginning, has a low growth around 0.4%.
However, the remaining four periods show a very different switch of trend growth. The apparent strong growth in period 5 (1.0% per quarter) is moderate by historical standards, but is still the strongest of the following three periods. The sixth period (average growth of 0.2%) is unusually long (seven years), but it was not followed by a period of strong growth. In effect, trend GDP growth becomes negative in period 7 (\(-\)0.3% per quarter) and includes two recessions. So it can be classified as a period with a double dip recession. This is the period with the weakest growth of the Portuguese economic history after 1977.
The current period 8 started in late 2013 (average trend growth of 0.5%) which can be considered as a regular expansionary period, close to the secular average estimated by the linear model, but much weaker than the recoveries from the 1980s and 1990s. This period includes the recession generated by the COVID-19 pandemic and implemented lockdown policies in 2020Q1-Q2. The stability of the MR filter is evident, contrary to the HP filter that slowly changes the trend growth between contractions and expansions. From its ability to attenuate the impact of outliers and noise, the MR filter is particularly useful to deal with such volatility in the data.
These eight periods are visible on series other than GDP. For some series, two periods may be represented as a single period (e.g. the first and second periods for consumption and investment, see Table 2). Moreover, the exact beginning of the strong and the weak spots are not necessarily estimated to begin and end on the same quarter by all time series analysed. In particular, investment suggests that the period 8 might have ended at 2019, right before the COVID crisis. However, they tell the same story from a qualitative point of view.
This description of the results shows the power of the MR approach to identify natural periods of differential growth on the data series. These periods show up quite naturally, and the weak periods usually include one or two recessions. So, the MR filter can be used for that purpose. This type of classification is useful for policy since weak periods of growth should recommend fiscal stimulus and strong periods of growth should counsel additional debt repayments and savings.
One can argue that HP filter provides a similar story. However, the beginning and ending of the periods is less obvious (associated with the inflexion points in Figs. 4 and 6), and the HP trend growth must be averaged to characterise each period directly signalled by the MR filter.
The five methods might provide very different estimates of the trend GDP growth. Using the last quarter of the data, the range of this growth is between 0.19% for the MA filter and 0.66% for the HP filter. The MR filter is quite conservative due to its robust estimation properties: changes of its estimated trend growth require stronger signals from data than temporary discrete shocks or cyclical recovery. In fact, it signals a trend GDP growth of 0.50% since the third quarter of 2014, despite the COVID-19 crisis and its developments.
Note that the linear model generates an extremely different pattern for the cyclical component, because it assumes a constant trend growth of 0.47% (see Fig. 7). The other filters generate fairly similar cycles except near the begin and end points of the sample (Figs. 8 and 9).
A remarkable feature of the nonlinear filtering techniques is that they produce cycle components less volatile than the difference between the original data and the HP trend, a suggested by the Table 3. This result is particularly evident for the median filter and it is a direct consequence of the ability of nonlinear filters to capture sharp swifts in the trend growth. Thus, the cyclical components associated with nonlinear filters (including MR) are less contaminated with noise and changes other than pure cyclical effects. As illustrated by Fig. 8 for GDP, the cyclical components of the MED filter coincides almost exactly with the recessions dated in the Appendix 2 with the Bry and Boschan (1971) algorithm which is a direct consequence of that characteristic of nonlinear filtering in general. Nevertheless, the MR filter realises a cycle component that is more comparable with the HP cycle (Fig. 9) than MED cycle.
4 Conclusion
Assessing economic conditions overtime requires separating trend, cyclical and noise components from time series. This task is often model dependent. Simple detrending models assume a secular trend that is fixed over time, thus all shocks are described as cyclical or temporary within that kind of framework. However, technology, demography and other fundamentals will likely change trend growth overtime. So, the trend of an economy can be better described as a slow changing movement over time rather than a fixed drift. The Hodrick and Prescott (1997) filter is very popular in part because it can estimate that kind of non-constant but smooth trend growth, producing insightful business cycles.
However, the HP and other linear filtering techniques generate trends with regular and predictable patterns that pass everything else to the stationary component, including high-frequencies and shocks other than pure cyclical effects. In practice, they produce ‘artificial’ trend-cycle decompositions that might not reflect the underlying economic processes.
Robust nonlinear filters could perform better than linear filters in capturing discrete shifts in the trend growth of economic series. For example, the median filter provides noise-attenuation and it has been effective in signalling recessions. Nevertheless, its trend is noisy even when averaged across adjacent time periods. We found that the filter proposed by Mosheiov and Raveh (1997) keeps the robust statistical properties of the median filter, while generating stable trend growth estimates that lend themselves to insightful interpretations of the different time periods of an economy.
The distinctive feature of the MR filter is the piecewise nature of its trend growth. This unique characteristic might be useful to estimate the trend growth of the economy and to highlight natural periods of differential growth on the data series. Moreover, it allows for economic shocks to have direct and discrete impacts on the cyclical position as well as in the potential growth. In fact, the MR filter is conceptually similar to HP filter but uses robust statistics anchored on the median and absolutes deviations of the data. Thus, the MR filter provides a more robust estimate of trend growth, only changing this estimate if the signal coming from the data is sufficiently strong. Additionally, it may provide a better measure of the output gap and as such a measure of the slack or overheating of the economy.
We propose a criterion to fix the smoothing parameter of the MR filter based on the error estimated with the HP filter. We found that it should be close to 40, which is the square root of the HP smoothing parameter for quarterly data (1600). In addition, we propose a new method to estimate the MR filter using least absolute deviations (LAD), see Appendix 1 for details.
With the help of the MR filter, we found eight distinctive periods for the Portuguese economy between 1977 and 2023 that show up quite naturally. In general, strong and weak periods of growth are estimated directly from data. The weak periods might include one or two recessions for some variables such investment or employment. In particular, the sixth period (2000Q4-2008Q2) was unusually long, has a moderate average trend GDP growth of only 0.2% per quarter, and it was not followed by a period of strong growth yet. Despite the COVID-19 pandemic, we found that the potential growth of the Portuguese economy is still positive and close to 0.5% per quarter or 2.0% annualised.
Data availability
Data and code can be provided by request.
Notes
NECEP has specific methods to assess the output gap which is formally the difference between log GDP and log Potential GDP, but this paper is mainly focused on trend-cycle decomposition using statistical filters. In the present context, the cycle component can be seen as a possible measure of the output gap.
Kim et al. (2009) followed the same approach, but apply the \(\ell _1\) norm to measure the smoothness of the trend \(x_t\), maintaining the squared \(\ell _2\) norm of the fitting residual \(\varepsilon _t = y_t - x_t\).
This reduction technique was originally proposed by Charnes, Cooper and Fergunson (1955).
References
Assunção JB, Fernandes PA (2022) Robust filtering with quantile regression. NECEP Research Papers 2. https://clsbe.lisboa.ucp.pt/cea/necep. Accessed 1 May 2022
Baxter M, King RG (1999) Measuring business cycles: approximate band-pass filters for economic time series. Rev Econ Stat 81(4):575–593
Bry B, Boschan C (1971) Cyclical analysis of time series: selected procedures and computer programs. National Bureau of Economic Research, New York. https://www.nber.org/books-and-chapters/cyclical-analysis-time-series-selected-procedures-and-computer-programs. Accessed 30 Dec 2022
Canova F (1998) Detrending and business cycle facts. J Monet Econ 41:475–512. https://doi.org/10.1016/S0304-3932(98)00006-3
Charnes A, Cooper WW, Fergunson RO (1955) Optimal estimation of executive compensation by linear programming. Manage Sci 1:138–151
Christiano L, Fitzgerald T (1999) The band pass filter. NBER Working Papers 7257:1–73. https://doi.org/10.3386/w7257
Cogley T (2001) Alternative definitions of the business cycle and their implications for business cycle models: A reply to Torben Mark Pederson. J Econ Dyn Control 25(8):1103–1107. https://doi.org/10.1016/S0165-1889(99)00060-3
Cogley T, Nason JM (1995) Effects of the Hodrick-Prescott filter on trend and difference stationary time series: Implications for business research. J Econ Dyn Control 19(1–2):253–278. https://doi.org/10.1016/0165-1889(93)00781-X
Cooley TF, Prescott EC (1995) Economic growth and business cycles. In: Cooley TF (ed) Frontiers of business cycle research. Princeton University Press, Princeton, New Jersey, pp 1–38 (Chap. 1)
Dermoune A, Djehiche B, Rahmania N (2009) Multivariate extension of the Hodrick-Prescott Filter - optimality and characterization. Stud Nonlinear Dyn Econom 13(3):4. https://doi.org/10.2202/1558-3708.1656
Enders W (1995) Applied econometric time series. John Wiley and Sons, New York
Greene W.H. (2003) Econometric analysis, 5th edn. Prentice Hall, Upper Saddle River, New Jersey
Hamilton JD (1994) Time series analysis. Princeton University Press, Princeton, New Jersey
Hamilton JD (2017) Why you should never use the Hodrick-Prescott filter. NBER Working Papers 23429:1–47. https://doi.org/10.3386/w23429
Harvey AC, Jaeger A (1993) Detrending, stylized facts and the business cycle. J Appl Economet 8(3):231–247
Hodrick RJ, Prescott EC (1997) Postwar U.S. business cycles: an empirical investigation. J Money, Credit, Bank 29(1):1–16. https://doi.org/10.2307/2953682
Inklaar R (2003) Bry-Boschan algorithm for MatLab. University of Groningen
Kim S-J, Koh K, Boyd S, Gorinevsky D (2009) L1 trend filtering. Society for Industrial and Applied Mathematics (SIAM) Review 51(2):339–360. https://doi.org/10.1137/070690274
King RG, Rebelo ST (1993) Low frequency filtering and real business cycles. J Econ Dyn Control 17:207–231. https://doi.org/10.1016/S0165-1889(06)80010-2
Lourenço N, Rua A (2022) A circular business cycle clock for Portugal. Banco de Portugal Economic Studies 8(4):77–95
Mohr M (2005) A Trend-Cycle(-Season) Filter. ECB Working Paper Series 499:1–46. https://doi.org/10.2139/ssrn.726694
Mosheiov G, Raveh A (1997) On trend estimation of time-series: a simple linear programming approach. J Oper Res Soc 48:90–96. https://doi.org/10.2307/3009948
Portnoy S, Koenker R (1997) The Guassian hare and the Laplacian tortoise: computability of squared-error versus absolute-error estimators. Stat Sci 12(4):279–296. https://doi.org/10.1214/ss/1030037960
Ravn MO, Uhlig H (2002) Notes on adjusting the Hodrick-Prescott filter for the frequency of observations. Rev Econ Stat 84(2):371–380. https://doi.org/10.1162/003465302317411604
Reis R, Bação P, Correia IH, Valério N, Varejão J, Tavares J, Aguiar-Conraria L, Ferreira JA (2023) Crises na Economia Portuguesa. Fundação Francisco Manuel dos Santos, Lisboa. https://www.ffms.pt/pt-pt/estudos/crises-na-economia-portuguesa. Accessed 10 Nov 2023
Rua A (2016) Dating the Portuguese business cycle. Banco de Portugal Economic Studies 3(1):47–63
Smith III JO (2011) Spectral audio signal processing. W3K Publishing, Stanford, California, USA. https://ccrma.stanford.edu/~jos/sasp/. Accessed 7 Dec 2022
St-Amant P, van Norden S (1997) Measurement of the output gap: a discussion of recent research at the Bank of Canada. Bank of Canada Technical Report 79:1–75
Wen Y, Zeng B (1999) A simple nonlinear filter for economic time series analysis. Econ Lett 64:151–160. https://doi.org/10.1016/S0165-1765(99)00089-0
Acknowledgements
The authors wish to thank Carlos Rondão (CLSBE/UCP) for programming support and Isabel Horta Correia (CLSBE/UCP), João César das Neves (CLSBE/UCP), Miguel Gouveia (CLSBE/UCP) and Pedro Raposo (CLSBE/UCP) for insightful comments.
Funding
Open access funding provided by FCT|FCCN (b-on). This work was financed by Fundação para a Ciência e Tecnologia (FCT), Lisbon, Portugal under a post-doctoral grant with the reference CUBE-MACROECO-BPD4, a research project with reference PTDC/EGE-ECO/27884/2017 and a doctorate auxiliary researcher grant at Universidade Católica Portuguesa (UCP) - Católica Lisbon Research Unit in Business and Economics (CUBE) with the digital object identifier (DOI): https://doi.org/10.54499/CEECINST/00070/2021/CP1778/CT0008.
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendices
Appendix 1
1.1 The computation of the MR filter
To eliminate the absolute values in the objective function (16), Mosheiov and Raveh (1997) use a linear programming approach with an appropriate change of variableFootnote 3
The variables \(u_t\) and \(v_t\) have a very intuitive interpretation. They represent either a positive or a negative cyclical position, and therefore at least one of them has to be equal to zero. Similarly, the variables \(a_t\) and \(b_t\) represent a sort of regime change where the economy either accelerates to a higher trend growth level or decelerate to a lower one. Likewise, they cannot be both positive. It is this interesting characteristic of the optimal solution to the MR linear program that allows this model to reveal the natural growth periods present in the data.
The previous problem assumes monotonicity of the trend component \(x_t\). However, the Portuguese economy shows a significant number of time periods with negative trend growth throughout data series. Therefore, we adopted a different approach to compute the MR filter that uses least absolute deviations (LAD).
It is convenient to express the MR problem (16) in matrix form:
where \(\Vert w \Vert _1 = \sum _{i}{\vert w_i \vert }\) denotes the \(\ell _1\) norm of some vector \(w\) and \(D \in \mathbb {R}^{(N-2) \times N}\) is an upper triangular Toeplitz matrix with first row \([1 \, -2 \, 1 \, 0 \, \cdots \, 0]\) (Kim et al. 2009). Relaxing the monotonicity condition, the linear program of the MR filter can be expressed as
where \(\tilde{u}^T = [ u \vert b ]\), \(\tilde{v}^T = [ v \vert a ]\), \(Z^T = [I_N \vert \theta D]\) and \(\tilde{y}^T = [y\vert 0]\) with \(0\) as a vector of \(N-2\) zeros (Assunção and Fernandes 2022). Given this reformulation, the MR trend \(x\) corresponds simply to the estimated \(N\)-coefficients of the median regression of \(\tilde{y}\) on \(Z\) that solves the LAD problem:
In practice, the MR filter can be computed with median/quantile regression with an appropriate formulation of the problem, noting that the LAD problem can be solved with the described linear programming approach (Portnoy and Koenker 1997).
With this procedure, the MR filter produces sound estimates, including a possible negative trend growth. It also preserves the good properties of the MED filter with a trend estimate that is smooth in the sense of being piecewise linear (Kim et al. 2009). Finally, the MR filter does not use fixed weights or coefficients as HP or MA filters.
Appendix 2
1.1 Dating the Portuguese recessions
A recession may be defined as a significant decline in the level of economic activity, not confined to one sector but spread across the economy, usually visible in two or more consecutive quarters of negative growth of GDP, employment and other measures of aggregate economic activity. Thus, a recession starts right after the economy reaches a peak and deems to end when growth resumes in GDP and other key measures of economic activity, that is, after a trough, when starts the recovery till the next peak.
In most applications, peaks and troughs were tracked using the well-known Bry and Boschan (1971) dating algorithm that roughly identified the same business cycle reference dates of the National Bureau of Economic Research (NBER) for the United States of America. In this framework, a peak occurred in quarter t for a previously smoothed variable y if
Similarly, a trough occurred in quarter t if
For quarterly data, the minimum peak-to-trough (trough-to-peak) period is two quarters and peak-to-peak (trough-to-trough) is six quarters.
Here, we applied the MatLab implementation of the Bry and Boschan algorithm developed by Inklaar (2003) to the macroeconomic variables that the Euro Area Business Cycle Dating Committee from the Centre for Economic and Policy Research had used to fix those turning points for the euro-area: GDP (chain linked volumes), household and other private final consumption expenditure (chain linked volumes), investment (gross fixed capital formation - GFCF, chain linked volumes) and employment (number of persons).
A total of six peaks was dated for the Portuguese GDP since 1977Q1: 1983Q1, 1992Q2, 2002Q1, 2008Q1, 2010Q3 and 2019Q4 (see Table 4). In three of theses cases (2002Q1, 2008Q1 and 2019Q4), peaks were observed also in private consumption expenditure. Typically, investment peaks occurred before GDP local maxima such as in 1982Q1, 1992Q1, 2001Q4 and 2019Q1, suggesting that changes in GFCF could signal the turning points of the product with a lag of at least one quarter. The employment followed a less predictable pattern in the sense that peaks can happen either before (1982Q2, 1992Q1, 2019Q3) or after (2002Q2, 2008Q2) GDP high-levels.
Dating troughs is a tricky task because low-levels were more sparse within the variables of interest. For example, the 1993Q2 GDP trough was observed with one and two quarters of delay in employment and GFCF, respectively, and it was not tracked by the algorithm (Inklaar 2003) for private consumption. Thus, the process of dating a trough might be delayed in order to assure a broadly consistent end of recession. In most cases, the date of the GDP trough sounds well to fix that end, but this might not be true for 2012Q4 (see Table 5). In this severe recession, the trough was fixed with one quarter of delay (2013Q1) from GDP local minimum in order to accommodate the low-levels observed in the other variables subsequently. The pertinence of this delaying was confirmed by a dating exercise with the monthly coincident indicator for the Portuguese economic activity (Rua 2016), as well as by a recent study about the crises and recessions in Portugal (Reis et al. 2023). In fact, the recessions dated in Table 5 follow in almost all cases the peaks and throughs identified in that study.
Another interesting feature of the dating exercise described in the previous tables is that troughs are not observed around 2009Q1 for investment and employment. Thus, the recessions IV and V might be considered as an unique contraction episode that lasted between 2008Q2 and 2013Q1.
Finally, the recession motivated by the COVID-19 pandemic and lockdowns had an abnormal ‘through’ in 2020Q2, with an output loss close to 21% (see Table 5), followed by a sucession of rebounds and contractions of GDP, private consumption and investment.
Rights and permissions
This article is published under an open access license. Please check the 'Copyright Information' section either on this page or in the PDF for details of this license and what re-use is permitted. If your intended use exceeds what is permitted by the license or if you are unable to locate the licence and re-use information, please contact the Rights and Permissions team.
About this article
Cite this article
Assunção, J.B., Fernandes, P.A. A robust method to date recessions and compute output gaps: the Portuguese case. Port Econ J (2024). https://doi.org/10.1007/s10258-024-00259-4
Received:
Accepted:
Published:
DOI: https://doi.org/10.1007/s10258-024-00259-4