Solving the discretionary problem for nonlinear models

Dear Professor Pfeifer,

I’m writing with a question about the discretionary_policy function in Dynare. We have a large model (> 400 equations) to which we’d like to apply this function, but the model’s equations are currently written in non-linear form and therefore have to be linearized before we can run discretionary_policy. Given the size of our model, is there a way to automate that linearization process? Since Dynare already has tools to compute the first-order derivatives of non-linear models, my collaborators and I thought that this should be possible in principle.

Thank you for any information or advice that you’re able to share.

Best regards,
Iskander

Can you compute the steady state analytically?

No, we can not. We solve for the steady state by dividing equations by blocks ordered by dependency and solving them using Newton’s method.

I am asking because https://git.dynare.org/Dynare/dynare/-/merge_requests/1792 allows for what you have in mind, but it’s not yet possible to have Dynare compute the steady state.
P.S.: Note that solving the steady state numerically outside of Dynare counts as “analytically” as you are not solving the full system by brute force.

In the current version of our Dynare model file, we are actually not solving for the steady state but simply provide the exact steady state values in the initval block. Is it okay if we just rename “initval” to “steady_state_model” for your code to work properly?

Yes. That way, Dynare will actually check whether these values are the correct ones as opposed to starting a solver.

Why does the output says “All endogenous are constant or non stationary, not displaying correlations and auto-correlations” and STEADY-STATE RESULTS are all zeros?

Without seeing the code it is impossible to tell.

If I run your test file Gali_2015_chapter_3_nonlinear.mod, I also get all zeros for steady-state results.

That was a mistake I just fixed. I printed the steady state before updating it.

I also get the warning in evaluate_planner_objective: “model too large, can’t evaluate planner objective”. Does it mean we can not estimate?

No, it only means that you cannot let Dynare compute the objective as is. This is safety check to prevent memory overflow when there are more than 180 static and predetermined variables. If you feel comfortable, you can simply remove that restriction in line 43 of evaluate_planner_objective.m. If your computer freezes, you know that memory is insufficient.

Why don’t you use discrete-time Lyapunov equation solver instead?

Wyy = reshape(dlyap(sqrt(beta)*Gy,reshape(Uyygygy,nspred,nspred)),1,nspred*nspred);

This will solve Wyy=beta*Gy*Wyy*Gy'+Uyygygy even with large number of variables.

That’s a good point. I hadn’t really looked at the bottleneck. I guess you meant
Wyy = reshape(dlyap(sqrt(beta)*Gy',reshape(Uyygygy,nspred,nspred)),1,nspred*nspred);

This will solve Wyy=beta*Gy'*Wyy*Gy+Uyygygy, i.e. the transpose was wrong. I pushed the change to https://git.dynare.org/Dynare/dynare/-/merge_requests/1792/diffs?commit_id=9728a52889b66f6a00f4f985a64e0143c15e92c3