Wealth Distribution in a Transfer Economy

Overview and Objectives

Overview

This lecture demonstrates that random redistribution can be a potent underpinning of emergent wealth inequality. To accomplish this, it develops a simple agent-based model of a transfer economy where total wealth is constant. Agents are initially homogeneous, but they continually engage in small transactions. These interactions between initially identical agents quickly produce substantial heterogeneity.

Initially, each agent has positive wealth. To ensure that any observed inequality is emergent and not imposed, every agent starts with the same wealth. Each period, each solvent agent makes a small gift to a randomly chosen recipient. (A solvent agent has positive wealth.)

Despite the apparent basic symmetry in these interactions, a surprising diversity in wealth outcomes quickly emerges. This lecture explores ways to characterize the macro-level inequality that emerges from symmetric micro-level interactions. As part of this exploration, this lecture introduces alternative approaches to measuring inequality.

Goals and Outcomes

This lecture adds to the agent-based modeling and simulation tools introduced in the Financial Accumulation lecture. It extends the exploration of ways in which substantial heterogeneity can emerge among initially identical agents. Central to the present lecture is the complete development of a simple agent-based model of the emergence of inequality in a world with constant total wealth.

Prerequisites

Implementing this lecture’s model requires the mastery of the material in the Financial Accumulation lecture, particularly the exercises therein. While understanding the core concepts in the present lecture does not require attempting the accompanying exercises, these exercises promote a deeper understanding of the model and its consequences. Addtionally, the exercises of this lecture refine programming skills needed for models in future lectures.

Gift World: The Process of Programming

Before attempting to implement a Gift World model, it may help to skim the present lecture from start to finish. Be sure to garner a good understanding of the conceptual model and of the visualizations of the model results. After a preliminary overview, work through the lecture step by step, implementing the computational model along the way. Whenever needed to keep the implementation runable during model development, temporarily use stubs. Verify all function implementations, either by using provided test procedures or by writing your own.

Gift World

This section develops and explores a particularly simple economy called Gift World. This economy is inhabited by gift givers, who are endowed with wealth that they give away as gifts. Total wealth is constant, so gift giving is purely redistributional. The core goal is to describe the emergent wealth distribution in Gift World.

Gift World Conceptual Model

The conceptual model of a Gift World is extremely simple. There is constant total wealth allocated across a constant number of givers. Initially, the givers all have the same wealth, but this changes over time as they engage in gift giving. To lend focus to the model, total wealth remains constant, and individual wealth changes only due to gift giving and receipt. Each period, each solvent giver gives away some wealth as a gift. Each giver chooses a gift recipient each period—there are no persistent links between agents. The giver chooses the recipient entirely randomly, and a gift is never refused by a recipient. This simple structure renders salient the consequences of small random redistributions among a fixed set of agents.

Formulating Hypotheses

Before diving into the model details, pause to consider the kinds of questions that such a model might be able to address. Questions are the driving force for model formulation and implementation. Gift World allows us to explore certain possible features of the distribution of wealth, but not others.

In particular, Gift World offers another opportunity to consider the role of chance in the emergence of a wealth distribution. Everyone is equal at the beginning. Everyone has identical behavior (i.e., gift giving). It is natural to wonder, what happens to the distribution of wealth over time? This question provides a motivation for exploring the Gift World model. A useful approach to such questions is to guess at the answer (based on knowledge of the model) and then test that guess by running the model.

This course focuses on the implementation of agent-based models in order to explore their implications. We run model-based simulations, collect simulation data, and analyze the data. The choice of model and the selection of data both reflect guesses about what model outcomes may prove interesting. We are particularly interested in how changes in the model parameters cause changes in the simulation outcomes. That is, we seek causal regularities in our simulations.

This course refers to any proposed testable causal regularity an “hypothesis”. This is a very weak concept of what it means to be a hypothesis. For example, it is not concerned with how much prior modeling or theoretical development motivates the proposed relationship. Of course, all else equal, a hypothesis motivated by theory or by prior analyses is more interesting than one that lacks such support.

We formulate hypotheses in order to test them. A hypothesis may be no more than a guess about how a model will behave, but it must be testable with data gathered by running the model. We gather data from an agent-based simulation and use this data to test hypotheses. A hypothesis about a model is testable to the extent that the model can produce simulation data that indicates whether or not the hypothesis is true.

Gift World Hypotheses

If Gift World does approach a limiting distribution of wealth, we can ask some related questions. Will the wealth distribution tend to be egalitarian, or will it tend toward substantial wealth inequality?

Gift World is a standard introductory model that is often known as the Boltzmann wealth model. [Wilensky.Rand-2015-MIT] comment that many people predict that the distribution of wealth produced by the model will tend to be rather flat (by which they mean egalitarian). However, some people predict that eventually the distribution of wealth will resemble a normal distribution.

One may propose rough intuition for either hypothesis. The model setup is egalitarian and each individual is treated equally, so it seems natural to expect everyone to remain about equal. On the other hand, after the very first iteration of the model, some agents are richer than others. So it also seems natural to expect this differentiation to continue.

Two possible approaches to such questions are to attempt a mathematical derivation of the distribution or to simulate the outcomes. This lecture develops an agent-based simulation for this purpose.

Gift World Hypotheses

Formulate one or more hypotheses about the distribution of wealth in Gift World. What should the mean wealth look like, relative to the initial mean wealth? What should the median wealth look like, relative to the initial median wealth? How egalitarian will the end-of-simulation distribution be, given an initial egalitarian distribution? Be sure to specify the data and methods reqired to test the hypotheses. Make a note of all this for later retrieval, perhaps in a GiftWorldNotes file.

Gift World: Designing the Agents

Givers are the only agents in a Gift World. Each giver starts with the same wealth; for concreteness, let this initial value be ¤100. A giver has one key data attribute: wealth. Evolution of the wealth of givers is the core focus of the model. In addition, it can be convenient to introduce one additional data attribute: donee, which is the giver’s intended recipient. (An insolvent giver will not pick a recipient.) A giver also has two behaviors: planGift, and giveGift. The following class box summarizes the basic features of a Giver agent.

Giver

wealth: Integer

donee: Optional[Giver]

planGift()

giveGift()

Gift Planning

The conceptual model of gift planning involves conditioning whether to give a gift on one's wealth. An agent with wealth > 0 is solvent. A solvent giver plans to give a gift and therefore picks a donee. This is the planning stage of gift giving: a giver plans either to give a gift (setting donee to a giver) or plans not to give a gift (setting donee to nobody). Capture this in a planGift behavior, as follows.

behavior:

planGift

context:

Giver

summary:

Set this giver's donee attribute to a random giver if this giver is solvent and otherwise to nobody.

Gift Giving

The ability to make payments is a common need in agent-based models: the payer’s wealth falls by the amount of the payment, while the payee’s wealth rises by the amount of the payment. In a simple Gift World, a solvent agent always gives a gift of ¤1, and the recipient is chosen completely randomly.

The following summary of a Giver agent’s giveGift behavior depends on the previous gift planning stage. If the giver planned to give a gift by choosing a recipient, the giveGift behavior should produce a transfer of wealth by decrementing the agent’s wealth by the amount of the gift and incrementing the wealth of the recipient by the amount of the gift. (In the simple Gift World model, the size of the gift is fixed at ¤1.) If the giver planned not to give a gift and so did not choose a recipient, the giver should do nothing.

behavior:

giveGift

context:

Giver

summary:

If the donee identifies a recipient, this giver should

  • decrement own wealth by \(1\), and

  • increment the recipient’s wealth by \(1\).

Giver Implementation

Create a new project named GiftWorld01. Implement the Giver type. Based on the description above, a Giver should have two data attributes (wealth and donee) and two behaviors (planGift and giveGift). Begin the implementation of these behaviors by creating stubs for them; then fill in the behavioral details. Test that these behaviors are working as expected.

Setting Up a Gift World

In the conceptual model, the number of agents and the total available wealth remain unchanged as Gift World evolves, period by period. Each period, the givers plan and give gifts. This produces a small change in the distribution of the fixed amount of wealth among the fixed number of agents, but it leaves total wealth unchanged.

Setting up the computational model requires a specification of the number of agents and the initial distribution of wealth. The initial state of a Gift World is completely egalitarian. The conceptual model therefore requires the initial wealths to be equal, but it does not provide useful guidance about the number of agents. This section works with fairly arbitrary numbers: \(1000\) agents, each with an initial wealth of \(100\). For simplicity, your initial implementation should simply `hard code`_ these two model parameters. (See the Exploration section for other approaches.)

Hard-Coded Model Parameters in Gift World

name (type)

value

nAgents: Integer = 1000

agentInitialWealth: Integer = 100

The primary goal of the setup phase of the simulation model is to begin with the the correct number of properly initialized givers. As a small convenience, one may additionally introduce a global ticks variable to track the number of simulation steps. In this case, the model setup should initialize ticks to \(0\). The setup procedure is correspondingly simple, as indicated by the following summary of a possible setup activity.

activity:

setup

summary:
  • Start afresh.

  • Initialize a collection of \(1000\) givers to each have a wealth of \(100\).

  • Initialize ticks to 0.

This summary seems to lack a couple details. For example, it does not specify the initial value of the donee of the givers. (Note however that since this initial value is never used, its initial value is arbitrary.) In addition model’s setup phase creates a collection of givers, but some way to access these is needed in order to run the simulation. The best way to handle these details is language dependent.

Basic Model Setup

In the GiftWorld01 project, implement the simulation model set up as summarized above. Begin with a a collection of comments that are based on the setup summary above. Then add the needed code after each comment.

Check that the model setup is working by running the code and examining one or more of the resulting agents. If this looks good, then write tests that ensure that the setup code is working correctly.

The Gift World Simulation Schedule

A Gift World simulation follows the typical pattern for a discrete-time dynamic system: set up the simulation model, and then iterate the simulation schedule for the duration of the simulation. According to the conceptual model, Gift World evolves because each solvent giver gives a gift each period. This description provides the basis for implementing the simulation schedule.

A subtle specification issue arises in the Gift World conceptual model. Is giver solvency determinee when the step begins or when it is a giver’s turn to give? These differ slightly, since in the second case, an initially insolvent giver might receive a gift before deciding to give. Later lectures pay more attention to synchronization issues. For now, assume that the solvency of all givers is determined in advance of any giving.

The simulation schedule embodies the conceptual model of gift giving in a fixed population, which is the core concept behind this model’s dynamics. Each period, each solvent giver will give a gift. Conventionally, a step activity handles the core simulation schedule. The following activity summary turns the conceptual description of gift giving into a tentative simulation schedule. (Recall that a solvent agent has wealth > 0.)

activity:

step

summary:
  • Each solvent giver prepares to give a gift by choosing a gift recipient.

  • Then, each solvent giver gives a gift.

Basic Model Step

In the GiftWorld01 project, implement the simulation model step as summarized above. Start by adding only summary comments. Then add the implementing code for each comment. Develop a test that your step could is correctly implemented.

Running a Gift World Simulation

The conceptual model of Gift Word does not suggest a natural stopping point. However, the computational implementation should not simply run the simulation forever. In this lecture, the resolution of this problem is to leave the decision up to the user of the simulation model. Create a runsim activity that runs the simulation a user-specified number of times. [1] Use the following activity summary, which depends only on the setup and step procedures. This means that this runsim is very familiar; it contains nothing that is particular to the GiftWorld01 model.

activity:

runsim

parameter:

nSteps: Integer, the number of iterations.

summary:
  • Execute the setup activity to set up the simulation.

  • Repeat the step activity nSteps times.

Running the Simulation

In the GiftWorld01 project, implement the runsim activity as summarized above. Run a \(100\) step simulation and then print out the final wealths of the agents.

Gift World Outcomes

With a working simulation model in hand, it is time to examine the simulation outcomes. This data analysis phase requires us to access and analyze data from the simulation. There are many possible approaches to model observation, both graphical and statistical. The data analysis typically uses these observations to test any hypotheses derived from the conceptual model.

This section focuses one simulation outcome: the distribution of wealth at the end of a simulation run. This requires access to the value of the wealth attribute of each giver. Begin the data analysis phase by producing some simple descriptive statistics of these values. Choose summary measures that expose features of the final wealth distribution.

Access the final wealth of givers from a \(100\) iteration simulation. Determine the mean value of wealth. Is it close to your recorded prediction? How about the median value of wealth; is it pretty close to the mean?

Produce a five-number summary for the wealth data. (If needed, review the five-number summary discussion in the Basic Statistics supplement.) Do the data seem to be grouped fairly symmetrically around the median? Is there evidence in the five-number summary that the data are clustering (or not) around the median?

Basic Descriptions of Final Wealths

Recall that the total wealth and the number of agents remain unchanged during a simulation. This pins down the per capita wealth of givers, so the mean wealth of agents must not change. A typical five-number summary after \(100\) iterations of a Gift World simulation show a median wealth near this mean, roughly symmetric quartiles within 10% of the median, and roughly symmetric minimum and maximum within 35% of the median. Such simulation results indicate that the behavior of Gift World agents changes the initially egalitarian wealth distribution of one with modest variation, rather symmetrically distributed around the mean.

Exporting the Gift World Data

The initial exploration of simulation outcomes is often graphical. For example, when the simulation toolkit supports them, GUI widgets can be very informative about the simulation outcomes. Nevertheless, the data analysis is typically supported by the export of the focal simulation data to an external file. Very often, in order to facilitate the analysis of simulation data, modelers export simulation data to a spreadsheet file.

Exported data may record the state of a simulation model, either after each iteration or at a single point in time (e.g., after the final iteration). This section focuses on the analysis of the end-of-simulation data, which may be exported by an exportWealths activity.

activity:

exportWealths

parameter:

filepath: String, location of output file (e.g., out/gwWealths100.csv)

summary:
  • Prepare the output file for new data export.

  • For each giver, write the value of its wealth attribute to a separate row.

  • Close the file after the data export is complete.

Add the exportWealths activity to the GiftWorld01 project. Use this to export the end-of-simulation wealth data.

Graphical Analysis of Final Wealths

Modern spreadsheets offer powerful facilities for data analysis, including useful statistical graphics. The box plot and the histogram plot are two widely used graphical characterizations of the distribution of a single variable. The next exercise uses these plots to analyze the exported wealth data.

Import the exported wealth data into a spreadsheet or another suitable application. Produce a box plot of this data, and relate it to the five-number summary. Based on an examination of the box plot, predict the shape and location of a histogram of the data. Create a histogram of the wealth data. How good were your predictions about its shape?

The simplest box plot is a visual display of the five-number summary. The earlier discussion of the five-number summary for this simulation leads us to expect a roughly symmetric histogram, centered on the per capita wealth of the givers, around which it is somewhat clustered. Figure histBasicGW000100 illustrates a typical outcome. Although every giver has an identical starting point and identical behavior, the final wealth outcomes display substantial heterogeneity. To phrase this more provocatively, the wealthier agents are not more deserving. They are just luckier.

images/histBasicGW000100.svg

Wealth Distribution (Gift World after 100 Iterations)

Algebraic Characterization of the Wealth Distribution

This section is algebraically focused and may be skipped on a first reading of the present lecture. The goal is to seek mathematical support for our attempts to characterize the wealth distribution of Gift World. This section offers a simplified statement of the arguments of [Dragulescu.Yakovenko-2000-EurPhysJB], who applied the mathematics of statistical mechanics to the repeated redistribution of a fixed amount of wealth.

Microstate and Macrostate

For the sake of readability, the mathematical notation of this section is more compressed than the previous computational notation. In Gift World, there are \(N\) agents and constant total wealth \(W\). Agent \(i\) has wealth \(w_i\), for \(i \in [1..N]\). The values of all the \(w_i\) constitutes the microstate. It must satisfy

\begin{equation*} W = \sum_{i=1}^{N} w_i \end{equation*}

An individual may have anywhere from no wealth to all of the wealth. Therefore, there are \(W+1\) conceivable values of one individual’s wealth: \(k \in [0 .. W]\). Of course, if one individual has all of the wealth, then the rest must have no wealth.

Represent the number of agents with wealth \(k\) as \(n_k\). Define the macrostate to be the values of all the \(n_k\). That is, a macrostate of a Gift World is an absolute frequency distribution. It is one out of all the frequency distributions that divide up all of the available wealth. The macrostate naturally satisfies two equalities: the total number of individuals must be \(N\), and the sum individual wealths must be \(W\).

\begin{equation*} N = \sum_{k=0}^{W} n_k \end{equation*}
\begin{equation*} W = \sum_{k=0}^{W} k \, n_k \end{equation*}

Create \(1000\) agents with a wealth attribute. Allocate \(100,000\) units of wealth randomly across these agents, where each unit of wealth is equally like to be allocated to each agent. Predict what a histogram of the resulting wealth distibution will look like. Create a histogram of the resulting wealth distibution and compare it to your prediction.

Theoretical Analysis: Boltzmann Distribution

Consider all the possible different ways wealth can be distributed in the population. Exercise ex-boltzmannSim asks you to produce one of them. There are many ways to produce any particular frequency distribution over wealths. Given the macrostate \((n_0,\dots,n_W)\), we may count the number of microstates that produce this macrostate.

First ask, how many ways can exactly \(n_0\) agents be selected from the set of all agents? Order does not matter, so as shown in the Basic Statistics supplement, the basic algebra of counting ensures that the answer is the following.

\begin{equation*} \frac{N!}{(N-n_0)! n_0! } \end{equation*}

Next ask, from the remaining \((N - n_0)\) agents, how many ways can exactly \(n_1\) agents be selected from the set of remaining agents? Again, order does not matter, so the answer is:

\begin{equation*} \frac{(N-n_0)!}{(N-n_0-n_1)! n_1!} \end{equation*}

Now ask, how many ways are there to do both things: make one group of \(n_0\) agents, and then another of \(n_1\) agents? The product rule of counting says that this is the product of the previous two results.

\begin{equation*} \frac{N!}{(N-n_0)! n_0! } \frac{(N-n_0)!}{(N-n_0-n_1)! n_1!} = \frac{N!}{n_0! n_1! (N-n_0-n_1)!} \end{equation*}

Continue in this way with the remaining \(N-n_0-n_1\) agents. How many ways can exactly \(n_2\) agents be selected from the set of remaining agents? And so on. In the end, the folded product is

\begin{equation*} \Omega[n_0,\dots,n_W] = \frac{N!}{\prod_{k=0}^{W} n_k!} \end{equation*}

This is the number of different microstates that produce this particular macrostate. To use this information to determine the macrostate that is most likely, choose the \(n_k\) to maximize \(\Omega\). Many people have explored this problem, and we may take advantage of their work to turn to a well-known, simplifying approximation. Stirling provides an approximation of the logarithm of a factorial.

\begin{equation*} \ln[N!] \approx N(\ln[N] - 1) \end{equation*}

We will apply this to the expression for \(\Omega\).

\begin{align*} \ln[\Omega] &\approx N (\ln[N]- 1) - \sum_k n_k (\ln[n_k] - 1) \\ &= N \ln[N] - \sum_k n_k \ln[n_k] \end{align*}

Now, define the relative frequency \(f_k=n_k/N\), and note that the relative frequencies must sum to \(1\). Therefore

\begin{align*} \ln[\Omega] &\approx N \ln[N] - \sum_k N f_k \ln[N f_k] \\ &= N \ln[N] - N \sum_k f_K (\ln[N] + \ln[f_k]) \\ &= N \ln[N] - N \ln[N] - N \sum_k f_k \ln[f_k]) \\ &= -N \sum_k f_k \ln[f_k] \\ &= N \big( -\sum_k f_k \ln[f_k] \big) \end{align*}

The value \((-\sum_k f_k \ln[f_k])\) is called entropy, so unconstrained optimization would choose the relative frequencies so as to produce the maximum entropy. Of course, the two constraints described above (fixed total population and total wealth) must be honored. We can restate these as follows.

\begin{equation*} \sum_{k} f_k = 1 \qquad \sum_{k} k f_k = W/N \end{equation*}

Introduce constraint-violation penalties (Lagrange multipliers) \(u_1\) and \(u_2\). The first-order conditions are then (for \(k=0,\dots,W\)) the following.

\begin{equation*} \ln f_k = 1 - u_1 - u_2 k \end{equation*}

or equivalently

\begin{equation*} f_k = \exp[1 -u_1 - u_2 k] = \exp[1-u_1] \exp[-u_2 k] \end{equation*}

Substitute this into the population constraint to get

\begin{equation*} 1 = \sum_k \exp[-u_1 - u_2 k] = \exp[-u_1] \sum_k \exp[-u_2 k] \end{equation*}

So for each \(n_k\) we have

\begin{equation*} f_k = \frac{\exp[-u_2 k]}{ \sum_k \exp[-u_2 k]} = \frac{1}{Q} \exp[-u_2 k] \end{equation*}

Here \(Q = \sum_k \exp[-u_2 k]\) is called the partition function. Summing up the wealth-weighted relative frequencies must produce mean wealth.

\begin{equation*} \frac{W}{N} = \sum_k k f_k = \frac{1}{Q} \sum_k k \exp[-u_2 k] \end{equation*}

Note that \(dQ/du_2 = -\sum_k k \exp[-u_2 k]\). So we have

\begin{equation*} \frac{W}{N} = \frac{1}{Q} \frac{dQ }{ du_2} = \frac{d(\ln Q)}{d u_2} \end{equation*}

The Evolution of Gift World Inequality

The initial results from simulating a Gift World indicate that wealth is not tending towards an egalitarian distribution, despite an egalitarian starting point. In the Financial Accumulation lecture, the 80-20 share ratio served as a summary measure of wealth inequality, where a minimum share ratio of \(1\) characterizes perfect equality. The final wealths of the Gift World simulation described above typically produce a ratio of more than \(1.3\). This section focuses on a different measure of inequality: the Gini coefficient.

Lorenz Curve

As a preliminary to discussing the Gini coefficient, this section reviews a famous and useful graphical display of inequality: the Lorenz curve, as presented in the Basic Statistics supplement. A Lorenz curve for wealth plots cumulative wealth against the cumulative population share. This visualization underpins the simplest conceptual introduction to the Gini coefficient of inequality.

One point on the Lorenz curve will represent proportion of total wealth held by the poorest 10% of the population, while another will represent proportion of total wealth held by the poorest 20% of the population (including the poorest 10%), and so on. As shown in the Basic Statistics supplement, following this procedure produces a curve similar to the one in Figure lorenzGW01, where an accompanying 45° line represents a perfectly egalitarian distribution. (With perfect equality, the poorest 10% of the population have 10% of total wealth.)

images/lorenzGW01.svg

Lorenz Curve

Gini Coefficient of Inequality

In this graphical presentation. the Lorenz curve always lies below the line of perfect equality. A Lorenz curve that lies further from the equality line indicates more inequality. The Gini coefficient of inequality summarizes this inequality with a single number between \(0.0\) and \(1.0\).

In terms of Figure lorenzGW01, the Gini coefficient is \(A/(A+B)\). A perfectly equal distribution, where every agent has the same wealth, produces a Gini coefficient of \(0\). A perfectly unequal distribution, where one agent has all the wealth, produces a Gini coefficient of \(1\).

Like the quantile dispersion ratios explored in the Financial Accumulation lecture, this measure of inequality satisfies the transfer principle and is anonymous, scale independent, and population independent. In addition, the range of possible values from \(0\) (perfect equality) to \(1\) (perfect inequality) makes the Gini coefficient particularly intuitive and conducive to comparison. Finally, unlike the quantile dispersion ratios, computing a Gini coefficient produces a sensible value even when the wealth data include many zeros.

Each point on this Lorenz curve represents the cumulative wealth share of a cumulative population share. With perfect equality, the two shares would be equal, thereby producing a point on the 45° line. Instead there is an inequality gap. As shown in the Basic Statistics supplement, the area \(A\) is the average of these inequality gaps; the Gini coefficient of inequality is correspondingly twice the mean gap. The following exercise typically produces a Gini coefficient between \(0.05\) and \(0.06\) for the Gift World simulation described above. Compared to real-world wealth inequality, this is very low.

Copy the GiftWorld01 project to a new project named GiftWorld02, which is the project for this section. The first addition to the project is a gini function. Use this to produce a Gini coefficient for the final wealths in the previous Gift World simulation.

The Evolution of Inequality in Gift World

The basic Gift World simulation starts with a perfectly equal wealth distribution. This produces a Gini coefficient of \(0\). As the givers give their gifts, the wealth distribution becomes less equal. This section further explores the emergence of inequality in a Gift World. One approach to such an exploration is to monitor the Gini coefficient over time. The following exercise approaches this by exporting the current Gini coefficient after each iteration step. To support this, implement a recordStep activity base on the following summary.

activity:

recordStep

summary:
  • Apply the gini function to current wealths to compute the current Gini coefficient of inequality.

  • Open the output file (e.g., out/ginisGW100.csv) for data export.

  • Append to a new row of this output file the comma-separated current values of ticks and the Gini coefficient.

  • Close the output file.

Add the recordStep activity to your GiftWorld02 project, making use of the gini function (above). Append this to the rusim activity as the final iteration action. Generate Gini data from the basic \(100\) step Gift World simulation, and then plot the evolution of the wealth Gini, step by step.

images/giniBasicGW000100.svg

Gini Coefficient over 100 Periods (Gift World)

Figure giniBasicGW000100 illustrates a typical simulation outcome for the evolution of the Gini coefficient over time. This figure clearly illustrates the emergence of inequality. At the same time, it prompts additional exploration: the strong upward trend in inequality suggests that there is more inequality to come. To explore the sensitivity of the inequality analysis to the timespan of this simulation, increase the simulation length by an order of magnitude. The next exercise explores the resulting final wealth distribution.

Allow the basic Gift World simulation to run for a full \(1000\) iterations. Create a histogram of the final wealth distribution.

To support this exercise, parameterize the maximum number of iterations, and change the rumsim activity to rely on this parameter.

images/histBasicGW001000.svg

Wealth Histogram (Gift World, 1000th iteration)

Figure histBasicGW001000 illustrates a typical final distribution of wealth after \(1000\) iterations. This broadly resembles the result after \(100\) iterations, although the values are somewhat more spread out. This higher variance in individual wealth should show up in measures of wealth inequality. The next exercise looks at how the passage of more time affected the Gini coefficient for wealth.

Allow the basic Gift World simulation to run for a full \(1000\) iterations. Plot the evolution of the wealth Gini.

Including more than \(100\) or \(200\) points is seldom useful in a time-series plot. One way to support this exercise is to parameterize the the observation frequency and change the rumsim activity to determine whether to record the step by relying on this parameter.

images/giniBasicGW001000.svg

Gini Coefficient over 1000 Periods (Gift World)

Figure giniBasicGW001000 correspondingly shows that, as anticipated, the Gini coefficient continued to rise. In this case, it more than tripled to about \(0.18\). Problematically, the Gini still displays a tendency to rise over time. Let us continue this pursuit of a characterization of the behavior of wealth inequality. To facilitate such visual explorations, a GUI can be useful.

Adding a GUI

The following exercise draws on what you learned about GUI construction in earlier chapters. Use this GUI to further explore the long-run behavior of a Gift World.

Create a GUI for the GiftWorld02 project, with the following features.

  • Sliders for setting the maximum number of iterations and the observation frequency.

  • Buttons to setup and run the simulation.

If supported by your simulation toolkit or language, add a dynamic histogram of the the giver wealths and a time-series plot for the Gini coefficient. Optionally add a progress indicator for the simulation.

Further Evolution of Inequality in Gift World

Figure histBasicGW010000 illustrates a typical final distribution of wealth after \(10,000\) iterations. This displays a startling divergence from the previous results: the values are not just more spread out, they are also highly skewed. This result highlights the possibility that simulation results can be highly sensitive to the length of the simulation.

images/histBasicGW010000.svg

Wealth Histogram (Gift World, 10000th iteration)

Figure giniBasicGW010000 correspondingly shows that, as anticipated, the Gini coefficient continued to rise. In this case, it more than doubled to about \(0.42\). Furthermore, although somewhat moderated, the Gini still displays a tendency to rise. It appears that, once again, we must increase the number of iterations.

images/giniBasicGW010000.svg

Gini Coefficient over 10,000 Periods (Gift World)

At this point, it is reasonable to wonder if the Gini will just continue to rise toward perfect inequality. However, it turns out that things settle down after a few tens of thousands of iterations. To illustrate, run the basic Gift World simulation for \(40,000\) iterations. This simulation will take a while to run. Depending on the computer hardware and the implementation language, it might even take enough time for a coffee break or perhaps lunch.

Figure histBasicGW040000 illustrates a typical final distribution of wealth after \(40,000\) iterations. As anticipated base on previous results, the distribution remains highly skewed. However, Figure giniBasicGW040000 finally suggests that we have arrived at a description of the long-run tendencies of the basic Gift World. In Gift World, the Gini coefficient continued to rise until is was nearly \(0.50\). Then it appears to stabilize.

images/histBasicGW040000.svg

Wealth Histogram (Gift World, 40000th iteration)

images/giniBasicGW040000.svg

Gini Coefficient over 40,000 Periods (Gift World)

Conclusions

This exploration has raised a difficult question: how long must a simulation run to be adequately informative about its long-run behavior? An analysis of inequality at various time horizons led to very different conclusions. The Gift World results after \(100\) iterations proved uninformative about its long-run trends. Even the analysis after \(1000\) iterations is misleading about long-run inequality. It takes tens of thousands of iterations before the long-run tendencies are fully manifest.

This lecture points identifies the problem of choosing a simulation stopping point but does not attempt to answer the difficult question of when to stop. The approach above is simply to run the simulation for longer and longer periods of time until finally it appears (visually) to be in some kind of stochastic steady state. There is no attempt to quantify the detection of such a state.

At this point in our analysis, it appears the Gini coefficient for wealth in this basic Gift World tends to approach a value around \(0.5\) over time. While this is somewhat low when compared the values observed in national economies, it approaches the values of Japan or China. It is interesting that even such a simple gift-giving economy is able to produce levels of wealth inequality comparable to some real economies.

Gift World Exploration, Resources, and References

Exploration

  1. What is the Gini coefficient for wealth in a country where all wealth is evenly shared by half the population, but the other half has no wealth What approximately is the Gini coefficient for wealth in a country where half the wealth is held by one person and the other half is evenly shared by the rest of the population? (Hint: draw the Lorenz curves.)

  2. Introduce a maximum number of iterations as a model parameter. Add a stopping condition to the model, based entirely on this permitted number of iterations. The simulation should stop when the number of iterations reaches maxiter.

  3. Make exportWealths safer by asking for confirmation before meddling with an existing file. Do the same for the setup of the file to be used by recordStep.

  4. Store the output-file names as global constants, and modify the exportWealths and recordStep activities (and setup) to use these file names.

  5. Implement a general exportArray activity that consumes a filename (as a string) and a sequence of numbers and writes the numbers as a column to a text file. (Remove any pre-existing data.)

  6. Modify exportWealths to use exportArray (from the previous exercise).

  7. Modify the collection of time-series data to accumulate it in some kind of dynamic array, and then write it all out at the end of the simulation (instead of writing it out as a recordStep activity as it is collected).

  8. The text states that Figure giniBasicGW000100 illustrates a typical outcome. This means that in a collection of \(100\)-iteration simulations, most of them will resemble this figure. Propose an approach to exploring the accuracy of this claim. (You do not need to implement this approach.)

  9. GUI Agent Display: Set up the GUI representation of givers. Add color to agents to help us visually distinguish them. Color agents based on their wealth. (White means not wealth; increasingly chromatic greens represent more wealth.) Make this agent display dynamic (if your simulation toolkit supports this). Run a hundred iterations of the simulation, and report any observations about the distribution of wealth.

    Over time, we observe the emergence of a few wealthy agents and quite a few poor agents. This observation contradicts the hypothesis that the limiting wealth distribution of Gift World will be egalitarian.

  10. Based on the discussion in the Basic Statistics supplement, add to this model a procedure to plot the ECDF of wealth. Use it to plot an ECDF for the final Gift World wealth distribution. If your toolkit allows it, create a dynamically updated version, plotting each tick as the simulation runs.

  11. The basic Gift World simulation appears to approach a long-run value of the Gini coefficient near \(0.5\). This simulation is based on \(1000\) agents. Does the result appear to be sensitive to population size? For example, what if there are half as many agents? Or, what if there are twice as many agents? (Add an nAgents slider to make it easy to explore this question.)

  12. Introduce a model parameter named giverInitialWealth, which is a positive integer. Each agent still begins with identical, positive initial wealth, but now it is giverInitialWealth instead of \(100\). Additionally, introduce a giftSize parameter, which determines the amount of each gift.

    Model Parameters

    name (type)

    value

    giverInitialWealth : Integer = 100

    giftSize: Integer = 1

  13. Set the giftSize of a single agent to \(0\). What happens to this agent’s wealth over time?

  14. In the baseline model, a giver may (with low probability) give a gift to itself. If this seems objectionable, consider the following fix: a giver gives only to another giver. In this case, since the set of givers in a world remains unchanged during a simulation, you may find it useful to provide givers with an others property. Initialize this to all the other givers, so that a Giver need only create others once. (This will allow the simulation to run a bit faster.)

  15. Charitable Giving

    Change the simple gift economy so that there is only charitable giving, in the following sense. Leave the planGift activity unchanged, but a giver who plans to give a gift actually does so to a less wealthy recipient.

  16. Local Giving

    Change the simple gift economy so that there is only local giving. That is, as its gift recipient, each agent picks not just any random agent but instead a random neighbor. (Assuming the use of square patches on a grid and a torus topology, the neighbors of an agent will the nearest \(8\) other agents.) This requires a small change to giveGift. Discuss any changes in outcomes.

  17. Profiling

    If the simulation seems to run slow, use profiling to try to find out why.

  18. Implement the givers using an array of wealths rather than patches. How does this affect the simulation speed?

  19. Is Gift World is characterized wealth mobility? That is, do any poor agents in a Gift World have a reasonable chance of becoming rich?

  20. What difference might it make if gifts are only given to neighbors?

Resources

The simplest Gift World model closely resembles the Simple Economy model of [Wilensky.Rand-2015-MIT] [ch. 2], which is in the NetLogo Models Library. A similar implementation using Python exists as a Mesa tutorial. For basic details about the Lorenz Curve, see the Wikipedia entry. For an introduction to Stirling’s approximation, see the Wikipedia entry.

References

[Bandini.Manzoni.Vizzari-2009-JASSS]

Bandini, Stefania, Sara Manzoni, and Giuseppe Vizzari. (2009) Agent Based Modeling and Simulation: An Informatics Perspective. Journal of Artificial Societies and Social Simulation 12, Article 4. http://jasss.soc.surrey.ac.uk/12/4/4.html

[demaio-2007-jech]

De Maio, Fernando G. (2007) Income Inequality Measures. Journal of Epidemiology and Community Health 61, 849--852.

[Dragulescu.Yakovenko-2000-EurPhysJB]

Dragulescu, Adrian A., and Victor M. Yakovenko. (2000) Statistical Mechanics of Money. The European Physical Journal B 17, 723--729. https://arxiv.org/abs/cond-mat/0001432

[Lorenz-1905-JASA]

Lorenz, M.O. (1905) Methods of Measuring the Concentration of Wealth. Publications of the American Statitical Association 9, 209--219.

[Wilensky-2017-CCL]

Wilensky, Uri. (2017) NetLogo 6.01 User Manual.

[Wilensky.Rand-2015-MIT]

Wilensky, Uri, and William Rand. (2015) An Introduction to Agent-Based Modeling: Modeling Natural, Social, and Engineered Complex Systems with NetLogo. Cambridge, MA: MIT Press.

[Wooldridge.Jennings-1995-KER]

Wooldridge, M.J., and N.R. Jennings. (1995) Intelligent Agents: Theory and Practice. The Knowledge Engineering Review 10, 115--152.


Appendix: Gift World Details and Hints

Implementing Gift World in Python

Build an object oriented implementation in Python by creating two classes: World and Giver. A World has a givers attribute, which hold the collection of givers. Methods of the World class set up and run the simulation by calling on the givers to plan and give their gifts.

Givers

A Giver class needs wealth and donee attributes. Behaviors (methods) of a Giver include planning a gift (by choosing a recipient and gift amount) and giving a gift (by transferring wealth to the recipient). Use the choice function, provided by the random module, to choose a random gift recipient.

For this implementation, add a World class that sets up and runs the simulation. It proves convenient for a giver to know its World, so world should be an additional data attribute of a giver. During setup, a world creates all the givers and stores them as a givers attribute. A Giver finds potential recipients in this attribute of its world.

Model the wealth transfer handled by giveGift on the pay behavior developed in the Gambler’s Ruin lecture. A Giver with zero wealth should not give a gift; handle this during the planning phase. The resulting planGift and giveGift procedures should pass the following test.

version:

2023-07-20