Smets/Wouters (2007) in Dynare 4.2.5

If you want to calculate the correlations of the variables or change time periods, how do you do that using Dynare?

What do you mean? In the context of Bayesian estimation, use the moments_varendo option for the moments and the nobs and first_obs options for the sample. See the manual.

Hi Professor,

I can run ā€œdynare usmodel_shock_decomp.modā€ on my 4.4.3, but when I run ā€œdynare usmodel_stst.modā€ I got the following message:

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ā€¦
ERROR: usmodel_stst.mod: line 23, cols 1-0: syntax error, unexpected $end

Thereā€™s no line 23 in the mod file. And if I delete line 22, the message still shows up.

The usmodel_stst.mod is not for running it with Dynare. It just contains the steady state.

Hi,

I am using MATLAB version 2014a along with Dynare 4.2.5 in order to run the posted Smets-Wouters program.

I am receiving the following error message(s):

The class RandStream has no property or method named ā€˜setDefaultStreamā€™.

Error in set_dynare_seed (line 35)
reset(RandStream.setDefaultStream(s));

Error in global_initialization (line 319)
set_dynare_seed(ā€˜defaultā€™);

Error in usmodel_shock_decomp (line 16)
global_initialization;

Error in dynare (line 120)
evalin(ā€˜baseā€™,fname) ;

I am under the impression this is due to the version of MATLAB I am using. Any suggestions on how to overcome this problem? Thank you very much!

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.)

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

1 Like

The most current file is now kept at 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 aeaweb.org/articles.php?doi=10.1257/aer.97.3.586

[quote=ā€œjpfeiferā€]The most current file is now kept at 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 aeaweb.org/articles.php?doi=10.1257/aer.97.3.586[/quote]

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!

Did you put the

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

That was it, thanks :slight_smile:

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

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?

  1. I use

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!

  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 oo_.autocorr
    For details, see 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 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

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.

  1. The reason is that Smets/Wouters did not provide a fully calibrated model before calling the estimation command. To fix this, simply add

constepinf=0.7; constebeta=0.7420; ctrend=0.3982;
before the model-block. I just updated the version for Dynare 4.5 at github.com/JohannesPfeifer/DSGE_mod/blob/master/Smets_Wouters_2007/Smets_Wouters_2007_45.mod

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

Thank you. Regarding (1) it was just as Iā€™d thought, but wanted to check that there wasnā€™t something subtle going on.

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.

That makes sense. Thank you for looking into this.

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.
SW07_model.mod (4.31 KB)

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.