Variance decomposition

Hello everybody!

For my master thesis I am trying to estimate a two-sector open economy DSGE model for Germany and the Rest of the Euro area following the theoretical framework of Ferrero et al. (2008). I brought the estimation to run and the irfs seem to have reasonable results, however when I try to compute conditional variance decompositions for production, consumption, trade balance and current account the following error messages show up:


Index exceeds matrix dimensions.

Error in dsge_simulated_theoretical_variance_decomposition (line 113)
Decomposition_array(linea,(i-1)*nexo+j) = tmp{2}(i,j);

Error in posterior_analysis>job (line 62)
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,‘posterior’);

Error in posterior_analysis (line 34)
oo_ = job(type,SampleSize,arg1,arg2,arg3,options_,M_,oo_);

Error in compute_moments_varendo (line 101)
oo_ =
posterior_analysis(‘decomposition’,var_list_(i,:),M_.exo_names(j,:),],options_,M_,oo_);

Error in dynare_estimation_1 (line 818)
oo_ = compute_moments_varendo(‘posterior’,options_,M_,oo_,var_list_);

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

Error in thesis_test2 (line 502)
dynare_estimation(var_list_);

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

Unfortunately I don’t know what problem the error messages indicate and how it can be solved in order to get valid variance decompositions.

Another issue I am having with the estimation is that the posterior distributions for some parameters fit the priors very poorly and seem to be concentrated far too narrowly around the posterior mean. Is this solely due to the fact that my model is relatively simple compared to more complex models like e.g. Quest or could this have another reason?

Help would be very much appreciated. Thanks in advance!

…here the data

Which Dynare version are you using? Could you please try the unstable version if it works there?
There is nothing that says a prior should look like the posterior. Quite the opposite. You want your data to be informative. It is only problematic when the posterior results make no economic sense.
A general tip: check your data and observation equation. could it be that there are still seasonal patterns in the data? And why is the variance of nx so much bigger than of every other variable? Is this a scaling issue?

Thank you very much for your response and help!

I am generally using version 4.4.3. I tried running the whole estimation with unstable versions 2016-03-19 and 2016-03-21 now but the estimation doesn’t work anymore at all and I get the following error messages:


Error using chol
Matrix must be positive definite.

Error in gmhmaxlik_core (line 194)
dd = transpose(chol(CovJump));

Error in gmhmaxlik (line 100)
[PostMode, PostVariance, Scale, PostMean] = gmhmaxlik_core(fun, OldPostMode, bounds,
gmhmaxlikOptions, Scale, flag, MeanPar, OldPostVariance, varargin{:});

Error in dynare_minimize_objective (line 250)
[opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function,
start_par_value, …

Error in dynare_estimation_1 (line 252)
[xparam1, fval, exitflag, hh, options_, Scale] =
dynare_minimize_objective(objective_function,xparam1,options_.mode_compute,options_,[bounds.lb
bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);

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

Error in thesis_test2 (line 511)
oo_recursive_=dynare_estimation(var_list_);

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

For connecting the data to the model I indexed all variables on the same scale (2010=1) and then I followed your paper of 2013 by taking logs and detrended by first difference. Finally I demeaned the data automatically through the estimation command. I also realized the much higher variance in nx but I followed the very same pattern as for all the other variables. So you think its a data related issue?

How do the mode_check plots look like?

The mode_check plots are attached to this message.

I now detrended all data by HP filter instead of taking first differences. I also deseasonalized the three series that haven’t been seasonally adjusted yet. However, these changes don’t solve the problem. One thing I realized is that I can get theoretical posterior moments and conditional variance decompositions for endogenous shock process variables like ah uh an un etc. but not for economically interesting endogenous variables like y c nx or ca. Do you have an idea why this is the case?

Thank you very much for your time and help!
plot4.pdf (3.13 KB)
plot3.pdf (10.6 KB)
plot2.pdf (10.6 KB)
plot1.pdf (10.4 KB)

Do not use the two-sided HP-filter for Bayesian estimation of DSGE models. See Pfeifer (2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.
Have you check identification in your model?
Not getting endogenous moments usually means there is a unit root in your model so that those unconditional moments are not finite.

But let’s step back for a moment: you said in a previous version you were able to run the estimation. Have you compared what the difference between versions is? Is there a notable difference in the density at the found mode?

Ok, I use a one-sided HP filter now and re-estimated the model. The results don’t seem to differ a lot from before.

My problem is actually “solved” now. I get variance decompositions for endogenous variables but ONLY if the posterior theoretical moments for shock process variables ah and an are also computed in the same estimation.

Actually there are unit roots in two of the structural equations, I guess that’s also the reason why I have to set the option lik_init=2 to get the estimation to run. To my knowledge identification is achieved. Is there a way to explicitely check for valid identification of the model in Dynare?

Generally the estimation only runs without error messages using Dynare version 4.4.3., but not if I use an unstable version.

You can use the identification command to check identification (unless you have correlated errors)

Dear Johannes,

Should “identification” command be added After estimation block?

estimation(....); identification; stoch_simul(...);

Kind regards,
Huan

In the unstable version, it should not matter. But usually you want to know about identification before running estimation. The usual way is to check identification first and then take the command out of the mod-file before running estimation. Note that if you run identification before an estimation-command, you need to sometimes provide options like

Dear Johannes,
I cannot find the data file (datafile=simulated_data_dynare_RBC_with_SS) in sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.
Only mod files are found. So would you mind helping me with the data file?
Thanks,
Bowen

The data was generated from the mod file. Use e.g.

stoch_simul(order=1,irf=20,periods=2000);
verbatim;
save simulated_data_dynare_RBC_with_SS c_tilde;
end;

OK, thank you very much