Mismatch between second order moments of estimation and actual data

Hi, I have been doing Bayesian estimation of linear DSGE model and second order moments are being much higher than that of actual data.What could be the reason ?

I have searched similar topics what I found was using endogenous prior command in estimation. But that did not work saying it is not supported with non-stationary models. The model includes variables in level.

Attached is the code of the model.

Thank you in advance, any help or advise is highly appreciated.:slightly_smiling_face:
estimation.txt (9.7 KB)

There is not much you can do here. In-sample shocks will always correlated, while theoretical moments are based on orthogonal shocks. Theory would tell you the different volatility in-sample was just due to chance. In practice, this may be a sign of model misspecification.

Thank you, professor

Actually, what I did first was using estimated parameters and simulating by (stoch_simul(order = 1,irf=20, nograph)) for matching second order moments(S.D and auotocorrelation) of the model and the actual data.

After your advise I have covered two other posts in dynare regarding matching second moments after Bayesian estimation which is very relevant to what I want.


I have been following that posts but always having error like:
EXECUTE_POSTERIOR_FUNCTION: Execution of prior/posterior function led to an error. Execution cancelled.
Brace indexing is not supported for variables of this type.

Error in disp_moments (line 41)
i_tmp = strmatch(var_list{i}, M_.endo_names, ‘exact’);

Error in posterior_function_demo (line 71)

Error in execute_prior_posterior_function (line 90)

Error in test.driver (line 469)
oo_ = execute_prior_posterior_function(‘posterior_function_demo’, M_, options_, oo_, estim_params_, bayestopt_, dataset_, dataset_info, ‘posterior’);

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

Could please, advise ?

test.mod (11.9 KB)
posterior_function_demo.m (4.2 KB)

In the paper that I am trying to replicate says:

For each parameter draw obtained with the MCMC chains we simulate 500 samples of length equal to the data after
discarding the first 50 observations

I think it is using posterior_functin as well…

Thank you in advance

The data file is missing. Are you using Dynare 5.2?

Attached is the data file. Yes, I am using Dynare 5.2.
tu_dat.xlsx (17.6 KB)

posterior_function_demo.m (3.8 KB)

Thank you very much, professor

I will try the file

I tried this posterior function demo file without changing anything and abover error is solved but, it is giving another error like:

Index in position 2 exceeds array bounds. Index must not exceed 1.

Error in test.driver (line 471)

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

What could be reason?

You only requested one output within the function. You cannot try to access oo_.posterior_function_results(:,2). Only oo_.posterior_function_results(:,1) should exist.

Dear professor, I appreciate your time and help. Error is fixed.

Let me ask 3 more questions, please

  1. From above mentioned two posts it was supposed to get 500x8 matrix for the oo_.posterior_function_results(:,1)

But unfortunately what I got is empty cell of 500x1 :

{0×0 double}
{0×0 double}
{0×0 double}
  1. I need standard deviation and autocorrelation for comparing with the ones of actual data. Is it true if modify posterior function demo file as follows:

2.1 For getting variance:

output_cell{1,1}=oo_.gamma_y; or output_cell{1,1}=oo_.var ?

2.2 For autocorrelation:


ps: output_cell{1,1}=mean(xparam1); is this part also subject to modification accordingly?

  1. Should I use the same MH draws for differet results(like for autocorr, variance, mean) or run an new for each?

Thank you in advance

My mistake. Try posterior_function_demo.m (3.5 KB)

Thank you , professor.

It is working well :slightly_smiling_face: