How to generate certain paths of endogenous variable under perfect foresight simulation

Hello everyone,

In this exercise, I am interested in making sure endogenous variable “a” to be 1 throughout 40 quarter period under perfect foresight simulation. I use

initval;
a=1;
end;

endval;
a=1;
end;

and later use

perfect_foresight_setup(periods=100);
perfect_foresight_solver(maxit=1000,stack_solve_algo=7,solve_algo=0);

Is it possible to have a var a =1 throughout 40 quarter?
example1.mod (1.7 KB)

Thanks,
Amina

You cannot fix an endogenous variables, only exogenous ones. Of course, you can try to find a shock path that makes an endogenous constant, e.g. https://github.com/JohannesPfeifer/DSGE_mod/tree/master/NK_linear_forward_guidance

Thank you for your reply and example!

Why do you have two

perfect_foresight_setup(periods=100);

in the code? Is distance.m file important to find a shock path to make endogenous variables constant?

I used your code as an example and got this error message from using distance.m

oo_ = perfect_foresight_solver_core(M_,options_,oo_);
Index in position 2 exceeds array bounds.

Error in sim1 (line 40)
y0 = endogenousvariables(:, M.maximum_lag);

Error in perfect_foresight_solver_core (line 102)
sim1(oo_.endo_simul, oo_.exo_simul, oo_.steady_state, M_, options_);

  1. The first call sets up the structure for doing the distance minimization. The second call is for conducting the actual simulation after that.
  2. Without the full codes it is impossible to tell.

This is a very helpful function, thanks so much for sharing this!

I have taken a first glance at the function, and was wondering wether it is possible (and practical in the sense that it is reasonable to expect the program to work numerically) to extend the function such that it takes a vector of shocks and endogenous variables with one-to-one mapping into account (i.e., when one has a one-to-one mapping of shock to endogenous variable in mind)?

Plus, is it correct that there is currently no such function available (which I simply haven’t found)?

Best regards
Johannes

Yes, that should be feasible. But I guess you mean a matrix, not a vector. The above function already works with a vector where the second dimension is the time of the shock.
But what exactly do you have in mind? Without perfect foresight you could use the conditional_forecast to achieve something like this.

Thanks for your quick reply! Indeed, in your example it is a matrix of shocks (I toyed around a bit and used the function in the context of a larger model and specified it using one period only, hence the confusion of matrix and vector - sorry for that).

In mind I have an adjustment such that the function works like the conditional_forecast function, but in the context of the nonlinear model (since as far as I know, conditional_forecast works only for the perturbation solution).

The questions to be answered would surround e.g. structural change induced by certain exogenously specified policy measures, or investigating the rate of technical change that is necessary to induce certain relative price changes over a longer horizon (long enough such that I wouldn’t want to use the linearized model)

I don’t see why what you describe should cause particular issues. The basic logic of the code should still apply.