/* compute the bn decomposition for an AR(1) fitted to the first difference of log real gdp The easiest way to implement the bn decomposition is to do a 2 step approach step 1: estimate AR(1) model for 1st difference of log real gdp in eviews and save the residuals in a separate file using the command genr residar1 = resid Then store the file residar1.db in the default location using the STORE command: store residar1 Next, store the file lrgdp containing the log of real gdp using the store command store lrgdp Don't forget to write down the relevant estimated parameters (phi, mu etc) and compute the long-run multiplier phi*(1). Create a text file containing the logarithm of real gdp from the eviews .db file lrgdp.db. Edit lrgdp.db in notepad or the gauss editor and delete the eviews header information so that the file only contains data. step 2: compute the components representation y(t) = TD(t) + TS(t) + C(t) in GAUSS using this program. Using the BN decomposition TD(t) = y(0) + mu*t TS(t) = psi*(1)*pure random walk component in e(t), e(t) = residual from AR(1) model C(t) = psi~(L)e(t) = y(t) - TD(t) - TS(t) */ library pgraph; format 8,5; /* load data saved from eviews estimation of AR(1) model */ load y[] = c:\classes\econ584\lrgdp.txt; @ load text file into gauss matrix @ @ change path accordingly @ load u[] = c:\classes\econ584\residar1.txt; @ residuals from AR(1) estimation done in eviews @ mu = 0.007723; @ unconditional mean @ phi = 0.3709; @ AR coeff @ psi1 = 1.58957; @ psi*(1) @ T = rows(u); tt = seqa(1,1,T-2); @ create time trend from additive sequence @ /* bn decomposition */ dt = y[2] + mu*tt; @ TD(t) @ rw = cumsumc(u[3:T]); @ pure random walk component = cumulative sum of @ @ prediction errors from AR(1) model @ st = psi1*rw; @ TS(t) @ ct = y[3:T] - dt - st; @ C(t) = y(t) - TD(t) - TS(t) @ trend = dt + st; @ overall trend @ /* save output to disk */ screen off; output file=bn.out reset; y[3:T]~u[3:T]~st~dt~ct; output off; screen on; begwind; window(3,1,0); title("Ln(RDGP) 1947:3 - 1993:4"); xlabel("time"); ylabel("ln(RGDP)"); xy(tt,y[3:T]); nextwind; title("Total Trend = DT + ST"); ylabel("DT(t) + ST(t)"); xy(tt,trend); nextwind; title("Cyclical Component"); ylabel("C(t)"); xy(tt,ct); endwind; begwind; window(2,1,0); title("Stochastic Trend"); ylabel("ST(t)"); xy(tt,st); nextwind; title("Change in Stochastic Trend and Cyclical Component"); ylabel("DSt(t) and C(t)"); xy(tt,u[3:T]~ct); endwind;