# Reference request: a book on numerically solving DSGE models with code

I am new to the area of DSGE modelling, and programming DSGE models. I was hoping that someone could recommend a book on DSGE modelling, that presents the different model components as well as code for numerically running/optimizing the components of those models. I am particularly interested in the numerical methods for solving these models.

As I am learning more about these models, it helps to have some existing simple solved codes, so that I know what working examples look like. That way when I run experiments, I have a bit more confidence that I am doing it correctly.

So far the best resource I have found are the quantecon lectures. These lectures use both the Julia and Python languages, and I am well versed in both. In terms of the reference request, any language would probably be good, matlab, julia, python, etc. What I would like to avoid is just using a package or black box, where the internals are hidden from the user.

Thanks.

• What do you mean by "simple solved codes"? Usually researchers build a more general tool that can than be applied to both simple and more complicated models. Also, the general theories behind the solution approaches are generally quite complicated,. Have you looked into numerical methods in Economics?
– BrsG
Jun 27, 2022 at 9:14
• @BrsG I think I just called them codes because in numerical PDEs we usually call the solvers codes. So that was just a habit. What I am looking for is something that actually shows the optimization code or simulation code for simpler models. For example in the quantecon lectures, the linear programming solver is a function in a package--so the user does not see what happens. I can find the code for simple interior point solvers anywhere, but then I might get different results from the examples. Thus it is nice to have simple examples with simple codes with them. Jun 27, 2022 at 16:32
• @BrsG the other thing is, if I am trying to disect the source code for some package, it can be pretty brutal to hunt through all of the internal functions and files to figure out the final algorithm. And even if a user suceeds in doing that, trying to replicate that algorithm outside in a new simplified form takes a lot of time. I mean I have done that with Fortran codes, and it takes forever to get it right. So that is what I was looking for. Jun 27, 2022 at 16:38

One of the best resources I have found is the book by Kindermann and Fehr, Introduction to Computational Economics using Fortran. This book covers most of the macroeconomic models and some variations, including Ramsey-Cass-Koopmans, and the New Keynesian models. The code is written in Fortran, but it is not too bad to adapt that code to a different language. The workhorse functions in the fortran code are fsolve and fzero, which are for solving linear systems of equation and root finding--for non-linear root finding problems. So the math is not too bad, and it is nice to see how the problems are setup.