Simult_ attempt

Hi.
I am trying to do some stochastic simulation and first of all I want to be sure that I understand the process. So, I would like to replicate the smoothed variable using the simult_ command.
Based on [Simulate a model using smoothed shocks] and [Choosing initial values for simult_], I ran the below code:

y0=;
SmoothedVars=;
for endo_iter=1:M_.endo_nbr
field=string(deblank(M_.endo_names(endo_iter,:)));
var=getfield(oo_.SmoothedVariables,field);
SmoothedVars=[SmoothedVars;var’];
y0 = [y0; var(1)];
end;

%Update decision rules
[oo_.dr,info,M_,options_] = resol(0,M_,options_,oo_);

%Get shocks
ex_=;
for shock_iter=1:M_.exo_nbr
field=string(deblank(M_.exo_names(shock_iter,:)));
ex_=[ex_ getfield(oo_.SmoothedShocks,field)];
end
ex_= ex_(2:end,:);

% Simulation
y_=simult_(M_,options_,y0,oo_.dr,ex_,iorder);

The results are close to the smoothed variables but not the same. Some more questions:

  1. I do not understand what is happening in “updating decision rules”. Actually, it seems they are already updated in my case.
  2. In the links above there are some references to oo_.SmoothedShocks.Mean, oo_.SmoothedVariables.Median and oo_.SmoothedVariables.Mean, but I have found only oo_.SmoothedShocks and oo_.SmoothedVariables. Is it a problem or just a change in Dynare?

Would you help me, please?

Btw, happy new year!
Files.zip (191.3 KB)

The current link should be

Did you follow it?

Thanks for your answer, professor Pfeifer.
I was not using the “smoother” option. That is why the SmoothedShocks.Mean and the other options were not triggered as I said in 2).
That is still a difference though, but I suppose it is normal since in the code that you refer there is a:

max(abs(y_(strmatch(‘gy_obs’,M_.endo_names,‘exact’),:)'-oo_.SmoothedVariables.gy_obs))>1e-10 ||…

On the another code fs2000.mod in the same folder, for Bayesian inference we have a larger interval to consider a variable the same:

if mean(abs(y_(strmatch(‘gy_obs’,M_.endo_names,‘exact’),:)‘-(gy_obs(1:options_.nobs))))>1e-3 ||…
mean(abs(y_(strmatch(‘gy_obs’,M_.endo_names,‘exact’),:)’-oo_.SmoothedVariables.Mean.gy_obs))>1e-3 ||…
mean(abs(y_(strmatch(‘gp_obs’,M_.endo_names,‘exact’),:)‘-(gp_obs(1:options_.nobs))))>1e-1 ||…
mean(abs(y_(strmatch(‘gp_obs’,M_.endo_names,‘exact’),:)’-oo_.SmoothedVariables.Mean.gp_obs))>1e-2
error(‘Smoother is wrong’)
end

So, my question is, it is possible to determine a general rule that assure us that the Smoother is correct? For example, in this code above, there is 1e-3, 1e-1, 1e-2 as rule, but I was wondering if these values are related to the type of variable, so I can use 1e-3 for a specific group of variables and 1e-2 for another and so on. I thing it is not easy to find a rule like that, but just to confirm.

Thank you again.

And just a friendly reminder, in the link that you sent me the simult_ function was called like this

simult_(y0,dr,ex_,iorder)

however, in the version that I am using (4.6.3), the simult_ has more arguments:

(Just in case some people have the same questions that I had).

Thank you

  1. For ML it is simply numerical error. For Bayesian estimation, it is more complicated. The problem is that we output the mean smoothed object across parameters. The exact decomposition holds for a given parameter draw. But it does not hold for an average (Jensen’s Inequality)
  2. As it says in the linked post, it’s for Dynare 4.5. The one for Dynare 4.6 is right in post before that.
  1. This means that the confractual depends on the whole distribution of the parameters, right? Would you please suggest me some link with a sketch of this procedure or something similar?

  2. Thank you for point that. It was my mistake.

  3. Related to this topic, I tried to do an exercise:

I) I estimated a model. Then I used simult_ to get a estimate of Smoothed Variables.

II) Using the same mean (or mode) that I obtained from the previous estimation, I run another model (with no estimation, I just calibrate the model with those values).

III) I used simult_ with the second model and the shocks of the first model to get a second estimate of Smoothed Variables.

I found that the first estimate of the smoothed variables is not equal to the second (that is why I believe the simult_ depends on the whole distribution).
Hence, I would like to know if there is a way to make the second simult achieve the same result as the first one. If there is no way, which one do you suggest to use as a base case scenario (or actual) variable: the result in simult_ in I), the result in simult in II) or even Smoothed Variables?
My concern is not to introduce an additional error in contrafactual exercises.

Thank you again!

A counterfactual needs to be conducted for one set of parameters. The underlying issue is Jensen’s Inequality. The same happens for IRFs. See

Thank you, professor Pfeifer. I think I understand it now.