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.

1 Like

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.

post1
post2

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)
oo_=disp_moments(ys,var_list,M_,options_,oo_);

Error in execute_prior_posterior_function (line 90)
junk=functionhandle(parameter_mat(1,:),M_,options_,oo_,estim_params_,bayestopt_,dataset_,dataset_info);

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)

PS:
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)

Use
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)
posterior_steady_states=cell2mat(oo_.posterior_function_results(:,2));

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:

output_cell{1,1}=oo_.autocorr

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:

Hi, Professor

Currently I tried to use the posterior_function_demo.m file for another project and it did not work and checked with the one posted here which worked well that time. But it is not working now.

Attaching again
tu_dat.xlsx (17.6 KB)
test.mod (11.9 KB)
posterior_function_demo.m (3.5 KB)
the only change is now I am using dynare 6.0 then I used older version.

Is it because of dynare versions or something else?
Could you please help?

the error is like

EXECUTE_POSTERIOR_FUNCTION: Execution of prior/posterior function led to an error. Execution cancelled.
Error using set_state_space
Too many input arguments.
Error in posterior_function_demo (line 62)
oo_.dr=set_state_space(oo_.dr,M_,options_);
Error in execute_prior_posterior_function (line 91)
junk = functionhandle(parameter_mat(:,1), M_, options_, oo_, estim_params_, bayestopt_, dataset_, dataset_info);
Error in test.driver (line 919)
oo_ = execute_prior_posterior_function(‘posterior_function_demo’, M_, options_, oo_, estim_params_, bayestopt_, dataset_, dataset_info, ‘posterior’);
Error in dynare (line 310)
evalin(‘base’,[fname ‘.driver’]);

In Dynare 6, we eliminated passing various global variables. As a consequence, the interface for many functions has changed. Use
posterior_function_demo.m (3.5 KB)

1 Like

Thank you very much . I do appreciate your time and effort

Now it is working, but oo_.posterior_function_results(:,1) is displaying of 500x1 NaNs
I expected it will be 500x8 with some value.

Can you provide your _mode.mat-file?

Sorry for the late response.
Sure, attached is _mode.mat file
test_mode.mat (12.5 KB)

When I run your code, I need to set

    options_.qz_criterium = 1-1e-6;

instead of the usual

    options_.qz_criterium = 1+1e-6;

It seems there is an issue with the parameter estimates being at the boundary of the stability region.