The Baseline Overview
# Mar 3, 2019Before we get started building any sort of more complex economy, the first thing we’ll want to do is confirm that it actually works by comparing the results of a simple virtual economy with what economic theory predicts will happen. We’ll do this by writing out a mathematical model of a very simple economy using standard economic theory, and see what sort of results it gives out. This will give us a prediction on what we’d expect to see, and then we can compare what we get from the simulation. If they match up then we have a good idea that our simulation works well, and we have more faith in it as we scale it up to larger economies. If they don’t match up it will probably indicate that we have a bug, but it could also point to something interesting in the way we’re doing our simulation.
As mentioned, this first version of our economy is going to be very simple, since as we scale up we probably won’t be able to do the same mathematical analysis - the number of variables and equations makes solutions impossible to find very quickly. Over time we’ll add complexity to add more interesting ideas, but because we started from a solid mathematical base and tested each step thoroughly, we can have a reasonable assurance that we didn’t make a mistake somewhere.
Let’s start off by describing our mathematical model of the economy. Imagine a very basic economy where we have some firms and some workers. We’ll say that in this imaginary economy, firms produce a good: biscuits. The firms own the means of production (the ovens) but don’t know how to actually make the biscuits, where the workers know how to make them but don’t have ovens and have no possibility of getting them. Firms pay their workers in biscuits instead of with money (which doesn’t exist in this fictional world).
This means that workers don’t actually have much thinking to do. They just work. The whole process is determined entirely by the firms, who have some sort of profit maximizing objective:
\begin{equation} \max_L \pi(w) = Q(L) - wL \end{equation}
Given a market wage $w$, the firm chooses the amount of labour $L$ that they hire in order to produce a certain amount of goods, determined by a production function $Q$. For simplicity we can just use the standard Cobb-Douglas production function:
\begin{equation} Q = AL^\alpha \end{equation}
Here $A$ is a technology multiplier, and $\alpha$ is a factor that determines the returns to scale of labour. We’ll want to restrict this to be between 0 and 1, which means that as you add more labour you get more quantity but the amount you get for each additional person declines over time (aka diminishing marginal product of labour).
Lastly, we’ll say that our economy is finite. There are $F$ firms and $N$ workers in our world.
This gives us our labour supply and demand curves:
\begin{equation} L_s = N \end{equation} \begin{equation} L_d = F\left (\frac{w}{A\alpha} \right )^{\frac{1}{\alpha - 1}} \end{equation}
In equilibrium, we get the following for the market wage:
\begin{equation} w = A\alpha\left (\frac{N}{F}\right)^{\alpha - 1} \end{equation}
The workers should be evenly distributed among the firms, there will be $\frac{N}{F}$ workers per firm.
Note that there is one degenerate case here: profits should never be negative, or firms will not demand any labour at all. In a Cobb-Douglas world it is never possible for profits to be negative unless $\alpha$ > 1, which is ruled out by assumption.
Now that we have our prediction, we can build our economy and see if it lines up.
The first thing we have to think about now that we didn’t have to in the mathematical analysis is: how do we get to equilibrium? Instead of just plugging the formula into the code which would make for a very boring simulation but also very unscalable to more complicated models, we want to have each agent make their own decisions and hope that we’ll arrive at the same value. We’ll have to come up with some sort of decision process that each agent follows.
The next thing we’ll have to think about is how do firms and workers connect with one another? From the mathematical analysis it’s easy for us to say that each firm will have $\frac{N}{F}$ workers, but we have no idea how those workers got there in the first place. We’ll have to build some mechanism for matching workers with firms.
Lastly, we’ll have to think about time. The mathematical analysis assumes we’re in equilibrium, which means that time doesn’t actually matter any more - the system has settled to a stable state, and all time after that point is the same. In our simulation though we aren’t going to start off in equilibrium, so we’ll need to think about how things change over time from the initial state to when it settles to equilibrium.
We’ll address the issue of time first, since it’s the easiest. We’ll just split up time into discrete steps, call them “days”. Each day all firms and workers will make their decisions, and absolutely none of them will be binding the next day - workers will not stay at a firm. This simplifies things because firms won’t have to decide about firing workers, and workers won’t have to decide about finding a new job.
Next we’ll decide how firms and workers get matched up with one another. There are many ways we can do this, but for this model we’ll use a market mechanism. It’s a relatively simple but flexible mechanism that we’ll be able to re-use when we start making our economy more complex.
This market will be a double auction modelled off of the stock market: workers (the sellers of labour) submit the minimum wage that they are willing to work for, and firms (the buyers of labour) submit the maximum wage they are willing to pay and the amount of workers they want to hire. This will potentially result in an overlap in wage values, so the market will match all the workers and firms who are in that overlap and notify them using a callback mechanism to say that they were matched. The market will track the high $w_h$ and the low $w_l$ of the overlap and expose those values for firms and workers so they can use them in future decision processes; ideally in equilibrium the high and low values will converge to a value that we can call the market wage1.
Lastly, the decision processes of firms and workers. Workers are very simple: they are trying to get the highest wage possible while remaining employed. If the agent was unemployed2 last round, it will try to guarantee itself a job by undercutting the market and offer a wage equal to $w_l - \tau$ ($\tau$ being an adjustment factor, provided as a parameter to the simulation). If they were employed then it’s possible they offered too low a wage, so they will offer $w_h$ as their wage.
Firms are slightly more complex because they are looking to fill a number of workers rather than just a single one, and are optimizing over a curve instead of a binary value. So firms will first decide on a wage to offer the market. A firm that did not get enough employees last period will try to lure workers from competitors by offering a wage of $w_h + \tau$; a firm that satisfied its requirements last period will attempt to offer $w_l$. Based on the chosen wage, the firm knows they can maximize their profits by using the individual labour demand function, so this will result in the number of workers to hire (with a few exceptions, they need to submit discrete values so they’ll choose the value of $floor(L)$ and $ceil(L)$ that maximizes profits).
There is one degenerate case for firms: if the wage they decide on results in them making negative profits, they will instead choose to hire no workers. In this model this should theoretically never be the case, but we’ll add it to the code anyway for two reasons: (1) we’re not 100% sure what will happen outside of equilibrium, so adding this condition avoids going off into non-sensical outcomes; and (2) as we make our models more complex this could become a realistic outcome for some firms, so we can add it now so we don’t forget to add it later.
We now have an outline for a simple virtual economy. The next few articles we’ll actually be writing some code for these, which will lay some framework for future simulations. Lastly, we’ll define a way we can extract results from this model and compare to the mathematical version. I’m looking forward to it!