Building A Sfc Model Inward Python
This article demonstrates the get-go basic application of my Stock-Flow Consistent (SFC) models bundle inwards Python: sfc_models. The code is nether construction, together with needs to hold upwardly extended inwards many directions. However, amongst the gist functionality built, adding novel analytic capabilities should hold upwardly straightforward. In this article, I explicate how to implement the simplest SFC model -- Model SIM ("SIMplest") -- from Chapter 3 of Godley together with Lavoie's Monetary Economics. The cardinal wages of my library is that the user simply specifies the high grade description of the sectors of the economy, together with the bundle generates the underlying equations.
The model SIM is the simplest of the models inwards Godley together with Lavoie. I needed to notice external validation of the equations generated past times my package, together with hence this was the get-go existent test. (I accept extensive unit of measurement tests of the code of the private sectors, but nosotros demand to validate that the framework stitches the sectors together inwards a agency that generates equations that tin hold upwardly solved numerically.)
The model consists of iii sectors. The Household together with Business sectors are tied together past times the labour together with goods (final output) markets, piece regime activity simply consists of an externally laid ("exogenous") demand for goods.
I accept already used this model equally an instance multiple times, hence I volition non repeat the background information.If you lot are unfamiliar amongst this model, delight see:
The bundle generates a rather impressive laid of equations for such a uncomplicated model.
GOV_F = GOV_LAG_F +GOV_T -GOV_DEM_GOOD
GOV_FISC_BAL = GOV_T -GOV_DEM_GOOD
GOV_LAG_F = GOV_F (k -1 )
GOV_T = TF_T .
HH_AfterTax = HH_PreTax -HH_T
HH_AlphaFin = 0.4000
HH_AlphaIncome = 0.6000
HH_DEM_GOOD = HH_AlphaIncome *HH_AfterTax +HH_AlphaFin *HH_LAG_F
HH_F = HH_LAG_F -HH_T +HH_SUP_LAB -HH_DEM_GOOD
HH_LAG_F = HH_F (k -1 )
HH_PreTax = HH_SUP_LAB
HH_SUP_LAB = BUS_DEM_LAB
HH_T = TF_TaxRate *HH_PreTax
BUS_DEM_LAB = GOOD_SUP_GOOD
BUS_F = BUS_LAG_F -BUS_DEM_LAB +BUS_SUP_GOOD
BUS_LAG_F = BUS_F (k -1 )
BUS_SUP_GOOD = GOV_DEM_GOOD +HH_DEM_GOOD
TF_T = TF_TaxRate *HH_PreTax
TF_TaxRate = 0.2000
LAB_DEM_LAB = BUS_DEM_LAB
LAB_SUP_LAB = LAB_DEM_LAB
GOOD_DEM_GOOD = GOV_DEM_GOOD +HH_DEM_GOOD
GOOD_SUP_GOOD = GOOD_DEM_GOOD
# Exogenous variable
GOV_DEM_GOOD = [20. ,]*105 # (=20. for fourth dimension 0 -> 104)
The beauty of the sfc_models bundle is that the algorithm generates the equations, together with non the user. This greatly reduces the tedium together with adventure of mistake when generating a large SFC model. For example, a multi-country SFC model volition accept multiple goods together with sectors, which creates an extremely large release of variables that await similar, but accept to hold upwardly carefully tracked.
The nautical chart higher upwardly is generated past times running next code (which requires the matlibplot package):
The model solution is done inside about other file ("out_SIM_Machine_Model.py") which was machine-generated. Although this is somewhat eccentric, it was the safest (and close efficient) agency of allowing for fairly full general equation forms.
The module sfc_models.examples.scripts.build_SIM_model.py does all the steps involved inwards edifice the model.
(c) Brian Romanchuk 2016
Model SIM
Flows inwards Model SIM. |
The model consists of iii sectors. The Household together with Business sectors are tied together past times the labour together with goods (final output) markets, piece regime activity simply consists of an externally laid ("exogenous") demand for goods.
I accept already used this model equally an instance multiple times, hence I volition non repeat the background information.If you lot are unfamiliar amongst this model, delight see:
- Finding the Solution inwards a Simple SFC Model,
- Primer: Money together with Debt inwards SFC Models,
- Equilibrium together with Steady State inwards SFC Models.
sfc_models Package Installation
Installation instructions are flora here. (If you lot are familiar amongst Python, pip install sfc_models works.)
Model Creation
The code to laid model SIM is equally follows:The bundle generates a rather impressive laid of equations for such a uncomplicated model.
GOV_F = GOV_LAG_F +GOV_T -GOV_DEM_GOOD
GOV_FISC_BAL = GOV_T -GOV_DEM_GOOD
GOV_LAG_F = GOV_F (k -1 )
GOV_T = TF_T .
HH_AfterTax = HH_PreTax -HH_T
HH_AlphaFin = 0.4000
HH_AlphaIncome = 0.6000
HH_DEM_GOOD = HH_AlphaIncome *HH_AfterTax +HH_AlphaFin *HH_LAG_F
HH_F = HH_LAG_F -HH_T +HH_SUP_LAB -HH_DEM_GOOD
HH_LAG_F = HH_F (k -1 )
HH_PreTax = HH_SUP_LAB
HH_SUP_LAB = BUS_DEM_LAB
HH_T = TF_TaxRate *HH_PreTax
BUS_DEM_LAB = GOOD_SUP_GOOD
BUS_F = BUS_LAG_F -BUS_DEM_LAB +BUS_SUP_GOOD
BUS_LAG_F = BUS_F (k -1 )
BUS_SUP_GOOD = GOV_DEM_GOOD +HH_DEM_GOOD
TF_T = TF_TaxRate *HH_PreTax
TF_TaxRate = 0.2000
LAB_DEM_LAB = BUS_DEM_LAB
LAB_SUP_LAB = LAB_DEM_LAB
GOOD_DEM_GOOD = GOV_DEM_GOOD +HH_DEM_GOOD
GOOD_SUP_GOOD = GOOD_DEM_GOOD
# Exogenous variable
GOV_DEM_GOOD = [20. ,]*105 # (=20. for fourth dimension 0 -> 104)
The beauty of the sfc_models bundle is that the algorithm generates the equations, together with non the user. This greatly reduces the tedium together with adventure of mistake when generating a large SFC model. For example, a multi-country SFC model volition accept multiple goods together with sectors, which creates an extremely large release of variables that await similar, but accept to hold upwardly carefully tracked.
Equation Solution
The nautical chart higher upwardly is generated past times running next code (which requires the matlibplot package):
import out_SIM_Machine_Model from sfc_models.examples.Quick2DPlot import Quick2DPlot
obj = out_SIM_Machine_Model.SFCModel() obj.main() obj.WriteCSV('out_SIM_Machine_Model.csv') Quick2DPlot(obj.t, obj.GOOD_SUP_GOOD, 'Goods supplied (national production Y)')
The module sfc_models.examples.scripts.build_SIM_model.py does all the steps involved inwards edifice the model.
Next Steps
In gild to hold upwardly to a greater extent than interesting, the sfc_models bundle volition demand to add together back upwardly for to a greater extent than complicated interactions betwixt sectors. I desire to complete off my side past times side mass ("Abolish Money!"), together with volition together with hence plough to a greater extent than attending to that task.(c) Brian Romanchuk 2016
No comments