Smets/Wouters (2007) in Dynare 4.2.5

Attached is a version of the Smets/Wouter (2007) model for Dynare 4.2.5. Due to a bug in Dynare 4.2.5 you need to replace the file matlab\distributions\inverse_gamma_specification.m with the attached one.

Note that this is an adapted version that fixes the problem discussed in [Syntax shock_decomposition). As this is a user-provided code that adapted the original Dynare 3 Smets/Wouters code from the AER homepage to Dynare 4 there is no guarantee for correctness. At first sight, the decision rules seem to be the same as in the original code. Nevertheless, please be careful. Any additional insights into the correctness of the provided code are appreciated. When looking into the correctness of the code, note that a different mode-file is used than in the AER-hompage benchmark case. The benchmark mode-file is also attached.
usmodel_mode.zip (7.94 KB)
Smets_Wouters_2007_Dynare425.zip (22.2 KB)
inverse_gamma_specification.m (5.14 KB)

1 Like

thanks for sharing but i got message"You did not declare endogenous variables after the estimation command.
This version of Dynare cannot estimate non linearized models!
Set “order” equal to 1."

moreover I posted question about taking data to model in dynare, nobody replied yet, could you please help me with that.

Regards

These are only warnings to show that Dynare default options are used - which is fine in this case. They are no error messages.

thanks.

[quote=“jpfeifer”]Attached is a version of the Smets/Wouter (2007) model for Dynare 4.2.5. Due to a bug in Dynare 4.2.5 you need to replace the file matlab\distributions\inverse_gamma_specification.m with the attached one.

Note that this is an adapted version that fixes the problem discussed in [Syntax shock_decomposition). As this is a user-provided code that adapted the original Dynare 3 Smets/Wouters code from the AER homepage to Dynare 4 there is no guarantee for correctness. At first sight, the decision rules seem to be the same as in the original code. Nevertheless, please be careful. Any additional insights into the correctness of the provided code are appreciated. When looking into the correctness of the code, note that a different mode-file is used than in the AER-hompage benchmark case. The benchmark mode-file is also attached.[/quote]

Thank you very much for your sharing!

Why does permuting the lines

and

in usmodel_shock_decomp.mod result in the following error?:

Error in computing likelihood for initial parameter values
Error using print_info (line 71)
one (many) parameter(s) do(es) not satisfy the lower bound

Error in initial_estimation_checks (line 69)
print_info(info, DynareOptions.noprint)

Error in dynare_estimation_1 (line 169)
oo_ =
initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);

Error in dynare_estimation (line 70)
dynare_estimation_1(var_list,dname);

Error in usmodel_shock_decomp (line 418)
dynare_estimation(var_list_);

Error in dynare (line 120)
evalin(‘base’,fname) ;

Because you are loading a mode-file derived from a different specification. Dynare does not know that you changed the parameter ordering when you load the mode-file from the previous run.

Hi, I was following the modifications as the attached file. However, the error on “#usmodel_stst;” seems have not be fixed. Have I missed something? Or what should I modify the code in “usmodel.mod”(attached) to modify the following error:*
ERROR: usmodel.mod:80.14: syntax error, unexpected ‘;’, expecting EQUAL*

Thanks

H
usmodel.mod (12 KB)

Anyone who can give some suggestion??

[quote=“HouseC”]Hi, I was following the modifications as the attached file. However, the error on “#usmodel_stst;” seems have not be fixed. Have I missed something? Or what should I modify the code in “usmodel.mod”(attached) to modify the following error:*
ERROR: usmodel.mod:80.14: syntax error, unexpected ‘;’, expecting EQUAL*

Thanks

H[/quote]

My posted file clearly shows that it must be

@#include "usmodel_stst.mod"
and not

#usmodel_stst;

1 Like

Hi,
I am trying to run the code in Dynare 4.4.x but I am getting the error below. It seems odd because the same code runs smoothly in Dynare 4.3.3. I wonder whether this is a bug in Dynare 4.4.
Any help greatly appreciated.

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

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

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

Error in ==> usmodel at 504
dynare_estimation(var_list_);

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

It’s a version problem. strsplit is a new Matlab function. Try using the one at mathworks.com/matlabcentral/fileexchange/21710-string-toolkits/content/strings/strsplit.m

It does help. Thank you very much!

Hello!
I tried to run the code for the model of Smets/Wouters (2007) in Dynare 4.40 and the following error occured:
*.mod not found.
Error using dynare (line 117)
dynare:: can’t open inverse_gamma_specification.mod
Is that a compatibility problem caused by the version of Dynare used?

Thank you very much for your support,

Alina

The file you need to call is usmodel.mod. For 4.4 you don’t need the inverse_gamma_specification-file. That is, use

not

Thank you for your answer. I have tried to run in Mathlab the us_model file too, by writing dynare us_model, as suggested, but the result was similar, as described bellow:
*.mod not found.
Error using dynare (line 117)
dynare:: can’t open us_model.mod
Can you, please, help me with a suggestion regarding the cause of the occurred error?

Thank you very much!

There is no us_model.mod, only a usmodel_shock_decomp. It must be

Hello!
Thank you very much for the explanation, it works.

Alina,

Hello everyone!

I have a question regarding the way to calibrate the parameters in Smets&Wouters (2007) DSGE model.
I have tried to apply the mod file, by using the observable variables from my country’s economy. As a result, the initial values of the parameters should be changed.
The error that occurred in Dynare was the one described above.
Can you, please, help me, by telling me how can I choose the initial values of parameters, taking into account the error message from Dynare 4.4.0?

Thanks a lot for your support and have a nice day!

Description of error occurred in Dynare
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 eu71 at 504
In dynare at 162

It seems you require extended runs of mode_compute=6 or 9 or even an extended combination of the two. But foremost, make sure your data matches the model, i.e. is in the right form for the observation equation including potential demeaning and seasonal adjustment.