Monetary Circuit Model/Skeleton Model

This lesson explains how to set up a skeleton of the monetary circuit model in Sage. This model looks at an economy with three sectors - banks, firms, and workers - with no monetary transactions taking place in between them. While the model itself is useless, the code given here will form the basis of future models.

The basic mathematical tool used by the monetary circuit model are systems of Ordinary Differential Equations (ODEs). The ODE system describes the flows between sectors of the economy. Taken together with some initial values, Sage can solve the system to describe how stocks (accounts) change over time. To do this, we must first tell Sage the names of the variables and functions we wish to use:

This declares our dependent variable, t, for time. Five stocks/accounts are also declared as functions of time: the bank vault, bank transactions account, firm debt (loans), firm deposits, and worker deposits. The constant ibc is the initial bank capital, the amount of money in its vault at the beginning of the first period. It is not used until later, but kept here so all declarations are in one place.

Next, we create a skeleton ODE system:

This creates a list of differential equations named des, one equation for each of the five stocks. Notice that we use the double-equals sign to specify that this is an equation rather than an assignment.

The system of differential equations specifies our flows. The left hand side of each equation is the first derivative of each stock with respect to time - how quickly the stock changes. The right hand side specifies the flow of money into and out of that stock. For our skeleton system, we do not have any transactions taking place, so the right hand side is 0.

Next, we solve the system:

The desolve_system function is somewhat complicated. The first argument is the system of differential equations we want to solve. The second argument is a list of the dependant variables, in this case our five accounts. The third argument is a list of initial conditions. The first element of the list is the initial value of the independant variable (t), followed by the value of the five dependant variables at the initial time t = 0.

We initialize all the stocks to 0 except for the bank vault, which we initialize to the initial bank capital (ibc) declared above.

Finally, we add some code to plot the system:

You do not have to understand this last bit of code to understand the model. To show the results, save all of the code in a file such as skeleton.py and run the following in the Sage interpreter:

attach skeleton.py

Note: once attached, Sage will automatically reload the file if it is changed. If you make a change, simply press 'enter' in the interpreter to re-run the model. The resulting graph should look something like this:



So far, this is a pretty useless model, since it describes an economy with no monetary transactions. In the next lesson, we will extend the skeleton to create a simple model where banks create money by lending to firms.