Stochastic variable in simul

I want to simulate a negative TFP shock in a model where some variables display a kink at their SS value, therefore I rely on the simul method instead of stoch_simul. How can I add stochastic shock in simul ? I tried adding a varexo and specifying period 1, value = ? how can I specify that the value should a random draw in some distribution ? (as in the stoch-simul case ?) I tried imposing value = 0.01 but I get that the error increases at each iteration.
If it can help, the original issue is an OCB where I can anticipate that the constraint will never be binding in SS and period 1, then always binding until getting back to SS.

Perfect foresight implies that all shocks are known. Of course, for the shock at period 1, there is no time to anticipate it. The problem you are facing seems more related to the general solution approach. Did you correctly specifcy initial and terminal conditions?

I use SS values for initial conditions and don’t specify explicit end values, so from what I understood Dynare considers the model goes back to the initial conditions.
I use the following specifications for the shock:
var E_A;
periods 1;
values 0.0105;
then the error is worth exactly 0.0105 in the first iteration and then increases.
I also tried the following:
var E_A = sigma^2 where sigma is a parameter (as would be done in a stoch_simul).
Then I don’t get any error, the files run but nothing happens in the simulated series.
Thanks for you help !

Is your model BK stable?

Yes, in the version that runs the BK conditions are ok (5 eigenvalues larger than 1 for 5 forward-looking conditions).

I would need to see the problematic file

So here is the file that runs fine: model_simul.mod (2.9 KB)

And what I tried to to, as you will see in the commands that were commented out, is to introduce a variable taking random values out of a specified distribution (as in a stoch-simul) to build my irfs by hand (because I have a kink, I can’t derive proper results with stoch_simul).

Sorry, but what is the problem with the file?
I get


Iter: 1,	 err. = 5.5511e-17, 	 time = 0.125

Total time of simulation: 0.132

Perfect foresight solution found.

Sorry, I was not clear, this is my “baseline file” that is working, indeed. Now I try to add a random shock in period 1 (surprise shock). That is when it does not work anymore, as in this file: model_simul.mod (2.9 KB)
Where I get this :

Iter: 1, err. = 0.01, time = 0.34457
Iter: 2, err. = 1.4376, time = 5.321
Last iteration provided complex number for the following variables:
Iter: 3, err. = 0.27655, time = 4.6791
Last iteration provided complex number for the following variables:
Iter: 4, err. = 1.0825, time = 4.6772
Last iteration provided complex number for the following variables:
Iter: 5, err. = 7.3086, time = 142.2695
Last iteration provided complex number for the following variables:

Thanks for your help,

Did you find a solution? It seems that I have the same problem. The perfect foresight solver is able to find a solution, however as soon as implement a shock, I have the issue 'Last iteration provided complex number for the following variables"…

How do you set the terminal condition? Sometimes there is only one valid terminal value consistent with a stable solution. Put differently, do you know that the system will converge back to the old steady state? Or do you have a unit root?

Sorry I didn’t post the mod file (for_dyr1.mod (3.8 KB)
)… So I have solved analytically the steady state. I’m starting from an initial steady state, with an exogenous tax different from zero. And I have tried to use both the endval option and a temporary shock, by varying the level of the tax, but in both case Dynare failed to solve the model. However, if I play with the initial value of the tax, by varying it, Dynare finds the steady state. Does that means that the steady state is unstable? If I have clearly understood, if the shock is temporary, the system should go back to the initial steady state. It seems that it is not my case. Thus what should I have to do now, in order to be sure that the system converge? I mean when we build a model, we write the Lagrangian, then the FOC, we stationnarize the model in case of deterministic trend, we need as many equations as variables, we solve for the SS, etc. But what are the next steps? What do we have to focus on, to be sure that the system will converge.

Your model displays a singularity problems as shown by model_diagnostics. That should explain why the dynamics do not work.

Thanks for your prompt answer. A singularity problem or colinearity problem means that an equation is redundant, and consequently one equation is missing. But how is it possible? I mean, when I’m building the model, I have the exact number of equations, I don’t understand how I can add an equation and missing one. Can the problem come from equation manipulations? Indeed, according to Dynare, equation 7 ( E_{gt}=(\omega e_{rt}^\varphi+(1-\omega)e_{ct}^{\varphi})^{\frac{1}{\varphi}} , the aggregated CES function for energy demand), equation 8 (e_{r,t}=\Big(\frac{\omega P_{E,t}}{P_{r,t}}\Big)^{\frac{1}{1-\varphi}}E_{g,t}, optimal condition for energy demand in the 1st intermediate sector), equation 9 (e_{c,t}=\Big(\frac{(1-\omega )P_{E,t}}{(1+\tau_{c,t)}P_{c,t}}\Big)^{\frac{1}{1-\varphi}}E_{g,t} optimal condition for energy demand in the 2nd intermediate sector) and equation 14 ( P_{E,t}=\Big(\omega^{\frac{1}{1-\varphi}}P_{r,t}^{\frac{\varphi}{\varphi-1}}+(1-\omega)^{\frac{1}{1-\varphi}}\Big[(1+\tau_{c,t})P_{c,t}\Big]^{\frac{\varphi}{\varphi-1}}\Big)^{\frac{\varphi-1}{\varphi}}, the index price for energy), are colinear. I have derived this condition assuming that the markets for energies are clearing. The demand for energy (P_{E,t}E_{g,t}) is equal to the energy supply, P_{r,t}e_{r,t} and (1+\tau_{c,t})P_{c,t}e_{ct}, so that: P_{E,t}E_{g,t}=P_{r,t}e_{r,t}+(1+\tau_{c,t})P_{c,t}e_{ct}. To find the energy price index (equation 14, similar to the one in Acemoglu et al. (2012) AABH), I have replaced the demand for energy in each sector (equation 8 and 9) in this market clearing condition. Do you think that explain why there is a colinear relation? In that case, I should replace equation 14 by the market clearing condition right?

I have replaced, the energy price index, by the market clearing condition (for_dyr11.mod (3.8 KB))
, but the problem of colinearity between the same equations remains… I really do not understand how to fix it

Often this is because of Walras Law. If N-1 markets clear, the last one does as well. Because of this, the last market clearing condition is redundant. The tricky part is to find the equation that is missing.

Ok, I’ve got the idea. But are you saying that the missing equation is another market clearing condition? In the model, there’s one market clearing condition for labour market L_t=L_{g,t}+L_{c,t}+L_{r,t},another for the overall feasibility constraint (G_t=C_t+I_t), the household budget constraint (r_tk_{t-1}+W_tL_t=C_t+I_T+T_t), market clearing condition for energy P_{E,t}E_{g,t}=P_{r,t}e_{rt}+(1+\tau_{c,t})P_{c,t}e_{ct}, etc. So, shall I try to replace this last equation (responsible for colinearity), with for example the household budget constraint?

No, I am not saying it is another market clearing condition. It can be anything. Note also that the equations you name are not all market clearing conditions. A budget constraint is not a market clearing condition.