Macro with Python is a set of introductory examples that apply Python to typical topics covered in an Intermediate (or advanced) macroeconomics course. The discussion assumes an intro/basic knowledge of Python and same familiarity with intermediate macroeconomic models.
The discussions in this project do not provide a full explanation of macroeconomic models nor intends to show coding best practices. The intention of the macro examples is to get started with how to use Python in macroeconomics. QuantEcon offers more advanced an detailed documentation.
The macro examples below are written in JupyterLab notebook and rendered with Jupyter’s nbviewer. Juyter notebooks are divided in cells, where each cell can be text or code. Since the purpose of this examples is pedagogical, each cell is written as a stand-alone piece of code (no need to execute the codes in previous cells).
The GitHub repository of this project is located here.
Macro with Python is an ongoing project. More examples will be added as they become available.
For an example on symbolic mathematics and LaTeX format, see The Solow Model (section 1).
For examples of how to find the roots (SciPy) of a system of equations, see The Labor Market (section 3) and The AD-AS Model (sections 5 and 6).
For a shooting algorithm, see A Simple Ramsey Model (section 5).
Probably the most user-friendly way to get Python is through Anaconda, an environement that allows to easily download and update Python packages and extensions.
In addition to its applicatoins, Anaconda also includes instructional videos and documents.
You can use a JupyterLab notebook. But, it is useful to have an “IDE.” Anaconda also comes with Spyder for Python as well as Visual Studio Code. If you are familiar with R, Anaconda also comes with RStudio.