Video Of Day

Breaking News

Sfc Models Library For Python

I induce got been "in the zone" for coding the final niggling while, in addition to induce got an initial version of a Python library to analyse Stock-Flow Consistent models. I soundless require to run on making the packet easier to install, therefore I volition hold off to give a fuller description when that is ready. Since I am supposed to move finishing a book, in that location are no guarantees when that volition happen. (Although I await to purpose this module inside the next book, therefore the delay volition non move equally good long.)

What I Hope the Module Will Accomplish

The site sfc-models.net has a code repository for solving SFC models. My impression is that the preferred technique inward academia is to purpose Eviews to solve them. Although Eviews is designed to move used past times economists, it has 2 drawbacks: it is non opened upward source, in addition to the Eviews programming linguistic communication has features that would heighten the eyebrows of most calculator scientists.

The difficulty amongst the electrical flow methodology is that the researcher needs to prepare highly complex models, amongst oodles of variables, past times hand, in addition to and therefore transfer those equations to Eviews. Such a methodology tin evidently move made to a greater extent than user-friendly. However, academics require access to the underlying equations therefore that it looks similar they know what they are doing inside mag articles.

I desire to purpose a existent programming linguistic communication (Python, which is opened upward origin -- that is, tin move downloaded at no charge) to induce got the drudgery out of this work. (I did a thesis inward the early on 1990s doing analytic closed-form mathematics; I swore never to create that again.)

There are 2 "killer apps" I promise to implement inward this package.
  1. Machine interpretation of mathematical formulae written inside formatted text blocks. That is, you lot tin implement a mathematical model amongst nigh no programming skills required.
  2. Machine-generated equations. The user sets upward the sectors of an economic scheme -- which may induce got multiple countries -- in addition to the module generates the equations for you. (These equations tin in addition to therefore move solved.) For example, I could ready the equivalent of the 2 province model from Chapter five of Monetary Economics without typing inward 37 equations consisting of sub- in addition to super-scripted variables.)
The get-go measurement was achieved (as noted below); whether I tin arrive at #2 remains to move seen. 

I would authorities annotation that in that location is already a laid of Python programs that implement the models from Godley & Lavoie's text: https://github.com/kennt/monetary-economics. I induce got spent nigh no fourth dimension looking at that project. Although interesting, it is a evolution direction that I create non desire to follow.

One could endeavour to arrive at this some other programming language. Matlab(tm) beingness some other favourite inside academia; however, Matlab is non free. Furthermore, it is straightforward to integrate Python modules into other evolution systems.

Machine Interpretation of Existing Equations


This is the code needed to generate the SIM model from Godley & Lavoie (Chapter 3):
(Available at GitHub if the higher upward embedding does non work: https://gist.github.com/brianr747/a1bb4b613fbfd012da2497c26bd43910.)

 In instance it is non obvious, the guts of the "code" is truly a documented string which is an nigh lead replication of the mathematics inside the text. (I had to create clean upward some of the equations, equally noted.)

My packet generates a novel file ("SIM_model.py") which solves the organisation of equations.

(In instance you lot are wondering, this packet cannot solve any organisation of equations; it volition only run on equations that are structured similar to that of model SIM. I promise to extend the solving packet (or choose grip of off-the-shelf solvers) to brand the organisation to a greater extent than robust.


Machine-Generated Equations

It remains to move seen whether I tin accomplish this, but it seems that I should move able to prepare an algorithm to generate the equations for a SFC model based on a easily-understood high grade description of a SFC model.

Once the algorithm is inward place, i could imagine setting upward a model economic scheme past times only dragging in addition to dropping models of sectors of the economic scheme into place, in addition to setting upward the interactions betwixt sectors.

Code on GitHub

The code is available on GitHub: https://github.com/brianr747/SFC_models.

For an experienced Python programmer, that would move plenty to larn started. (Note: in that location is a setup.py script inward the evolution branch.)

For those of you lot who are novel to Python, I am working on creating an installation module. Once that installation module is completed, I volition post service installation instructions, in addition to give a to a greater extent than formal introduction.

If you lot mean value you lot would move interested, I would get-go propose installing Python (Version 3.3 or later), in addition to trying some basic tutorials. As tin move seen inward my origin code, you lot mightiness move able to construct some basic models alone past times messing or therefore amongst equations inward the generating string (if you lot tin install the package).

To larn the plotting to work, you lot volition require to install the matlibplot package, which tin move tricky. The code that creates the plots are flora inward the examples directory: https://github.com/brianr747/SFC_models/blob/master/examples/plot_for_examples.py

Ugly Installation Instructions

For a cleaner installation method (before I induce got the install package), please meet my article on Git in addition to Github. However, I volition give you lot the ugly method for impatient readers.
  1. On Github, switch to the "development" branch, instead of "master" - meet the command at the upper left. (The "master" branch represents "production" versions of the code, "development" is the latest version.) Direct link to development: https://github.com/brianr747/SFC_models/tree/development
  2. Use the download option (on the upper right) to download equally a goose egg file (tarball inward linux?).
  3. Unzip the files somewhere useful.
  4. Run "setup.py" on the command line of piece of job (double-clicking it inward Windows mightiness work): "python setup.py". (You may require to give the path to the Python executable, which varies.)
  5. The run_SIM_machine_generated.py script inward the "examples" directory should forthwith run (although you lot volition require to install matlibplot to meet plots).

Concluding Remarks

The code is inward an extremely preliminary state. I only wanted to brand this proclamation therefore that whatever readers interested inward economical modelling consider looking into using Python.

(c) Brian Romanchuk 2016

No comments