Perron and Wada(2009)

Use this forum for posting example programs or short bits of sample code.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Perron and Wada(2009)

Unread post by TomDoan »

This is a replication for Perron and Wada(2009), "Let’s take a break: Trends and cycles in US real GDP", Journal of Monetary Economics, vol 56, 749-765. This uses the same data and uses the same basic model as Morley, Nelson and Zivot(2003), but adds a shift in the trend rate.

This is covered in the 2nd Edition of the State-Space/DSGE e-course.
pw_jme_2009.rpf
Program file
(2.19 KiB) Downloaded 1224 times
lgdp.txt
Data file
(3 KiB) Downloaded 1186 times
Future
Posts: 6
Joined: Fri Jan 04, 2013 5:27 am

Why UC0 and UCUR have same result?

Unread post by Future »

Hi TOM!
I'm interested in Perron and Wada(2009)("Let's take a break:* Trends and cycles in US real GDP", Journal of Monetary Economics, vol* 56, 749-765.), try using some monthly data for other research, but I found UC0 and UCUR results almost exactly the same, I posted below. In order to guarantee for the original program changes in the minimum, I didn't replace variables and the name of the title. please help me , thanks.

Code: Select all

* Standard state space models and ARIMA models
*
OPEN DATA bmonth201310.txt
CALENDAR(M) 2004:1
DATA(FORMAT=PRN,NOLABELS,ORG=COLUMNS) 2004:01 2013:10 lgdp
*
* Everything is run on 50*log data
*
set lgdp  = 50.0*lgdp
set d2006 = t>2006:4
*
*
* UC-0 decomposition with AR(2) cycle, broken trend rate.
*
nonlin mu d sn ph1 ph2 se
*
dec frml[rect] af
dec frml[vect] zf
dec frml[symm] swf
*
frml af = ||1.0,0.0,0.0|$
            0.0,ph1,ph2|$
            0.0,1.0,0.0||
frml zf = ||mu+d*d2006,0.0,0.0||
frml swf = %diag(||sn^2,se^2||)
*
compute [vect] c=||1.0,1.0,0.0||
compute [rect] f=%identity(2)~~%zeros(1,2)
*
* Get initial guess values
*
filter(type=hp) lgdp / gdp_hp
set gap_hp = lgdp - gdp_hp
linreg gap_hp
# gap_hp{1 2}
compute ph1=%beta(1),ph2=%beta(2),se=sqrt(%seesq)
set trend = t
linreg gdp_hp
# constant trend
compute mu=%beta(2)
compute sn=sqrt(.1*%seesq)
*
dlm(presample=ergodic,a=af,z=zf,sw=swf,c=c,f=f,y=lgdp,method=bfgs,type=filter) / states0
*
set cycle0 = states0(t)(2)
set trend0 = states0(t)(1)
*
graph(footer="Figure 1 UC-0 Cycle, US Real GDP. Percent Deviation from Trend")
# cycle0
*
* Unrestricted UC model, allowing for correlation between the shocks.
* The maximum occurs at rho=1 (possible since we have only one
* observable, so having just a single effective shock is OK).
*
compute rhone=0.0,sn=.1
nonlin mu d sn ph1 ph2 se rhone=1.0
*
frml swf = ||sn^2|rhone*abs(sn)*abs(se),se^2||
dlm(presample=ergodic,a=af,z=zf,sw=swf,c=c,f=f,y=lgdp,method=bfgs,type=filter) / statesur
set cycleur = statesur(t)(2)
set trendur = statesur(t)(1)
graph(footer="Figure 3 UC-UR Cycle, US Real GDP")
# cycleur
*
* Estimation of unrestricted ARIMA(2,1,2) model. BOXJENK doesn't find
* the boundary solution because it pushes away from unit roots in the
* moving average part.
*
boxjenk(ar=2,diffs=1,ma=2,maxl,noapplydiffs,reg) lgdp
# constant d2006
*
* Estimate of constrained model (AR(2) with broken trend)
*
set trend  = t
set dtrend = %max(0,t-2006:4)
boxjenk(ar=2,diffs=0,reg,maxl) lgdp
# constant trend dtrend
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Perron and Wada(2009)

Unread post by TomDoan »

If you're applying this to a different data set, you don't want to start with rhone pegged at 1 which is what this is doing:

nonlin mu d sn ph1 ph2 se rhone=1.0

You might have to do that if the maximum is at the boundary, but you want to give it an opportunity to find an interior solution by starting with just rhone rather than rhone=1 on the NONLIN.

What do you mean by "almost identical"? If you look at the estimates with the original data, both the restricted and unrestricted models end up with (in effect) one shock rather than two---the restricted model pushes SN to zero, while the unrestricted pushes rho to 1.
rawraw
Posts: 9
Joined: Sat Sep 28, 2013 2:29 am

Re: Perron and Wada(2009)

Unread post by rawraw »

Hi,Tom
how can I get starting values of nonlin parameter below and starting values of x0|0 and P0|0 in mixture model for my application? the code please! many thanks!
nonlin sn se sg so ph1 ph2 alpha1 alpha2
compute sn=.0004,se=||.2583,1.2816||,sg=||.0001,.0634||,so=.2497,ph1=1.3800,ph2=-.4719,alpha1=.9000,alpha2=.5813
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Perron and Wada(2009)

Unread post by TomDoan »

I'm fairly sure those came from the authors, so you would have to check with them.
falcon223
Posts: 6
Joined: Wed Jun 10, 2015 4:48 pm

Re: Perron and Wada(2009)

Unread post by falcon223 »

Dear Tom,

I am new to State Space model.
I am running a perron wada (2009) model with 3 breaks in the trend.
I have got the cycle component. I was thinking how do I estimate the length of the cycle.
I know it should be 2pai/lamda. How do I do it in rats.
Many thanks.

Best wishes,
Rosen
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Perron and Wada(2009)

Unread post by TomDoan »

This is a direct AR(2) estimation, which will only have "cycles" if ph2 is negative. Assuming that's true, then cycle period is 2*%pi/(%acos(ph1/(2*sqrt(-ph2))))
falcon223
Posts: 6
Joined: Wed Jun 10, 2015 4:48 pm

Re: Perron and Wada(2009)

Unread post by falcon223 »

Dear Tom many thanks. Just wondering is there a procedure that I can use for this. The AR(2) term is negative . Also how do we get the amplitude of the cycles.
Thanks again

best wishes
Rosen
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Perron and Wada(2009)

Unread post by TomDoan »

The amplitude is sqrt(-ph2). Now, there's no procedure since it's just a straightforward algebraic calculation.
Post Reply