Hi, I was trying to run a perfect foresight simulation but get the following error:Fatal error: In Simulate_Newton_Two_Boundaries, dynare cannot improve the simulation in block 1 at time 2 (variable 1 = 0.000000). After few iterations, it fails to solve for perfect foresight. Could you please help me understand why it is not solving and how to fix this? Here is the code which can be run using Main.m
NK Model_v5b.zip (545.7 KB). Thanks
Which Dynare version have you been using?
I’m using dynare 6.1.
I feel like the problem is related to the shock block. When I put initval and endval without specifying any shock, it is able to find the perfect foresight solution .In the attached version, the solution is found but there is no simulated shocks.
NK Model_v5b.zip (546.0 KB)
How can I specify the shock to avoid the fatal error? Thanks
The error message just signal that solving a particular block of the model did not work. That can happen in large models.
You say that it works without shocks. Did you try a transition from outside of the steady state to the steady state? If that worked, have you tried smaller shocks first?
It works for smaller shocks but If I try for the transition from one steady state to another, I get an error that it cannot find the steady state.
Which steady state cannot be found? The terminal one?
You are using the bytecode
option of the model
block. Is that really needed? I would retry without that option.
Hi Prof, The terminal steady state is solving. But the model is still struggling to converge when I apply a shock. I’m able to get a solution with stoch_simul. Is there something I need to fix to get the model found the perfect foresight solution with shocks?
Also, Is there any difference between the irfs from simul vs stoch_simul? In a non linear model, how to interpret the irfs? Are they absolute deviations from steady state? When I apply the option loglinear, I got the error that the model cannot be loglinearised because some steady state are negative. What to do in that case ? Thanks
Yes I’m using bytecode. I will try your suggestion in a moment. I’ve tried to remove the bytecode in the past to just run the model without simulation and noticed that the model takes a lot of time to run. Now that I want to run some simulations, I’m assuming that, it would take much more time. Is there any alternative to bytecode that would help? Thanks
When I remove bytecode, it keeps doing the iteration continuously without reaching any solution.
I would again recommend working with a smaller model. There are too many moving parts.
The fact that the model solves with stoch_simul
but not perfect_foresight
suggests that the model is locally stable but has trouble converging for the full nonlinear model if you start too far from the terminal steady state.
The IRFs for stoch_simul
are absolute deviations from steady state. You don’t need the loglinear
option. You can simply use the var(log)
statement to automatically append the logs of variables that you want in percent.
Thank you for your response. I attempted to apply a log transformation to the variables to obtain percentage deviations, but when I took the log of investment, I encountered a singular matrix error. What could be causing this? Are there alternative ways to express IRFs in percentage deviations?
From an economic standpoint, is it appropriate to use stock_simul for a shock that was intended to be anticipated?
I am still working on resolving the convergence issue in the deterministic simulation. I have reduced the number of sectors in the model and removed some non-essential features, but the model still fails to converge. I also noticed that it does not support either an immediate large shock or a persistent shock. I attempted to increase the shock gradually, but once it reaches its maximum level and I try to maintain it, the model no longer converges. Based on your experience, what aspects of the model could generally lead to such issues? Thanks
- Ultimately, you should not care too much about the log transformation. Once you have the solution for the level variables, you can always transform them manually into percentages.
- If you are willing to work with a linear approximation, you can use the
linear_approximation
ofperfect_foresight_solver
. - If the linear approximation works, the reason must be the nonlinearity of the model. The big question is whether the problem is finding the solution or whether the solution in the nonlinear model does not exist.
Where are the solution for the variables in level stored? because from my understanding the irfs are the absolute deviation. Note that I’m referring to the results of the stochastic simulation.
For the deterministic simulation, I will try the linear approximation as you suggested. Thanks
In oo_.irfs
.
Ok thanks. I applied several shocks simultaneously and got the irfs of each shock on let’s say output. Can I do the summation of the irfs to get the change in output with respect to all the shocks together? If no how to get the combined response to the shocks for a non linear model?
Also if after a shock, an irf for output is 0.05, does it mean an increase in output by 0.05% or 5%? Thanks
- For simultaneous shocks, see
- Regarding the interpretation: that depends on how you measure output (percent/logs or levels) and whether you have scaled the shocks with 100, i.e. whether a 1 percent shock is coded with 0.01 or 1.
Many thanks. You mentioned that the irfs can be summed up due to linearity. I wanted to mention that my model is non linear. Would that still work?
For the shock a 1% shock is 0.01 in the code. Also since the model is non linear, I divided the irfs results with the steady state values to get the change in percentage deviation.