Page 4 of 5

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Wed May 27, 2015 4:46 pm
by jpfeifer
You cannot use Dynare 4.2.5 with newer Matlab version due to changes in Matlab'r random number generator. Please use the current Dynare stable version (4.4.3 at the time of this writing.)

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Tue Dec 29, 2015 2:59 pm
by www3
Hi,

I'm trying to compare the 2007 Smets Wouters model with some other models I created. I downloaded the model from the original post. I have two quick questions. What is the date on the data, and how are they transformed. Is it an exact copy of the paper? If so could you tell me the source you got the information from. I tried to get it from FRED but am unable to find the data the matches close enough for me to be satisfied. Thanks,

Cameron

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Tue Dec 29, 2015 3:07 pm
by jpfeifer
The most current file is now kept at https://github.com/JohannesPfeifer/DSGE_mod/tree/master/Smets_Wouters_2007
The data are taken directly from the Smets/Wouters (2007) replication files at the AER. Their Appendix also describes the transformations, see https://www.aeaweb.org/articles.php?doi=10.1257/aer.97.3.586

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Thu Feb 25, 2016 7:38 pm
by mjfourier
jpfeifer wrote:The most current file is now kept at https://github.com/JohannesPfeifer/DSGE_mod/tree/master/Smets_Wouters_2007
The data are taken directly from the Smets/Wouters (2007) replication files at the AER. Their Appendix also describes the transformations, see https://www.aeaweb.org/articles.php?doi=10.1257/aer.97.3.586


Hi, I am using Dynare 4.4.3, but when I take the code directly from your website, the following message shows up:

You did not declare endogenous variables after the estimation/calib_smoother command.

Error using load
Unable to read MAT-file
C:\Users\admsop\Dropbox\usmodel_shock_decomp_mode.mat: not a
binary MAT-file.
Try LOAD -ASCII to read as text.
Error in dynare_estimation_init (line 125)
mode_file = load(options_.mode_file);
Error in dynare_estimation_1 (line 81)
[dataset_,xparam1, hh, M_, options_, oo_,
estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname,
[], M_, options_, oo_, estim_params_,
bayestopt_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in codedi (line 505)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;


I don't understand what might be wrong, I just downloaded the files and ran them using the lastest stable Dynare version.

Thanks in advance for any guidance!

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Fri Feb 26, 2016 7:40 am
by jpfeifer
Did you put the
Code: Select all
usmodel_shock_decomp_mode.mat

in the same folder? There seems to be a text file with the same name already there.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Fri Feb 26, 2016 4:27 pm
by mjfourier
That was it, thanks :)

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Sun Feb 28, 2016 8:03 pm
by mjfourier
Hello Mr Pfeifer,

1. I am trying to do something similar to Figure 5 of the original paper (Actual and model-based cross-correlation function between output and inflation). After running your code, try the following in my command window

Code: Select all
crossmod=xcorr(y,pinf)
crossdata=xcorr(dy,pinfobs)


(then I would take those two series and plot them, but I receive the following error:

Undefined function or variable 'y'.

Nevertheless, y is one of my declared endogenous variables. Could you help me know what am I missing?

2. I use

Code: Select all
stoch_simul(irf=20, conditional_variance_decomposition=[1,2,4 10, 40,100]) dy dc dinve robs pinfobs dw labobs ;


and I want ultimately to get a graph of the forecast error variance decomposition like the one in the paper (figure 1), and I understand that is what conditional_variance_decomposition=[1,2,4 10, 40,100] is for, but I am not sure where the output of this is stored, or how to insert a command to get a plot (if that is possible).

Thank you very much in advance!

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Mon Feb 29, 2016 9:23 am
by jpfeifer
1. The code does not simulate data from the model, so you cannot do what your are trying. There are two ways: either add a periods statement to the stoch_simul command you are using or compute the correlations based on the covariances stored in
Code: Select all
oo_.autocorr

For details, see http://www.dynare.org/manual/index_26.html#oo_005f_002eautocorr
Regarding data moments, you have to compute them from your dataset. Do no rely on simulated moments from Dynare after stoch_simul. dy and pinfobs will not be from the loaded dataset, but simulated from the model.
2. See http://www.dynare.org/manual/index_26.html#oo_005f_002econditional_005fvariance_005fdecomposition. You would have to extract the required numbers and then plot them using Matlab's functions

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Tue Nov 15, 2016 4:47 pm
by Brasidas
Dear all,

I have searched on the forum but haven't quite found an answer.
I have run the Smets-Wouters model from Johannes' Gibhub as well as this forum (they're essentially the same) and
1) If I perform 'steady' or 'check' the file crashes as the steady state contains NaN of Inf. It also adds the warning that some of the parameters have no value. Without these checks the model solves but these errors are clearly undesirable.
2) If I run the identification command I then get the warning that the rank of J (moments) is deficient as several parameters are pairwise collinear.

Are these problems well known and just ignored?
Any help would be greatly appreciated.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Tue Nov 15, 2016 9:05 pm
by jpfeifer
1) The reason is that Smets/Wouters did not provide a fully calibrated model before calling the estimation command. To fix this, simply add
Code: Select all
constepinf=0.7;
constebeta=0.7420;
ctrend=0.3982;

before the model-block. I just updated the version for Dynare 4.5 at https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Smets_Wouters_2007/Smets_Wouters_2007_45.mod

2) I have to investigate this more deeply. Iskrev does not note any issues here, so this might be a problem with Dynare.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Wed Nov 16, 2016 10:09 am
by Brasidas
Thank you. Regarding (1) it was just as I'd thought, but wanted to check that there wasn't something subtle going on.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Tue Dec 13, 2016 3:35 pm
by jpfeifer
Regarding point 2) At the prior mean, [cmap,crhopinf] and [cmaw,crhow] are pairwise collinear. Thus, running identification at the prior mean will return a warning. But this is only a local issue. These parameters are only indistinguishable at the prior mean, but not at different points, like the mode. I have added this information to the mod-file.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Thu Dec 15, 2016 2:41 pm
by brasidas1
That makes sense. Thank you for looking into this.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Wed May 24, 2017 2:27 am
by David Gutkovsky
Hi jpfeifer,

I'm kind of new to Dynare and I don't have much experience with complex macro models like SW07. My professor asked me to write/find the Dynare code for SW07. I found this forum and the code worked perfectly. However, my professor wants to use a conventional parameterization (let's say alpha=1/3) and doesn't want to use these prior and posterior values and distribution of parameters.

I wrote the code based on yours and I took out the "estimation" part of the code. However, it doesn't work, giving the following error: "The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite".

What is exactly the problem? Is it possible to only use conventional parameterization (like in my code)? Do I just need to try some numbers to make it work?

Thank you for your time and help!

David.

Re: Smets/Wouters (2007) in Dynare 4.2.5

PostPosted: Thu May 25, 2017 5:39 pm
by jpfeifer
Use F9 in Matlab to execute the parameter definitions before the model block.You will see that same ratios that should be positive become negative so that you get complex values after that.