*
* Enders, Applied Econometric Time Series, 4th edition
* Example from Chapter 4, page 251-252
* Beveridge-Nelson decomposition of British pound real exchange rate.
*
open data panel.xls
calendar(q) 1980:1
data(format=xls,org=columns) 1980:01 2013:01 australia canada france germany japan netherlands uk us
*
set y = log(uk)
set dy = y-y{1}
*
* With and without the mean
*
boxjenk(const,ma=1,define=dyeq) dy
boxjenk(noconst,ma=1,define=dyeq) dy
compute dymean=0.0
*
clear bntrend bncycle
do time=%regstart(),%regend()
uforecast(steps=100,from=time+1,equation=dyeq) dyfore
sstats time+1 time+100 dyfore-dymean>>stochastic
compute bncycle(time)=stochastic
end do time
*
* The BN "permanent" component is the *sum* of the data plus the cycle.
* (This is the opposite of the behavior of the typically detrending
* operation). However, the main point of the BN decomposition is to
* extract the cycle.
*
set bnperm = y+bncycle
*
spgraph(footer="BN Decomposition of log real UK exchange rate",vfields=2) 2
graph(hlabel="Data with permanent component") 2
# y
# bnperm
graph(hlabel="Cycle")
# bncycle 1980:1 *
spgraph(done)
*
* The BN decomposition can also be done with the @BNDECOMP procedure.
* This picks its own ARIMA model automatically.
*
@bndecomp y / bntrend