Linking SGU toolkit resolution to Dynare for GMM calibration

Hello Dynare users,

I am currently reproducing the paper by Horvath and Yang (2021), “Unemployment Dynamics and Informality in Small Open Economies”. Their model is solved using the Schmitt-Grohe Uribe (SGU) toolkit, which uses perturbation methods to find the model solution around the steady state. Please find attached the replication files for the Horvath and Yang paper.

The model equations are specified in base_model.m, which calls the anal_deriv.m and anal_deriv_print2f.m functions. Running base_model produces base_num_eval.m, which contains the symbolic log-linear approximation to the function f, defining the system of model equations. Model steady state is laid out in ‘base_ss’ to run next to have ss parameters values. Finally, the model is solved, and the moments and impulse responses are computed in base_run.m calling the gx_hx.m, mom.m, and ir.m functions.

My problem is with attempting to calibrate some parameters using the method of moments. Usually, for calibration, I use Dynare 5.0. I had a DSGE model in a .mod file and used Willi Mutschler’s code to perform the method of moments to select the parameters to calibrate according to the moments to match. Here, using the SGU toolkit, I manage to obtain the moments of interest in an Excel file (variance, covariance, and serial correlations), but I have no idea how to implement the method of moments since I no longer use a .mod file.

Hence, my questions are:

  1. Is there a way to link the results of the DSGE model resolution by SGU toolkit to Dynare and then apply Willi Mutschler’s MoM code?
  2. If not, would you have any resources to direct me to create my own code? I’m thinking of something like [X, fval, exitflag] = fminsearch(fun, x0, options) where X(1), ..., X(N) would be the parameters to calibrate that minimize the objective function fun = sum((model_moments_val - empirical_moments).^2)`?
    anal_deriv.m (2.2 KB)
    anal_deriv_print2f.m (5.0 KB)
    base_model.m (7.5 KB)
    base_num_eval.m (18.6 KB)
    base_run.m (3.4 KB)
    base_ss.m (5.0 KB)
    gx_hx.m (2.2 KB)
    ir.m (671 Bytes)
    mom.m (1.4 KB)

Thank you very much for your help.

I think there are basically two ways to proceed:

  1. Port the full model to Dynare. That is cumbersome but straightforward, given the similarities in the necessary coding.
  2. Check out Martin Uribe’s published work. He has published papers using GMM. Maybe there are some replication files.

Hi Johannes,

Sorry for my late reply, and thank you very much for your feedback.

I will look into Mr. Uribe’s replication files to see how GMM is used for calibration. However, I have a question regarding the first option. I am considering porting the full model to Dynare. Since the model resolution in the paper by Horvath and Yang (2021) involves log-linearizing around the steady state (following the approach of Schmitt-Grohé and Uribe (2004), “Solving dynamic general equilibrium models using a second-order approximation to the policy function”), should I log-linearize the entire model to write it in Dynare using the model(linear) block?

For instance, should an equation defining the output “y_t = k_t^\alpha l_t^(1-\alpha)” be log-linearized before writing it in the model(linear) block?

I just want to confirm that solving by log-linearization with SGU implies that the entire model needs to be log-linearized when porting it to Dynare.

Thank you for your help.

No, you can simply port the existing first order conditions from the base_model.m to Dynare.

Ok, so I ported the full model to Dynare. The .mod file is attached. The fact is that when I compute the .mod file I get that error message :
There are 9 eigenvalue(s) larger than 1 in modulus
for 10 forward-looking variable(s)

The rank condition ISN’T verified!

Error using print_info
Blanchard & Kahn conditions are not satisfied:
indeterminacy.

Error in stoch_simul (line 120)
print_info(info, options_.noprint, options_);

Error in SGU_test.driver (line 491)
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list_);

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

There are many discussions in the forum dealing with that kind of error so I looked for any timing considerations but I can’t find where the problem is since I follow the paper and the equations authors wrote for the SGU solution.

Can you tell me where I did worng please ?
SGU_test.mod (9.6 KB)

Thank you for you rhelp.

I think you are missing

predetermined_variables nnf;

Indeed, when declaring nnf as a predetermined variable, I successfully ran my .mod file. I can now use the MoM file to calibrate parameters.

Thank you very much for your help. Much appreciated.

Hello Professor,

I have another question regarding my model. I’m using the method of moments (MOM hereafter) to calibrate five parameters with Willi Mutschler’s code. After MOM, I obtain the values of the calibrated parameters and an estimate of the moments that I try to match according to these new values that Dynare offers. These values seem to be in agreement with the literature.

However, since I cannot perform sensitivity analyses directly from the “mom” file, I therefore recreated the MOM model file (“mom”) as a new “.mod” file, incorporating the newly calibrated parameter values. When I run stoch_simul on the “.mod” file, the resulting moments are significantly different. For instance, in the “mom” file, the calibration results in a GDP variance of 0.0007585, which is close to the observed data variance. On the other hand, the “.mod” file produces a GDP variance of 0.002633 after stoch_simul. I’m unsure why there’s such a large discrepancy. Am I looking at the correct information? Is there a specific command I should be using? How can I manage to get variance without stoch_simul ? I fear the stochastic shocks may be the problem.

For reference, the empirical data are in logs and HP filtered (see attached .mat file). The model is based on the files discussed earlier in our conversation, specifically a second-order log-linearization around the steady state. The attached files include:

  • The .mat file containing the cyclical components of the variables of interest.
  • The “mom” file where I perform mom for calibration.
  • The “.mod” file replicating the “mom” file with the calibrated parameter values.

Thank you in advance for your help.

SGU_test2.mod (12.8 KB)
MoM_SGU2.inc (12.1 KB)
MoM_SGU2.mod (8.7 KB)
SGU_HPfilterninf2.mat (3.6 KB)

You did not provide the necessary helper file. But why are you comparing theoretical to simulated moments? And how did you make sure you are correctly comparing variances and not uncentered moments from GMM to centered second moments in stoch_simul?

Oh I’m sorry I forget the helper. Please find it attached.
I thought that in matched moments, y*y gave me the variance for the variable y for example. So to me, I could then directly compare this variance obtained after GMM with the variance in the diagonal elements of the oo_.var matrix of the stoch simul. But I didn’t have in mind that I was comparing uncentered moments with centered moments.

In this case, how can I make sure that I reproduce the same uncentered moments in a mod file without going through a GMM? The idea is that I want to do a sensitivity analysis by modifying the value of some parameters taken from literature. My concern is that if I have to go through the GMM each time, I modify my calibration results because I change the values ​​of other parameters for the sensitivity analysis.
So I want to create a mod file that can give me the same uncentered moments as GMM where I have calibration obtained through GMM, and just change other parameters value to go through my sensitivity analysis.
SGU_test2_steadystate_helper.m (1.6 KB)

I would simply compute the uncentered moments using the standard formula
E(x^2)=Var(x)+[E(x)]^2
Hence:

stoch_simul(order = 2,irf=0,nograph,periods=0,pruning);
y_pos=strmatch('yf',M_.endo_names,'exact');
y_2_mom=oo_.var(y_pos)+oo_.mean(y_pos)^2;