Simulation with real data

Yes, oil revenue of the government increased drastically due to start of the contracts. It is very volatile during the entire period.

RA

Then you should try a higher order approximation. But more generally, a global solution technique may be more appropriate in this case.

1 Like

Thank you @jpfeifer, 4th order approximation delivers shocks close to the real data.

In my model, the economy experiences unexpected oil revenue shocks, i.e. each period the economic agents believe that the shock is permanent. Does it imply that I cannot use stoch_simul in this situation?

RA

With a prespecified shock sequence, that should still work.

Am I getting it correctly?

When I exclude the “shocks” block (or set the variance to zero) and use “simult_” to simulate with real data, the agents do not expect any shock and accept each one as permanent shock when they arrive.

Here is my code: StEx3.mod (5.0 KB)

RA

  1.  X = simult_(M_,options_,initial_condition_states,oo_.dr,shock_matrix,1);
    
    means you are still using a first order approximation. Use
    X = simult_(M_,options_,initial_condition_states,oo_.dr,shock_matrix,options_.order);
    
  2. At higher order, certainty equivalence does not hold. For that reason, setting the shock variance to 0 will affect the solution of the model.
  1. Both lines yield the same results. I am using a fourth order approximation in ‘stoch_simul’:

stoch_simul(irf=15, order=4, nograph)

  1. Yes, I am getting different results when the shock variance is set to 0. I am still confused: why do I need shock variance when I have a prespecified shock sequence and I need them to arrive unexpectedly?
  1. The reason is a bug. See simult_.m: simulate user-requested order with k_order_solver (!1914) · Merge requests · Dynare / dynare · GitLab
  2. The shock variance is relevant for how agents behave in response to occurring shocks. If there is a large variance, agents will for example have a very strong precautionary motive.

Thank you @jpfeifer.

  1. Now I am not getting any results when the order of approximation is larger than 2. Struggling to figure out a solution when the actual shocks are huge.
  2. Does this mean that when I set the shock variance to zero, agents do not expect any shock after each one arrives?
  1. For a given shock sequence that is strange. With random shocks, you may need pruning.
  2. Yes.
1 Like

Unfortunately, In Dynare, the pruning approach is implemented for second and third order approximations. I need fourth or fifth order to get shock values close to real data.

That is true, although we are working on it.

1 Like

@jpfeifer, would it be correct to use a deterministic case to overcome this difficulty? I mean, compute steady states for each shock value, use them as initial and terminal values, pick up the first period in each transition and put them together as a sequence?

  1. Please provide the most recent version of the codes. I would like to see what is going on.
  2. If you are not interested in precautionary behavior, you could model the problem as a sequence of surprise shocks. But that is tricky to do. See the discussion here: MIT shocks in deterministic environment - #3 by jpfeifer
  1. Here is my latest code:
    StEx3.mod (5.0 KB)

  2. I’ve come across this discussion before. As you said, a deterministic setup assumes perfect foresight. In my case, I need shocks to be unexpected in each period.

  1. That file generates results without pruning, so where is the problem? You wrote above

StEx3.mod (5.0 KB)
2. Yes, but the post MIT shocks in deterministic environment - #4 by ghazika1 outlines the right idea to use a sequence of perfect foresight problems.

  1. The output matrix X is empty.
  2. Thank you, these discussions are indeed useful.

In Dynare 4.6.4 X is not empty with the file I posted.

Your version of my code StEx3.mod (5.0 KB) produces the following error when I am using an updated simult_m (where you’ve fixed a bug):

Error using -
Arrays have incompatible sizes for this operation.

Error in StEx4.driver (line 348)
M_IRF = X(:,M_.maximum_lag+1:end)-repmat(oo_.dr.ys,1,options_.irf);

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

However, the previous version of simult_m (from the original Dynare package) runs smoothly. Am I missing something?

Please try the most recent unstable version.