Authors and guest post by Benjamin Wong (Monash University) and Davaajargal Luvsannyam (The Bank of Mongolia)
Analysis of macroeconomic time series often involves decomposing a series into a trend and cycle components. In this
blog post, we describe the Kamber, Morley, and Wong (2018) BeveridgeNelson (BN) filter and the associated EViews
addin.
Table of Contents
 Introduction
 The BN Decomposition
 The BN Filter
 Why Use the BN Filter
 BN Filter Implementation
 Conclusion
 Files
 References
Introduction
In this blog entry, we will discuss the BeveridgeNelson (BN) filter  the Kamber, Morley, and Wong (2018)
modification of the wellknown Beveridge and Nelson (1981) decomposition. In particular, we will discuss
the application of both procedures to estimating the output gap, which the US Bureau of Economic
Analysis (BEA) and the Congressional Budget Office (CBO) define as the proportional deviation of the real
actual gross domestic product (GDP) from the real potential GDP.
The analysis to follow will use quarterly data from the post World War II period 1947Q1 to 2019Q3 and will be
downloaded from the FRED database. In this regard, we begin by creating a new quarterly workfile as follows:
 From the main EViews window, click on File/New/Workfile....
 Under Frequency select Quarterly.
 Set the Start date to 1947Q1 and the set the End date to 2019Q3
 Hit OK.
Next, we fetch the GDP data as follows:
 From the main EViews window, click on File/Open/Database....
 From the Database/File Type dropdown, select FRED Database.
 Hit OK.
 From the FRED database window, click on the Browse button.
 Next, click on All Series Search and in the Search for box,type GDPC1. (This is the
real actual seasonally adjusted GDP)
 Drag the series over to the workfile to make it available for analysis.
 Again, in the Search for box, type GDPPOT. (This is the real potential seasonally unadjusted
GDP estimated by the CBO)
 Drag the series over to the workfile to make it available for analysis.
 Close the FRED windows as they are no longer needed.


Figure 1a: FRED Browse

Figure 1b: FRED Search

Next, rename the series GDPC1 to GDP by issuing the following command:
rename gdpc1 gdp
We now show how to obtain the implied estimate of the output gap from the CBO to provide the user
some perspective on how to obtain the output gap. In particular, the CBO implied estimate of the
output gap is defined using the formula:
$$ CBOGAP = 100\left(\frac{GDP  GDPPOT}{GDPPOT}\right) $$
For reference, we will create this series in EViews and call it CBOGAP. This is done by
issuing the following command:
series cbogap = 100*(gdpgdppot)/gdppot
We also plot CBOGAP below:

Figure 2: CBO implied estimate of the output gap

BN Decomposition
Recall here that for any time series $ y_{t} $, the BN decomposition determines a trend process $ \tau_{t} $
and a cycle process $ c_{t} $, such that $ y_{t} = \tau_{t} + c_{t} $. In this regard, the trend component
$ \tau_{t} $ is the deviation of the longhorizon conditional forecast of $ y_{t} $ from its deterministic drift
$ \mu $. In other words:
$$ \tau_{t} = \lim_{h\rightarrow \infty} E_{t}\left(y_{t+h}  h\mu\right) \quad \text{where} \quad \mu = E(\Delta
y_{t}) $$
On the other hand, the cyclical component is the deviation of the underlying process from its longhorizon forecast.
Intuitively, when $ y_{t} $ represents the GDP of some economy, the cycle process $ c_{t} = y_{t}  \tau_{t}$ is
interpreted as the output gap.
In practice, in order to capture the autocovariance structure of $ \Delta y_{t} $, the BN decomposition starts by
first fitting an autoregressive movingaverage (ARMA) model to $ \Delta(y) $ and then proceeds to derive $ \tau_{t}
$ and $ c_{t} $. For instance, when the model of choice is AR(1), the BN decomposition derives from the following
steps:
 Fit an AR(1) model to $ \Delta y_{t} $:
$$ \Delta y_{t} = \widehat{\alpha} + \widehat{\phi}\Delta y_{t1} + \widehat{\epsilon}_{t} $$
 Estimate the deterministic drift as the unconditional mean process:
$$ \widehat{\mu} = \frac{\widehat{\alpha}}{1  \widehat{\phi}} $$
 Estimate the BN trend process:
$$ \widehat{\tau}_{t} = \left(y_{t} + \left(\frac{\widehat{\phi}}{1  \widehat{\phi}}\right) \Delta
y_{t}\right)  \left(\frac{\widehat{\phi}}{1  \widehat{\phi}}\right) \widehat{\mu}$$
 Estimate the BN cycle component:
$$ \widehat{c}_{t} = y_{t}  \widehat{\tau}_{t} $$
As an illustrative example, consider the BN decomposition of US quarterly real GDP. To conform with the
Kamber, Morley, and Wong (2018) paper, we will also transform the raw US real GDP as 100 times its logarithm.
In this regard, we generate a new EViews series object LOGGDP by issuing the following command:
series loggdp = 100 * log(gdp)
At last, following the 4 steps outlined earlier, we derive the BN decomposition in EViews as follows:
series dy = d(loggdp)
equation ar1.ls dy c dy(1) 'Step 1
scalar mu = c(1)/(1c(2)) 'Step 2
series bntrend = loggdp + (dy  mu)*c(2)/(1  c(2)) 'Step 3
series bncycle = loggdp  bntrend 'Step 4
The BN trend and cycle series are displayed in Figure 2 below.


Figure 3a: BN Trend

Figure 3b: BN Cycle

To see how the BN decomposition estimate of the output gap compares to the CBO implied estimate of the output gap,
we plot both series on the same graph.

Figure 4: BN Cycle vs CBO implied output gap estimate

Evidently, the BN cycle series lacks persistence (very noisy), lacks amplitude (low variance), and in general,
does not exhibit the characteristics found in the CBO implied estimate of the output gap, CBOGAP.
The BN Filter
First, to explain why the BN estimate of output gap lacks the persistence of its true counterpart, recall the formula
for the BN cycle component for an AR(1) model:
$$ c_{t} = y_{t}  \tau_{t} = \frac{\phi}{1\phi}(\Delta y_{t}  \mu)$$
Clearly, when $ \phi $ is small, $ \Delta y_{t} $ is not very persistent. Since $ c_{t} $ is only as persistent as
$ \Delta y_{t} $, the cycle component itself lacks the persistence one expects of the true output gap series.
Next, to explain why $ c_{t} $ lacks the expected amplitude, define the signaltonoise ratio $ \delta $ for any time
series as the ratio of the variance of trend shocks relative to the overall forecast error variance. In other words:
$$ \delta \equiv \frac{\sigma^{2}_{\Delta \tau}}{\sigma^{2}_{\epsilon}} = \psi(1)^{2} $$
which follows since $ \Delta\tau = \psi(1)\epsilon_{t} $ and $ \psi(1) = \lim_{h\rightarrow \infty} \frac{\partial
y_{t+h}}{\partial \epsilon_{t}} $. Intuitively, $ \psi(1) $ is the longrun multiplier that captures the
permanent effect of the forecast error on the longhorizon conditional expectation of $ y_{t} $. Quite generally, as
demonstrated in Kamber, Morley, and Wong (2018), for any AR(p) model:
\begin{align}
\Delta y_{t} = c + \sum_{k=1}^{p}\phi_{k}\Delta y_{tk} + \epsilon_{t} \label{eq1}
\end{align}
the signaltonoise ratio is given by the relation
\begin{align}
\delta = \frac{1}{(1\phi(1))^{2}} \quad \text{where} \quad \phi(1) = \phi_{1} + \ldots + \phi_{p}\label{eq2}
\end{align}
In particular, when the forecasting model is AR(1), as was the case in the BN decomposition above, the signaltonoise
ratio is simply $ \delta = \frac{1}{(1\phi)^{2}} $ and in the case of the US GDP growth process, it is
$ \delta = \frac{1}{(10.36)^{2}} = 2.44$. In other words, the BN trend shocks exhibit higher volatility than
quartertoquarter forecast errors and the signaltonoise ratio is therefore relatively high. In fact, in the case
of a freely estimated AR$ (p) $ model of output growth, $ \phi(1) < 1 $, which implies that $ \delta > 1 $. In other words,the trend will be more volatile than the cycle, and at odds if one expects the cycle shocks (the output gap amplitude) to explain the majority of the systematic forecast variance.
To correct for the aforementioned shortcomings of the BN decomposition, Kamber, Morley, and Wong (2018) exploit
the relationship between the signaltonoise ratio and the AR coefficients in equation \eqref{eq2}. In particular,
they note that equation \eqref{eq2} implies that:
\begin{align}
\phi(1) = 1  \frac{1}{\sqrt{\delta}}
\end{align}
In this regard, the idea underlying the BN filter is to fix a specific value to the signaltonoise ratio, say
$ \delta = \bar{\delta} $. Subsequently, the BN decomposition is derived from an AR model, the AR coefficients
of which are forced to sum to $ \bar{\phi}(1) \equiv 1  \frac{1}{\sqrt{\bar{\delta}}} $. In other words, the
BN decomposition is derived while imposing a particular signaltonoise ratio.
It is important to note here that estimation of the BN decomposition under a particular signaltonoise ratio
restriction is in fact straightforward and does not require complicated nonlinear routines. To see this, observe
that equation \eqref{eq1} can be rewritten as:
\begin{align}
\Delta y_{t} = c + \rho \Delta y_{t1} + \sum_{k=1}^{p1}\phi^{\star}_{k}\Delta^{2} y_{tk} + \epsilon_{t} \label{eq3}
\end{align}
where $ \rho = \phi_{1} + \ldots + \phi_{p} $ and $ \phi^{\star}_{k} = \left(\phi_{k+1} + \ldots +
\phi_{p}\right) $. Then, imposing the restriction $ \rho = \bar{\rho} \equiv \bar{\phi}(1) $ reduces the
regresion in \eqref{eq3} to:
\begin{align}
\Delta y_{t}  \bar{\rho} \Delta y_{t1} = c + \sum_{k=1}^{p1}\phi^{\star}_{k}\Delta^{2} y_{tk} + \epsilon_{t} \label{eq4}
\end{align}
In other words, $ \bar{\rho}\Delta y_{t1} $ is brought to the left hand side and the regressand in the regression
\eqref{eq4} becomes $ \Delta \bar{y}_{t} \equiv \Delta y_{t}  \bar{\rho} \Delta y_{t1} $.
Why Use the BN Filter?
Before we demonstrate the BN Filter addin, we quickly outline two reasons why the BN filter might be a reasonable
approach, particularly when estimating the output gap.
 When analyzing GDP growth, standard ARMA model selection often favours low order AR variants, which, as
discussed earlier, produce high signaltonoise ratios.
 Unlike alternative low signaltonoise ratio procedures such as deterministic quadratic detrending, the
HodrickPrescott (HP) filter, and the bandpass (BP) filter, which often require large number of estimation
revisions (as new data comes in) and are typically unreliable in outofsample forecasts (see Orphanides
and Van Norden, (2003)), Kamber, Morley and Wong (2018) argue that the BN filter exhibits better outofsample
performance and generally requires fewer estimation revisions to match observable data characteristics.
To further drive this latter point, we demonstrate the impact of expost estimation of the output gap using the HP
filter. In particular, we will first estimate the output gap (the cycle component) of the LOGGDP series for the
period 1947Q1 to 2008Q3 and call it HPCYCLE, and then again for the period 1947Q1 to 2019Q3 and call it
HPCYLCE_EXPOST.
To estimate the HP filter cycle component for the period 1947Q1 to 2008Q3, we first set the sample accordingly by
issuing the command:
smpl @first 2008Q3
Next, we estimate the HP filter cycle series as follows:
 From the workfile, double click on the series LOGGDP to open the series.
 In the series window, click on Proc/HodrickPrescott Filter...
 In the Cylce series text box, type hpcycle.
 Hit OK.

Figure 5: HP Filter

The steps are repeated for the sample period 1947Q1 to 2019Q3. A plot of both cycle series on the same graph is
presented below.

Figure 6: HP Cycle vs HP Cycle Ex Post

Evidently, the expost HP filter estimation of the output gap diverges from its shorter period counterpart
starting from 2006Q1. It is precisely this drawback that we will see is not nearly as pronounced in BN filter
estimates.
BN Filter Implementation
To implement the BN Filter, we need to download and install the addin from the EViews website. The latter
can be found at https://www.eviews.com/Addins/BNFilter.aipz.
We can also do this from inside EViews itself:
 From the main EViews window, click on Addins/Download Addins...
 Click on the the BNFilter addin.
 Click on Install.

Figure 5: Install Addin

At last, we will demonstrate how to apply the BN Filter addin using an AR(12) model. To do so, proceed as
follows:
 From the workfile window, double click on LOGGDP to open the spreadsheet view of the series.
 To access the BN filter dialog, click on Proc/Addins/BN Filter
 Stick with the defaults and hit OK.

Figure 6: BN Filter Dialog

The signaltonoise ratio, while not specified above, is chosen using the Kamber, Morley, and Wong (2018) automatic
selection procedure which balances the trade off between fit and amplitude. Typically, the signaltonoise ratio for
the US using such a procedure is about 0.25, which implies a quarter of the shocks to US GDP are permanent. Below, we
show the BN Filter cycle series both alone and in comparison to the CBO implied estimate of the output gap CBOGAP.


Figure 7a: BN Filter Cycle

Figure 7b: BN Filter Cycle vs CBO implied output gap estimate

We also plot a comparison of the BN Filter cycle series with the HP filtered cycle.

Figure 8: BN Filter Cycle vs HP Filter Cycle

As we can see, the BN filter estimate of the the US output gap using an AR(12) model resembles what we would
get for an output gap that has a low signaltonoise ratio. The amplitude is reasonably large, we see business
cycles, and the troughs line up with the recessions dated by the NBER. The amplitude of the output gap estimated using the BN Filter is comparable to that of the cycle obtained by the HP filter, as well as the implied estimated of the CBO, which is unlike what we see in Figure 4.
The BN filter addin also accommodates the ability to incorporate knowledge about structural breaks. In
particular, we will use 2006Q1 as a structural break which is consistent with the date found by a Bai and Perron
(2003) test, used by Kamber, Morley and Wong (2018), and is consistent with independent work by Eo and Morley
(2019). The following steps demonstrate the outcome:
 From the workfile window, double click on LOGGDP to open the spreadsheet view of the series.
 To access the BN filter dialog, click on Proc/Addins/BN Filter
 Select the Structural Break box.
 In the Date of structural break text box, enter 2006Q1.
 Hit OK.

Figure 9: BN Filter Cycle (Structural Break)

Now we see a more positive output gap post2006 as the structural break accounts for the fact that the average
GDP growth rate has fallen.
Suppose however that we were ignorant about the actual date of the break. This might be the case in practice as
it could take a decade or more before one could empirically identify a structural break date. In this case, a
possible option is to use a rolling window for the average growth rate. In this example, we use a backward
window of 40 quarters as the average growth rate. The idea is that if there were breaks, they would be reflected
in this window. When this is the case, we proceed as follows:
 From the workfile window, double click on LOGGDP to open the spreadsheet view of the series.
 To access the BN filter dialog, click on Proc/Addins/BN Filter
 Select the Dynamic mean adjustment box.
 Hit OK.


Figure 10a: BN Filter Cycle (Dynamic Mean Adjustment)

Figure 10b: BN Filter Cycle (Known vs Unknown Structural Break)

Evidently, the estimated output gap looks similar to the one estimated with an explicit structural break in
2006Q1. In general, this suggests that using a backward window to adjust for the mean growth rate might be a
useful realtime strategy for dealing with breaks.
Users are not constrained to the automatic option, which balances the trade off between fit and amplitude. The BN filter addin also allows users to specify a desired signaltonoise ratio. For instance, the following example compares the difference in setting the signaltonoise ratio $ \delta $, to 0.05 (which implies 5% of the variance is permanent), against the default 0.25 which we derived earlier by leaving $ \delta $ unspecified, and so uses the procedure which balances the trade off between fit and amplitude. To do so, we proceed as follows:
 From the workfile window, double click on LOGGDP to open the spreadsheet view of the series.
 To access the BN filter dialog, click on Proc/Addins/BN Filter
 Select the Structural Break box.
 In the Date of structural break text box, enter 2006Q1.
 Hit OK.
The plot below summarizes the exercise.

Figure 11: BN Filter Cycle (delta = 0.25 vs delta = 0.05

Unsurprisingly, specifying $ \delta = 0.05 $ results in an output gap with a larger amplitude than the default as the new specification implies a smaller proportion of the shocks to the forecast error is parsed to the trend, and so a larger proportion is parsed to the cycle, leading to a larger amplitude cycle.
Finally, we come back to the issue of revision. As we mentioned earlier, the BN filter should produce output
gaps that are less revised as long as the AR forecasting model is stable, especially when compared to the
heavily revised HP Filter. Here, we show the output gap estimated using the BN filter with data up to
2008Q3, and one expost up to 2019Q3. Clearly, the output gap is hardly revised, which address a key critique
of Orphanides and Van Norden (2003).

Figure 11: BN Filter Cycle (ExPost)

Conclusion
In this blog post we have outlined the BN filter addin associated with the work of Kamber, Morley and Wong (2018).
In general, we hope the ease of using the addin, together with some of the useful properties of the BN Filter will
encourage practitioners to explore using the procedure in their work.
Files
References
 Bai J. and Perron P.:
Computation and analysis of multiple structural change models
Journal of Applied Econometrics, 18(1) 1–22, 2003.
 Beveridge S. and Nelson C. R.:
A new approach to decomposition of economic time series into permanent and transitory components with
particular attention to measurement of the business cycle
Journal of Monetary Economics, 7(2) 151–174, 1981.
 Eo Y. and Morley J.:
Why has the US economy stagnated since the Great Recession
University of Sydeny Working Papers 201714, 2019.
 Kamber G., Morley J., and Wong B.:
Intuitive and reliable estimates of the output gap from a BeveridgeNelson filter
The Review of Economics and Statistics, 100(3) 550–566, 2018.
 Orphanides A and Van Norden S.:
The unreliability of outputgap estimates in real time
The Review of Economics and Statistics, 84(4) 569–583, 2002.
 Watson M.:
Univariate detrending methods with stochastic trends
Journal of Monetary Economics, 18(1) 49–75, 1986.
Thanks, Ben and Davaa. This is very helpful in showing how to use the BN filter in EViews.
ReplyDeleteThe comparison with the CBO gap is interesting. But I decided to make a direct comparison between the BN filter output gap (with dynamic demeaning) and the HP filter output gap using the EViews procedures, including the addin.
The result is here.
As can be seen in the linked figure, the BN and HP gaps have more similar amplitude than with the CBO gap. The HP gap is deeper than the BN gap in the 8182 recession, while the BN gap is deeper than the HP gap in the Great Recession.
Note that I have used an old version of the EViews addin for which the BN filter needs to be applied to the *first difference* of the series to be detrended, while the HP filter procedure applies directly to the series to be detrended. The blog post seems to suggest that the BN filter can be applied to directly to the series to be detrended, which makes sense since the BN decomposition is a trend/cycle decomposition of y, not dy. So hopefully an updated version of the addin will allow this. Also, it would be great if users can impose a smoothing parameter delta, much like imposing a lambda for the HP filter. This is possible in the Matlab and R code for the BN filter available on the Global Perspective's Model Hub.
Hi James. I just wanted to give you a heads up that both links for the Matlab and R code for the BN filter on Global Perspective's Model Hub currently do not appear to be working. It redirects to Ben's page but gives a 404 error. I just wanted to let you know.
DeleteThanks, Yamin. It seems that Ben has reorganized his site. The code is available on his research page.
DeleteProbably, something is wrong with this addin. Instead of cycle, it gives trending line. So I cannot replicate this stuff in Eviews 11 and 10. Additionally, Eviews freezes while executing bnfilter_blog.prg.
ReplyDeleteThanks for bringing it to our attention. We've updated the system with the correct version. Things should work as expected now.
DeleteJust tried out the updated version of the addin (version 2.1) and it works perfectly. Once installed, it can be applied easily by opening a series to be detrended (e.g., y, where "genr y=100*log(realGDP)"), clicking the Proc button, and selecting BN Filter under Addins at the bottom of the menu.
ReplyDeleteThere is also now an option to impose a smoothing parameter, if desired.
Thanks, Davaa for creating the addin and updating it to work like the HP filter procedure in EViews, while, of course, producing a more reliable estimate of output gap!
How do you set the smoothing delta in command? I tried the code below but no luck:
ReplyDeletey.bnfilter(lag=12, demean=1, window=40, delta=0.1)
y.bnfilter(lag=12, impose=1, delta=0.1)
DeleteThanks. My post below is not relevant after this explanation.
DeleteAh I needed to add "impose=1"  thanks for your help!
DeleteIt seems that delta is setting only in addin now. In command line this is not working at this point.
ReplyDeletey.bnfilter(lag=12, impose=1, delta=0.1)
DeleteJust a note that version 2.1 of the addin, which applies the BN filter to the levels of the series to be detrended, shifts the timing of the cycle one period back. That is, it suggests there is a cycle in the first period that the levels series is available and does not report a cycle in the last period. However, the cycle should be shifted forward one period (i.e., no cycle in the first period that the series is available because the series needs to be differenced when applying the filter and a cycle in the last period). Hopefully this can be fixed in the next version of the addin. But, in the meantime, it is important for users to shift the cycle forward (e.g., "genr bn_cycle_s_true=bn_cycle_s(1)") to be correctly timed.
ReplyDeleteThank you Prof. James for pointing the shift. It will be fixed soon.
ReplyDeleteThanks, Davaa. And thanks for all the work on the addin.
Delete