Techniques For Finding Sfc Model Solutions
The reward of measure Stock-Flow Consistent (SFC) models is their analytical tractability. Although some researchers mightiness desire to include infinite horizon utility component optimisations, at that topographic point is petty value added if you lot cannot honour the solution to the model. We start off with SFC models that nosotros tin honour the solution, as well as therefore nosotros tin incrementally add together complexity, therefore long equally a solution method is available. I hash out diverse techniques to solve these models.
(Note: this postal service uses the MathJax bundle to display properly formatted equations; they may or may non display properly on your browser. Please allow me know if you lot get got severe problems, equally I mightiness last using MathJax inwards the future.)
The text Monetary Economics by Wynne Godley as well as Marc Lavoie has perish the measure piece of work for learning virtually these models. One of the advantages of the mass is that researchers get got built code (and spreadsheets) to solve the diverse models included inwards it. This agency that it is possible to interact with the solutions, regardless of your software preferences.
From my express noesis of the literature, it seems that the preferred platform alongside SFC academics is Eviews. For person with a casual involvement inwards the subject, this software has the drawback of existence commercial software. However, at that topographic point is at in 1 lawsuit code available to solve the models for the opened upwards origin linguistic communication R -- which is what I operate to generate the plots on my website.
(I get got developed my ain variation of SFC models with Python; previous models I get got built were with that system. Python is also opened upwards source. You could non operate my Python organisation to solve the models inwards Godley as well as Lavoie; I decided to get got the algorithms inwards a somewhat eccentric direction. I tin easily model fairly complex systems, at the terms of losing the mathematical elegance that academics require. My organisation is non truly ready for "prime time," therefore I get got non released the code yet.)
For the models inwards Monetary Economics, at that topographic point is solution code in:
As I discussed inwards Finding the Solution inwards a Simple SFC Model, there is an Excel spreadsheet which solves the organisation fourth dimension point-by-time point. (Note that past times setting the taxation charge per unit of measurement to zero, I blew upwards the steady terra firma solution.) The spreadsheet contains graphs of the output.
Influenza A virus subtype H5N1 spreadsheet similar this is belike the best introduction a non-programmer could promise for. It is possible to encounter all the variables -- as well as how they evolve over fourth dimension -- inwards 1 shot. However, with all the equations hidden inwards prison theater cellphone formulae, it is non obvious how the solution is arrived at from a technical standpoint. (More on this below.)
Even if you lot practice non get got Eviews, the code is straightforward to read, which is truly unfortunate, equally discussed below. I volition at in 1 lawsuit excerpt some fragments of the program.
The code showtime defines variables (above). As the code indicates, the variables are all fourth dimension series, defined at an annual frequency from 1945 to 2010.
The code therefore creates the model 'sim_model', with the equations specified exactly equally they are inwards Godley inwards Lavoie. (With c_d standing inwards for $C_d$.)
The critical measurement -- solving the model is done equally shown below.
In other words, the plan invokes the "solve" method on the "model" object, which is defined past times proprietary Eviews code. (One hopes that at that topographic point is some technical documentation for that method somewhere.)
There are 2 ways of looking at this.
If nosotros right for the fourth dimension shift inwards $u(t)$ (we tin define $\hat{u}(t) = u(t+1)$), we tin relate to the canonical format via:
\[ Influenza A virus subtype H5N1 = (I-A_1)^{-1} A_2, \]
\[ B = (I - A_1)^{-1} B_1. \]
We tin therefore apply measure dynamic organisation theory to hash out the properties of the solution.
From a technical dot of view, the existence of the matrix inverse $(I - A_1)^{-1}$ is what determines the existence as well as uniqueness of a solution to the system. Godley as well as Lavoie emphasise the importance of the break of equations needed to unopen the organisation ($n$ equations for $n$ variables). The existence of the matrix inverse indicates whether you lot get got properly chosen the equations to unopen the system. (For example, if you lot direct $x_1 = x_2$ as well as $x_2 = x_1$ equally 2 equations inwards 2 unknowns, you lot practice non get got plenty data to honour a unique solution.)
However, it should last noted that most interesting SFC models volition involve nonlinearities. (In the illustration of model SIM, the model would last nonlinear if reward were no longer fixed.) In which case, nosotros mightiness last stuck with iterative methods of solution. (In my Python models, I operate a diverseness of terminate runs to avoid the operate of iterative solution methods.)
See Also:
(c) Brian Romanchuk 2015
(Note: this postal service uses the MathJax bundle to display properly formatted equations; they may or may non display properly on your browser. Please allow me know if you lot get got severe problems, equally I mightiness last using MathJax inwards the future.)
The text Monetary Economics by Wynne Godley as well as Marc Lavoie has perish the measure piece of work for learning virtually these models. One of the advantages of the mass is that researchers get got built code (and spreadsheets) to solve the diverse models included inwards it. This agency that it is possible to interact with the solutions, regardless of your software preferences.
From my express noesis of the literature, it seems that the preferred platform alongside SFC academics is Eviews. For person with a casual involvement inwards the subject, this software has the drawback of existence commercial software. However, at that topographic point is at in 1 lawsuit code available to solve the models for the opened upwards origin linguistic communication R -- which is what I operate to generate the plots on my website.
(I get got developed my ain variation of SFC models with Python; previous models I get got built were with that system. Python is also opened upwards source. You could non operate my Python organisation to solve the models inwards Godley as well as Lavoie; I decided to get got the algorithms inwards a somewhat eccentric direction. I tin easily model fairly complex systems, at the terms of losing the mathematical elegance that academics require. My organisation is non truly ready for "prime time," therefore I get got non released the code yet.)
Software Repository
The spider web site sfc-models.net -- aimed at SFC modelling researchers -- has a code repository: http://models.sfc-models.net/For the models inwards Monetary Economics, at that topographic point is solution code in:
- Eviews (commercial);
- Matlab (commercial, but widely available at Universities);
- R (open source);
- Excel spreadsheets (commercial, but presumably tin last viewed inwards Open Office).
Although I am only discussing the simplest model -- model SIM, which I referred to inwards a previous article -- the models inwards Monetary Economics acquire increasingly complex. One mightiness last able to modification an existing model to report a organisation of interest.
It should last noted that without access to the text, the models may last hard to follow. (What are these variables? Where did the equations come upwards from?) I am assuming hither that the reader has access to a description of the model. (In my previous article, although I skipped the equations, I explained how the diverse economical variables related to eachother.)
Excel Spreadsheet
As I discussed inwards Finding the Solution inwards a Simple SFC Model, there is an Excel spreadsheet which solves the organisation fourth dimension point-by-time point. (Note that past times setting the taxation charge per unit of measurement to zero, I blew upwards the steady terra firma solution.) The spreadsheet contains graphs of the output.
Influenza A virus subtype H5N1 spreadsheet similar this is belike the best introduction a non-programmer could promise for. It is possible to encounter all the variables -- as well as how they evolve over fourth dimension -- inwards 1 shot. However, with all the equations hidden inwards prison theater cellphone formulae, it is non obvious how the solution is arrived at from a technical standpoint. (More on this below.)
Eviews Code
The link for the code for model SIM (in Chapter 3): gennaro.zezza.it/software/eviews/glch03.phpEven if you lot practice non get got Eviews, the code is straightforward to read, which is truly unfortunate, equally discussed below. I volition at in 1 lawsuit excerpt some fragments of the program.
Eviews code: Initialisation (partial) |
The code showtime defines variables (above). As the code indicates, the variables are all fourth dimension series, defined at an annual frequency from 1945 to 2010.
Chart: Eviews code - creation of model, with equations specified (partial). |
The critical measurement -- solving the model is done equally shown below.
In other words, the plan invokes the "solve" method on the "model" object, which is defined past times proprietary Eviews code. (One hopes that at that topographic point is some technical documentation for that method somewhere.)
There are 2 ways of looking at this.
- If you lot are an Eviews user, this is really convenient. You tin direct read off the equations from Godley as well as Lavoie (or from your pen-and-pencil analysis of some other model), as well as direct imitate those equations inwards Eviews.
- If you lot practice non get got Eviews, the code tells you lot exactly goose egg virtually how to honour a solution to the system. You get got exactly the same data equally is given inwards the equations inwards the book.
Since I did non get got access to Eviews, I was non peculiarly happy with that situation. Rather than trying to emulate the Eviews solution technique, I took the modelling framework inwards a dissimilar direction, using Python. (That volition last the topic of afterwards articles.) However, my response is non useful for those of you lot who desire to piece of work through Godley as well as Lavoie, and/or read the academic literature (which has tended to follow the same formalism).
R as well as Matlab Models
Graphical Output from R code (model SIM). |
The sfc-models.net code page contains origin code for the solution of models using R as well as Matlab.
The solution technique is to a greater extent than transparent -- the solution to the organisation of equations is determined iteratively. That is, nosotros start off with an initial guess at the solution, as well as therefore the guess is improved over a serial of iterations. If the organisation of equations is good behaved, the algorithm volition converge to the solution.
(I no longer get got access to Matlab, therefore I get got non tested the code. The R code is developed using object-oriented code. Although I prefer object-oriented programming, I get got non truly used those techniques inwards R, therefore I get got non extensively played with the code.)
Even if you lot prefer other programming languages, it would last easier to prepare an algorithm that emulates the low-level code used inwards the R as well as Matlab versions.
Existence And Uniqueness
One of the most basic questions nosotros tin inquire virtually a mathematical organisation -- does a solution exist, as well as is it unique? If nosotros cannot response those questions, nosotros get got to get got concerns whether the mathematical model tin last related to existent globe behaviour.
The existence of a solution is plainly important. If at that topographic point is no solution, the model tells us nothing. Although it is entertaining to write downward equations like:
\[ x = x + 1, \]
it is merely a long-winded way of writing out the empty laid ($\emptyset$). There is an infinite break of models that get got no solution, therefore nosotros cannot operate the data that at that topographic point is no solution inwards a useful way.
Non-uniqueness of the solution is to a greater extent than awkward. As long equally nosotros practice non subscribe to some wacky quantum metaphysics, nosotros usually assume that at that topographic point is 1 "real world." As a result, it is hard to relate a mathematical model with 2 or to a greater extent than solutions to real-world behaviour. What is the model predicting? (Within economics, at that topographic point appears to last a lot of metaphyiscal musings virtually "multiple equilibria" related to this concept; such reasoning makes petty feel when translated into mathematics.)
For a linear organisation (such equally model SIM), non-uniqueness as well as non-existence of solutions effect inwards the same terminate dot for iterative solution methods -- the algorithm does non converge.
- If at that topographic point is no solution, the algorithm has goose egg to converge to (absent some really bad luck).
- If the solution is non-unique, a linear model has a laid of solutions that are a linear subspace of the infinite of all possible values for the variables. In other words, an infinite break of solutions. This lack of uniqueness agency that the algorithm cannot converge to a unmarried point; each iteration volition last drawn towards a dissimilar dot inwards the laid of all possible solutions. (Once again, assuming that nosotros are non unlucky.)
As a result, nosotros tin last fairly indifferent to worrying virtually the existence as well as uniqueness properties when dealing with linear systems. If nosotros tin honour a solution, nosotros know that 1 exists, as well as nosotros tin last fairly certain that the solution is inwards fact unique.
Unfortunately, this is no longer truthful for nonlinear systems. The laid of solutions tin get got almost whatever conceivable form, including the possibility of a few isolated solutions. Iterative techniques volition converge to 1 of these local solutions, without offering whatever indication that other solutions exist.
In the context of economics, it mightiness last possible that at that topographic point are 2 solutions to a model -- 1 with high unemployment, some other with depression unemployment. Researchers doing iterative solution techniques could terminate upwards with simulations with quite divergent outputs, alone based on really hard-to-replicate differences inwards the search technique.
This reasoning is why I get got reservations virtually purely iterative solution techniques. They mightiness last necessary, but nosotros demand to last cautious.
Tom Brown's Models
Tom Brown, who has commented upon some of my SFC articles, has done a break of simulations of model SIM as well as other SFC models. For example, his version of a model past times Nick Edmonds. Some of his piece of work revolves unopen to converting the models to continuous time, a technique that I get got reservations towards. (A continuous fourth dimension framework is favoured past times Jason Smith, inwards his "Information Transfer Economics" theory.)
I get got had difficulty with the loading fourth dimension with some of his pages on my underpowered "writing laptop," therefore I get got non had a direct a opportunity to hold back into his piece of work also closely.
Canonical Linear Dynamic Models
For a linear model similar SIM, what nosotros would similar to practice is to convert it into the canonical linear time-invariant cast (which is described inwards whatever measure multi-variable systems textbook):
\[ x(t+1) = Influenza A virus subtype H5N1 x(t) + B \hat{u}(t), x(0) = x_0. \]
In this case, $x$ is a vector of variables, residing inwards $R^n$. For those of you lot who are unfamiliar with matrix notation (or purged the concept from memory), that agency nosotros are stacking upwards $n$ fourth dimension serial variables into a unmarried object. Using economical lingo, $x(t)$ are the endogenous variables, as well as the vector $\hat{u}(t)$ is the vector of exogenous variables ("inputs").
However, the equations inside Godley as well as Lavoie are non inwards that format; what nosotros encounter is a bunch of algebraic equations; inwards the illustration of model SIM, eleven of them. (Which is impressive, since at that topographic point is technically only 1 truthful terra firma variable.) Even the exogenous variable -- authorities spending -- is specified equally an algebraic equation.
After some manipulation, it is possible to convert the equations for model SIM into the format:
\[ x(t+1) = A_1 x(t+1) + A_2 x(t) + B_1 u(t+1). \]
(Since at that topographic point is a petty of algebra involved, I would only endeavor that conversion inside a PDF document.)
We tin therefore convert this to:
\[ (I - A_1) x(t+1) = A_2 x(t) + B_1 u(t+1). \]
Finally (assuming $(I-A_1)^{-1}$ exists),
\[ x(t+1) = (I - A_1)^{-1} A_2 x(t) + (I - A_1)^{-1} B_1 u(t+1). \]
If nosotros right for the fourth dimension shift inwards $u(t)$ (we tin define $\hat{u}(t) = u(t+1)$), we tin relate to the canonical format via:
\[ Influenza A virus subtype H5N1 = (I-A_1)^{-1} A_2, \]
\[ B = (I - A_1)^{-1} B_1. \]
We tin therefore apply measure dynamic organisation theory to hash out the properties of the solution.
From a technical dot of view, the existence of the matrix inverse $(I - A_1)^{-1}$ is what determines the existence as well as uniqueness of a solution to the system. Godley as well as Lavoie emphasise the importance of the break of equations needed to unopen the organisation ($n$ equations for $n$ variables). The existence of the matrix inverse indicates whether you lot get got properly chosen the equations to unopen the system. (For example, if you lot direct $x_1 = x_2$ as well as $x_2 = x_1$ equally 2 equations inwards 2 unknowns, you lot practice non get got plenty data to honour a unique solution.)
However, it should last noted that most interesting SFC models volition involve nonlinearities. (In the illustration of model SIM, the model would last nonlinear if reward were no longer fixed.) In which case, nosotros mightiness last stuck with iterative methods of solution. (In my Python models, I operate a diverseness of terminate runs to avoid the operate of iterative solution methods.)
See Also:
(c) Brian Romanchuk 2015
No comments