Replication of Smets and Wouters (2007)

Discussion of State Space and Dynamic Stochastic General Equilibrium Models

Replication of Smets and Wouters (2007)

Unread postby BinhPham » Tue Feb 14, 2017 3:25 pm

Dear RATSers,

I am a beginner in DSGE and find that some RBC DSGE models can be solve with RATS. My question is that can RATS reproduce the results of Smets and Wouters (2007) or similiar papers using Bayesian estimation techniques?

Many thanks,
BinhPham
 
Posts: 50
Joined: Tue Feb 14, 2017 11:00 am

Re: Replication of Smets and Wouters (2007)

Unread postby BinhPham » Wed Feb 15, 2017 2:48 pm

I am trying to convert Smets and Wouters (2007) Dynare files into RATS form. The problem is some local variables defined as #var_names = ... (prefix with #) cannot be converted by RATS conversion utility.

Of course, we can rewrite the equations without any local model variables but it is worth knowing the natural way in RATS to declare the macro variables like dynare done.

Any ideas? Please share or show me the way to handle this issue.

Thanks in advance,
BinhPham
 
Posts: 50
Joined: Tue Feb 14, 2017 11:00 am

Re: Replication of Smets and Wouters (2007)

Unread postby TomDoan » Wed Feb 15, 2017 5:06 pm

Attached is a set of programs that come at least close to replicating the model. It seemed a bit too "blackboxy" for my taste---there were more than a few places where things really weren't documented and would have to be hacked out of the Matlab code.
Attachments
Smets Wouters RATS.zip
(87.5 KiB) Downloaded 560 times
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Replication of Smets and Wouters (2007)

Unread postby BinhPham » Wed Feb 15, 2017 6:40 pm

Dear Tom,

Many thanks for your efforts. But I cannot run your code with trial version 9.1. The messages are:

Model SW US (2007) message is below:
## SX19. This Character is Illegal Here
>>>>compute cstderrqs=?<<<<


Model SW (2003):
## FO15. Model can't be expanded. Includes exogenous series reference.
Taking derivative with respect to YP{0}
Error was in FRML EQN10


Model with data: withdata.rpf generates error at "source smetswouters.src" line. The message is:
## FO17. Mismatch between unstable roots and expectational terms.

I have copied all *.src into both working dir and source dir. I run some RBC example without any problems.

Please advise to correct!
Thanks a lot.
BinhPham
 
Posts: 50
Joined: Tue Feb 14, 2017 11:00 am

Re: Replication of Smets and Wouters (2007)

Unread postby TomDoan » Thu Feb 16, 2017 3:47 pm

BinhPham wrote:Dear Tom,

Many thanks for your efforts. But I cannot run your code with trial version 9.1. The messages are:

Model SW US (2007) message is below:
## SX19. This Character is Illegal Here
>>>>compute cstderrqs=?<<<<



These programs are as I left them when last I tried to work on this. The 2007 paper had some shock sizes that didn't seem to be specified. You might want to look through that paper (reference is that the top) more carefully and see if you can find the missing information.

BinhPham wrote:Model SW (2003):
## FO15. Model can't be expanded. Includes exogenous series reference.
Taking derivative with respect to YP{0}
Error was in FRML EQN10



And that was the reason I gave up on that. The SW model has a "shadow" set of equations to generate potential output and no one seems to want to actually write down what the equations are for that. (The SW appendix on the AER web site has a blank space where they're supposed to be).
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Replication of Smets and Wouters (2007)

Unread postby BinhPham » Thu Feb 16, 2017 6:47 pm

Thank for your post. I am trying to correct something ...then upload asap.
BinhPham
 
Posts: 50
Joined: Tue Feb 14, 2017 11:00 am

Re: Replication of Smets and Wouters (2007)

Unread postby junlin » Mon Mar 06, 2017 1:37 pm

Dear Tom,
I have two questions about DSGE estimation:
(1) When I use the method in "Bayesian Estimation: Hyperinflation Model" in RATS Handbook for State-Space Models to estimate a simple DSGE mode. In the "function EvalModel":
If I use "compute gdlm=%dlmgfroma(adlm)" or "compute gdlm=||1.0,-1.0||~\%identity(%rows(adlm)-2)"
The estimation will be done,but the graph is one horizontal line!
If I use "compute gdlm=||1.0,-1.0||~\%identity(%rows(adlm)-2)"above, RATS tell me:
## MAT3. Matrix with Dimensions 21 x 22 Involved in DLM-G matrix Operation. Need rxN
The Error Occurred At Location 200, Line 3 of EVALMODEL
Called From Location 613, Line 26 of EVALPOSTERIOR
Called From Location 28, Line 1 of loop/block
So:
*1) How to set the matrix of gdlm? Every time we guess it ?
*2) Why are the density graphs horizontal lines? If we use Uniform destribution, we can't get the resoult from bayesian estimation?

(2) In program of "withdata" (replication for Smets Wouters (2007)),
Why shouldn't we set the prior destribution of parameters? Can we set the prior destribution of parameters in program of "withdata"?Can we use the commands below( in "Bayesian Estimation: Hyperinflation Model") to get the density of parameters ?

@mcmcpostproc(ndraws=ndraws,mean=bmean,stderrs=bstderrs,cd=bcd) bgibbs
set alphas 1 ndraws = bgibbs(t)(1)
density(grid=automatic,maxgrid=100,band=.75) $
alphas 1 ndraws xalpha falpha
scatter(style=line,vmin=0.0,footer="Posterior for the_c")
# xalpha falpha


Thank you!

Sincerely,
Junlin Mu
Attachments
question for Bayesian Estimation.rar
(26.17 KiB) Downloaded 490 times
junlin
 
Posts: 3
Joined: Sun Jan 17, 2016 9:15 am

Re: Replication of Smets and Wouters (2007)

Unread postby TomDoan » Wed Mar 08, 2017 12:45 pm

junlin wrote:Dear Tom,
I have two questions about DSGE estimation:
(1) When I use the method in "Bayesian Estimation: Hyperinflation Model" in RATS Handbook for State-Space Models to estimate a simple DSGE mode. In the "function EvalModel":
If I use "compute gdlm=%dlmgfroma(adlm)" or "compute gdlm=||1.0,-1.0||~\%identity(%rows(adlm)-2)"
The estimation will be done,but the graph is one horizontal line!
If I use "compute gdlm=||1.0,-1.0||~\%identity(%rows(adlm)-2)"above, RATS tell me:
## MAT3. Matrix with Dimensions 21 x 22 Involved in DLM-G matrix Operation. Need rxN
The Error Occurred At Location 200, Line 3 of EVALMODEL
Called From Location 613, Line 26 of EVALPOSTERIOR
Called From Location 28, Line 1 of loop/block
So:
*1) How to set the matrix of gdlm? Every time we guess it ?


So far as I can tell, those all work fine if you run the entire program. However, the G option on the DLM is no longer necessary, since PRESAMPLE=ERGODIC to handle it without any (prior) calculations:

dlm(a=adlm,f=fdlm,sw=%diag(||sig_eps^2,sig_eta^2||),y=||x,mu||,$
c=cdlm,presample=ergodic,method=solve)

(That's described in the text, but apparently didn't make it into the program). The use of the G option is deprecated in favor of the PRESAMPLE=ERGODIC because it does change from model to model.

junlin wrote: *2) Why are the density graphs horizontal lines? If we use Uniform destribution, we can't get the resoult from bayesian estimation?


They aren't so far as I can tell.

junlin wrote: (2) In program of "withdata" (replication for Smets Wouters (2007)),
Why shouldn't we set the prior destribution of parameters? Can we set the prior destribution of parameters in program of "withdata"?Can we use the commands below( in "Bayesian Estimation: Hyperinflation Model") to get the density of parameters ?

@mcmcpostproc(ndraws=ndraws,mean=bmean,stderrs=bstderrs,cd=bcd) bgibbs
set alphas 1 ndraws = bgibbs(t)(1)
density(grid=automatic,maxgrid=100,band=.75) $
alphas 1 ndraws xalpha falpha
scatter(style=line,vmin=0.0,footer="Posterior for the_c")
# xalpha falpha


As I said in the post where I included those, those aren't finished products, and, in fact, are far from it. If you can find someone who has actually documented the complete model, please post a reference.
TomDoan
 
Posts: 7147
Joined: Wed Nov 01, 2006 5:36 pm

Re: Replication of Smets and Wouters (2007)

Unread postby adrangi » Sat Sep 04, 2021 12:29 pm

Hi Tom. I'm trying to estimate a DSGE model for the US data. As a first step, I tried to just execute the program that you had provided. I got the following error message
## FO17. Mismatch between unstable roots and expectational terms.

So, the first question is why doesn't the program run?

Secondly, I was reading a paper that used several macro time series to estimate a DSGE model. In your program I don't even see a place where you can read and use the current data for the US. Please advise. Thanks. Best, Bahram
adrangi
 
Posts: 48
Joined: Sun Sep 05, 2010 7:23 pm

Re: Replication of Smets and Wouters (2007)

Unread postby adrangi » Sat Oct 23, 2021 1:06 pm

Hi Tom and everyone. I'm trying to estimate a DSGE model for the US data. As a first step, I tried to just execute the program smetswouters.src on the data set smetswouters.prn that is on the forum. I didn't change anything. I got the following error message multiple times.
## FO17. Mismatch between unstable roots and expectational terms.

I can't figure out why this error is showing up. Has anyone on the Forum tried to do the same thing successfully? Any help is much appreciated. Thanks much. Bahram
adrangi
 
Posts: 48
Joined: Sun Sep 05, 2010 7:23 pm


Return to State Space Models/DSGE

Who is online

Users browsing this forum: No registered users and 2 guests