Smets/Wouters (2007) in Dynare 4.2.5

Hi everyone and thanks a lot for your answer, dear professor.

I have tried to use mode_compute=6 and, distinctly, 9 and the results are significantly better than the previous time, in case of mode_compute=6.
I want to ask you how can I use the mode_compute 6 combined with mode_compute 9? I use Dynare 4.4.0 and I wrote the optimization commands recommended by you (mode_compute=6 and, respectively 9) in the estimation command. I would really appreciate if you would give some help by telling me how can I write the command to combine both of these optimization methods (if possibly).

In addition, I have some question regarding the results of the estimation obtained:
1.regarding the variance decomposition, based on the independent contribution of each particular shock, I have obtained a graph that doesn’t seem correct in comparison with the one of the original model of Smets&Wouters (the graph that I hope will be attached Graph 1). In my case, the initial values of the observed variables are very significant in the explanation of the variance. Can you please have a look at it and tell me whether you find this situation is correct, that the variance of the initial value have such a big influence?
C:\Users\gionita\Desktop\GRAPHIC
2.regarding the convergence of Markov chain obtained, as resulted from Graph2-with the hope to be attached, there are some problems of convergence. Do you have any suggestion for solving them?
C:\Users\gionita\Desktop
3. the last question is about the graphs of the apriori and, respectively, aposteriori distributions of the parameters from the model. As results from Graph3-attached there is a big difference between the graph of the apriori distribution and that of the aposteriori distribution. This situation is not for all the parameters, I have attached you the ones with the higher differences. I am not sure that this is correctly, could this would mean that the observed variables bring additional information to the model?
C:\Users\gionita\Desktop

Thanks a lot for your support!

Hello, everyone!

Can anyone please help me with an answer to my questions?
I really need to know it.

For a clear understanding it would also help to know how to attach the graphs that I mentioned about.

Thanks a lot!

Hi,

Thanks a lot for your answer.
I am afraid that the answer was referring to the to the version of Dynare 4.2.5.

The version of Dynare that I am using is 4.4.0.

When you run the mode-finding, Dynare will save the found mode in a mode-file. What you can do then is load this mode with the mode_file option and continue from that point with a different mode-finder.

You can attach graphs in the pdf-format. Just specify the graph_format=(pdf) option.

Hi,
Thanks a lot for your answer.

I have attached bellow the graphs, as mentioned in the previous message:
Graph1- Variance decomposition
Graph 2- Graph of apriori and aposteriori distribution
Graph 3- Graph of the Markov Chain Monte Carlo convergence

The questions related to the attached graphs are:
1.regarding the variance decomposition, based on the independent contribution of each particular shock, I have obtained a graph (the Graph 1) that doesn’t seem correct in comparison with the one of the original model of Smets&Wouters. In my case, the initial values of the observed variables are very significant in the explanation of the variance. Can you please have a look at it and tell me whether you find this situation is correct, that the variance of the initial value have such a big influence?
2. regarding the graphs of the apriori and, respectively, aposteriori distributions of the parameters from the model, as resulted from the attached Graph2-there is a big difference between the graph of the apriori distribution and the graph of the aposteriori distribution. This situation is not for all the parameters, I have attached you the ones with the higher differences. I am not sure that this is correctly, could this would mean that the observed variables bring additional information to the model?
3.regarding the convergence of Markov chain obtained, as resulted from Graph3, there are some problems of convergence. Do you have any suggestion for solving them? I have tried to increase the number of MCMC simulations, by using an mh_replic=250.000 (as resulted from the axis of graph 3).

Thanks a lot for all your understanding and support,

Have a nice evening,
Graph3.pdf (9.94 KB)
Graph2.pdf (6.41 KB)
Graph1.pdf (12.5 KB)

  1. In short samples, this is not uncommon. However, your data (the black line) looks weird.
  2. If the prior is updated, this suggests that the data is informative. Note that the shape of your posterior is still ugly. It should by asymptotically normal, suggesting that there are insufficient draws.
  3. Again, use more draws. There are more involved methods (e.g. the Chib/Ramamurthy algorith), but they are hard to implement.

Professor Jpfeifer,

Firstly, I want to thank your for all the help, I really appreciate all your support.

Regarding the use of both mode_compute-6 and, respectively, mode_compute=9, I have tried to use a combination of both of them, as you indicated.
I haves started with a mode_compute=6 in the estimation function:

estimation(datafile=db, xls_sheet=dbs, xls_range=A1:G56, first_obs=1, presample=4,lik_init=2,prefilter=0,mh_replic=350000, mh_nblocks=2,mh_jscale=0.30, mode_compute=6, smoother, mh_drop=0.5,tex,bayesian_irf);

Afterwards, I have introduced in the mode_compute=9 and the mode_file option in the estimation function, keeping the same name of the mode file:

estimation(datafile=db, xls_sheet=dbs,xls_range=A1:G56,first_obs=1, presample=4,lik_init=2,prefilter=0,mh_replic=350000, mh_nblocks=2,mh_jscale=0.30, mode_compute=9, mode_file=db_mode, mh_drop=0.5,tex,bayesian_irf);

The error message that occurred is described above. Do you have any suggestion for solve this error? Or maybe, there is something wrong in the way I introduce the mode_file option?

Many thanks!

The Output was the following:

Initial value of the log posterior (or likelihood): -589.8629
n=36: (7,14)-CMA-ES(w=[36 24 16 11 7 4 1]%, mu_eff=4.3) on function dsge_likelihood
Iterat, #Fevals: Function Value (median,worst) |Axis Ratio|idx:Min SD idx:Max SD
1 , 15 : 1.0000000000000e+08 +(1e-08,4e-08) | 1.03e+00 | 28:9.3e-05 12:9.4e-05
#Fevals: f(returned x) | bestever.f | stopflag
16: 1.00000000000e+08 | 5.89862895442e+02 | equalfunvals
mean solution: +3.0e+00 +5.6e-01 +2.9e+00 +6.2e-01 +2.3e-02 +1.6e-02 +3.0e+00 +9.2e-01 +9.0e-01 +9.9e-01 +9.7e-01 +8.7e-01 +7.1e-01 +4.4e-01 +6.7e-01 +6.8e-02 +6.9e+00 +2.8e-01 +4.4e-01 +3.4e-01 +5.6e+00 +9.5e-01 +6.0e-01 +6.6e-01 +7.9e-01 +1.7e+00 +1.0e+00 +9.8e-01 +1.7e-01 +9.6e-04 +7.0e-01 +5.1e-01 +5.2e+00 +5.1e-01 +1.5e+00 +3.7e-01
std deviation: 9.3e-05 9.4e-05 9.3e-05 9.3e-05 9.3e-05 9.3e-05 9.4e-05 9.4e-05 9.3e-05 9.3e-05 9.3e-05 9.4e-05 9.3e-05 9.3e-05 9.3e-05 9.4e-05 9.3e-05 9.4e-05 9.3e-05 9.4e-05 9.3e-05 9.4e-05 9.3e-05 9.3e-05 9.3e-05 9.3e-05 9.4e-05 9.3e-05 9.4e-05 9.3e-05 9.4e-05 9.4e-05 9.4e-05 9.3e-05 9.4e-05 9.4e-05
use plotcmaesdat.m for plotting the output at any time (option LogModulo must not be zero)

Objective function at mode: 100000000.000000

POSTERIOR KERNEL OPTIMIZATION PROBLEM!
(minus) the hessian matrix at the “mode” is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
Warning: The results below are most likely wrong!

In dynare_estimation_1 at 711
In dynare_estimation at 84
In db at 497
In dynare at 162
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.574083e-16.
In dynare_estimation_1 at 726
In dynare_estimation at 84
In db at 497
In dynare at 162

Log data density [Laplace approximation] is -714.040281.

Error using chol
Matrix must be positive definite.
Error in metropolis_hastings_initialization (line 68)
d = chol(vv);
Error in random_walk_metropolis_hastings (line 62)
ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d ] = …
Error in dynare_estimation_1 (line 799)
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation (line 84)
dynare_estimation_1(var_list,dname);
Error in azi2pol3_pol2final (line 497)
dynare_estimation(var_list_);
Error in dynare (line 162)
evalin(‘base’,fname) ;

That is strange and should not happen. Could you try again with the same mode-file? If the problem persists, please send me the mod-file, the data, and the mode-file.

Thanks a lot, Mr.Professor,

I have tried to run again the same algorithm and the error occurred.
I have attached you the mod file-SmetsWouters, where in the estimation function I have used the optimization function: mode_compute=6, without the mode_file function.
As a result, it was generated the mode file: SmetsWouters.mode, that I have tried to attached. I kindly ask you to tell me how to attach the mode file (as the message received when trying to attach it was that the extension mat is not allowed).
For the seven observed variables, please find attached the Excel document ** (MATA-incercare) **containing the seven quarterly time series for the period 2000q1:2013q4.
The same error occurred when I have tried to introduce the mode_file name and the mode_compute=9 function, as described in the Word document-Error-mode_compute=9.
Error-mode_compute=9.doc (209 KB)
MATA_incercare.xls (30 KB)
SmetsWouters.mod (6.52 KB)

1 Like

Just put everything into a zip-file and upload it. This allows to attach mat-files.

Hello again,

I have attached the zip containing the mode file.

Many thanks,

Have a nice day!
SmetsWouters_mode.zip (8.26 KB)

The run you uploaded looks better. What looked like a bug is gone there. It rather looks like a problem with your data. Your data looks completely different from the Smets/Wouters data and it does not look as if you adjusted the observation equations and the priors accordingly.

For example, SW2007 use the net quarterly interest rate multiplied by 100. You seem to use the simple gross annual interest rate.
Please have a look at the data description in the appendix of Smets/Wouters and Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf for more details.

Hello,

Can anyone help me with some indications regarding the attached variance decomposition graphs (graph 1 and graph 2)?
These doesn’t seem like being correct.
I have tried to demean the series of data and I have also checked that the shocks are white noises (around 0) but the results doesn’t improve.

Thanks a lot.
Graph2.pdf (144 KB)
Graph1.pdf (158 KB)

Look at the smoothed shock series to see whether they are roughly mean zero.

Yes, I have already checked this and they are around zero (white noises).

Can be another reason?

Thanks a lot

Then it’s hard to tell. Your graph can be correct. Do you have any reason to be suspicious about your results (apart from the fact that your scaling for y looks weird)?

Actually, all the other diagnostics seems ok.

Now, that you told me, I have took a new look at the smoothed shocks and I have attached them for each of the previous two decomposition graphs.

In case of the first graph, investment shocks, on that scale between -200 and 200 reaches -100 one time, at the very beginning

Also, wages shock reached -50, for a scale between -100 and respectively 100.

Should this also be the main cause?

Big thanks,
Smoothed shocks-graph 2.pdf (84.9 KB)
Smoothed shocks-graph 1.pdf (84.5 KB)

I don’t know your data. But my feeling is that you are treating some observables wrong. Why should they have a scale in the hundreds? Moreover, the shocks suggest the presence of a seasonal pattern. Have you made sure all your data is seasonally adjusted?

Dear Jpfeifer . I don’ t use the model of (Smets and Wouters) . The dynare 's version is 4.4.1 . In fact I have obtained the same message of error concerning 'strsplit 'which is

??? Undefined function or method ‘strsplit’
for input arguments of type ‘char’.

Error in ==> dynare_estimation_1 at 356
options_list =
strsplit(options_.optim_opt,’,’);

Error in ==> dynare_estimation at 84
dynare_estimation_1(var_list,dname);

Error in ==> article4 at 379
dynare_estimation(var_list_);

Error in ==> dynare at 174
evalin(‘base’,fname) ;

but when I try strsplit.m I obtain another error which is

??? Undefined function or method ‘Warning’ for
input arguments of type ‘char’.

Error in ==> dynare_estimation_1 at 388
Warning(‘gmhmaxlik:
Unknown option (’
options_list{2*(o-1)+1}
‘)!’])

Error in ==> dynare_estimation at 84
dynare_estimation_1(var_list,dname);

Error in ==> article4 at 379
dynare_estimation(var_list_);

Error in ==> dynare at 174
evalin(‘base’,fname) ;

Can you help me please? sorry for asking you many questions :frowning:
article4.mod (5.64 KB)

Please upgrade to 4.4.3. That should help.