|Home | About | Journals | Submit | Contact Us | Français|
There is growing interest among urban health researchers in addressing complex problems using conceptual and computation models from the field of complex systems. Agent-based modeling (ABM) is one computational modeling tool that has received a lot of interest. However, many researchers remain unfamiliar with developing and carrying out an ABM, hindering the understanding and application of it. This paper first presents a brief introductory guide to carrying out a simple agent-based model. Then, the method is illustrated by discussing a previously developed agent-based model, which explored inequalities in diet in the context of urban residential segregation.
Among urban health researchers, there is growing interest in conceptualizing complex problems using a system framework 1 and in using systems modeling tools to explore how components of a complex problem interact, are sustained or changed, and ultimately identify areas for intervention 2,3. In particular, system simulation approaches are useful tools for understanding processes and structures involved in complex problems, identifying high-leverage points in the system and evaluating hypothetical interventions 1 – an exercise that would be impossible to do by collecting and analyzing real-world data.
One tool that has been increasingly used to examine urban health issues is agent-based modeling (ABM) 4,5. Agents are given traits and initial behavior rules that organize their actions and interactions. Stochasticity can be included in the assignment of agent characteristics and in determining which agents interact and how agents obtain information and make decisions. The model is run over time and repeated numerous times, to obtain a distribution of possible outcomes for the specified system. The micro-entities, referred to as “agents”, are anything that alters its behavior in response to input from other agents and the environment 6.
ABM is able to accommodate high heterogeneity in agent characteristics and interactions between agents and environments, as well as features like dynamics, feedbacks and adaptation, which are impossible to represent in traditional statistical models 7,8. Agents can be defined at multiple levels, including individuals or group of individuals (e.g., families, institutions, policy-making bodies etc.). Research questions that require significant heterogeneity within and between agents and diverse spatial and relational elements are well-suited to ABM 9. In urban health research, simulations can be used to explore dynamic scenarios involving diverse entities and settings such as the built and social environment, city agencies, legislative bodies, health services, individual residents and families. Some agent-based models include detailed data and strive for high realism 4 while others are abstract 5,10.
Despite the ABM suitability to research complex problems in urban health, it is a new tool to many researchers. One important barrier to foster ABM adoption among researchers is their unfamiliarity with steps needed to carry out the modeling. Therefore, the purpose of this paper is to provide a very brief introductory guide to carrying out a simple agent-based model. We then use a previously constructed model 11 to illustrate the steps one can take when building a simple model. This is only a brief guide; before starting a computational model, it is recommended that readers refer to comprehensive guides 9,12,13,14.
As in all research endeavors, first the investigator must define the question(s) of interest. To outline the question(s), researchers rely on mental models encompassing components and mechanisms relevant to the topic of interest. The problem is that these models usually remain implicit, along with their assumptions, internal consistency and logical consequences 15. Therefore, to define the research question(s), the initial step is to construct an explicit conceptual model. At the first stage, this should be a broad conceptual model characterizing the general problem and some specific features related to it. Then, one can identify where the significant gaps in knowledge are, and a relatively simple aspect of the problem to explore in depth. In the second stage, the researcher articulates a more specific, narrower conceptual model around this relatively simple aspect. At this stage, one works to identify the key elements that may be most important to the question(s) and think about dynamic processes and feedbacks that may play an important role.
There are three important points to highlight about constructing conceptual models. First, conceptual models can be based on either theory or empirical data, or both. The researcher may construct a new theoretical model, or explore and extend someone else’s model. Second, the conceptual model is a prerequisite for computational models, but by itself has high value and can be a product for those unwilling to undertake computational modeling. Third, a common mistake among researchers starting in ABM is to try to write a computational model that addresses many elements within the broad conceptual model identified before. It is important to keep in mind that all models are analogies of real systems, and so they will fail to represent reality 16. Good models balance simplicity and adequate representation, incorporating enough key elements and processes and ignoring those that are not directly relevant.
After defining the specific research question(s), we need to choose the most suitable tool to carry out the work. Not all questions posed within a system framework need to be answered using a systems science tool; they may be better answered with statistical methods or qualitative approaches. Moreover, ABM is not the only tool for modeling dynamic, complex systems. Other systems science tools, such as systems dynamics, may be preferable and more appropriate 9,17.
Modeling is an iterative process of using a conceptual model to plan and execute the computational model, and then potentially rethinking the conceptual model. The iterative process of modeling is often where the most valuable insight occurs, rather than in the “final results”. Even though modeling is an iterative process, investigators still need to begin with a clear model objective. From there, investigators must plan the simulation study, including a preliminary plan for setting up and testing experimental conditions, and how the outcome will be assessed. This is also the time to plan what types of entities will fill the system and the temporal and spatial extent of the model.
Agents and their characteristics should be specific to the needs of the research question(s). Select few agents and the minimum characteristics required to address the question(s). Agents do not need to appear to be “real”. For example, agents representing humans do not require specification of age, sex, race etc. unless those characteristics are involved in processes or decisions that will be modeled. In a simulation framework, there is a limitless range of options, thus researchers need to curb the enthusiasm for modeling numerous types of actors and characteristics. Adding a lot of detail does not necessarily result in better insight and can make very difficult to execute, test, and interpret the model.
The simulated “world” does not need to represent the real world; instead, it must represent the simulation space that is most appropriate to the specific question(s) being asked. If mapping to a local “real” geography is important, most programming environments allow users to import Geographic Information System (GIS) layers as inputs to replicate an actual urban space or configure a generic abstract space.
The researcher must define the main objectives of the agents, thinking through the processes that are essential to answering the research question(s) and choose to ignore the rest.
Agents may be required to take action and/or make decisions in response to single stimuli or weigh multiple criteria. Utility functions are aides for decision making when factoring in multiple criteria and allowing each agent to rank options and make a choice. Theory and empirical research can be incorporated in decision-making rules, drawing in particular from the fields of economics, cognitive science, neuroscience and computation science 18,19. Typically, there is a gap in the data/theory that inform decision making in the specific contexts we want to model. Thus, researchers may not have strong conceptual justification for a particular utility function and instead choose one that has been widely used and that provides reasonable results. Deciding on the specification of the utility function can be difficult and ultimately one will need to test sensitivity to the functional forms and inputs.
In ABM, randomness can be included in the construction of each dimension. Researchers usually add randomness to the utility function itself, in order to represent uncertainty they have about a particular equation and the parameters within it, as well as to represent bounded rationality 18. Bounded rationality refers to the fact that decision making is not a perfectly rationale procedure. Decisions are made with incomplete information or even for reasons unknown to the actor making the decision.
The model is run over time steps. Model activity can be mapped to a timeframe in the real world; however, real timeframes are not required and may make little sense in an abstract model. For some models, there may be activities that occur in fixed time intervals or triggered when particular situations transpire.
A key advantage of complex systems simulations – including ABM – is the ability to incorporate dynamics and feedbacks within the model, which may be important to the process being studied. Researchers should be deliberate about incorporating dynamics and feedbacks. Dynamics allow changes over time to agent characteristics or decision rules, in ways that could affect the process under study. For example, some questions involve lifecycle processes, where deaths and births are important to include in the model for equilibrium or to explore how much information, traits, and risks are passed from one generation to another. Feedbacks can be represented as responses to structural features (the structure of the world/environment, which could be exogenously imposed) and/or behavioral conditions (how behaviors are altered by other behaviors, often an endogenous process) 20. Feedbacks are typically most interesting when represented in both structural and behavioral processes, as they can generate changes/new behaviors at both the agent level and the system at large 12,20. Implementing many dynamics and feedbacks into the early model stage will make it impossible to interpret and verify the system 9, so it is recommended to start small and expand.
In ABM, stochasticity is part of many steps (initialization, behavior rules etc.), thus, it is important to run the model multiple times to obtain the distribution of outcomes and then summarize results across multiple runs. Note that, in ABM, this is not assessing how well the model fits the intended system or observed world; it is only assessing the impact of stochasticity embedded in the model 14. Tools can be used to determine the number of runs necessary to generate a representative result (for example, the Simulation Parameter Analysis R Toolkit Application package developed for R 21). Absent tools, it is reasonable to try 10 or 30 runs on a particular scenario and evaluate the magnitude of the uncertainty across runs.
ABM outputs are different from those generated from statistical analysis. The main outputs are the evolution of the system and its components (process outputs) and a summary of the “final” state (summary outputs). Process outputs are displayed in graphics or tables representing the system’s variables at each time step (or lightly summarized over multiple time steps), as well as visual representations of the system in action. Process data are especially useful for exploring and interpreting the system’s behavior, structure and emergence. Because any one-time step is representative of the system, in order to obtain a summary of the “final” state of the model, researchers can summarize the data of a representative/relevant interval at the end of the model run (e.g., averaging the outcome for the final 20% of the run). Due to the uncertainty of data inputs and modeling process, agent-based models are not prediction models and outputs should not be interpreted as precise estimates. Interpret results qualitatively rather than quantitatively. Look for strong patterns and large differences between summary outcomes across experiments; small differences are usually not worth noting.
During the modeling process, some procedures must be done to achieve the most useful and reliable model possible. Given that ABM can reveal counterintuitive processes, evaluating and testing models can be difficult. Unexpected results that appear interesting may be due to errors in computer programming or high dependence on initial choices or small variations in stochastic processes involved with strong positive or negative feedbacks. For this reason, researchers need to work to internally validate (verification and calibration) and externally validate the model:
ABM can be done in any language, but object-oriented programming languages are preferred (Python, C++, Java etc.). Commonly used interfaces/libraries are RePast (http://repast.sourceforge.net), NetLogo (http://ccl.northwestern.edu/netlogo), and AnyLogic (http://www.anylogic.com). A detailed and commented list of programming environments is presented by Kravari & Bassiliades 27.
Some protocols and standards were developed in order to increase transparency of ABM, reduce criticism that models are irreproducible, and provide a language that the scientific community can use to evaluate model validity. The most frequently used protocol is the ODD 28,29 (and ODD+D 30), which includes elements to make explicit the Overview, Design concepts and Details of the model. The example below does not explicitly follow this protocol, but we included a number of its components.
An income differential in diet quality has been observed in numerous studies illustrating that lower income is generally associated with worse dietary profiles 31,32. Thus, diet quality has been identified as a key factor in socio-economic inequalities in obesity and diet-related illnesses. There are three prevalent theories of dietary inequality and the variety of explanations highlights that inequalities likely occur within a complex system of interrelated processes that are not well understood:
We used ABM to explore the role that urban segregation can play in shaping dietary behaviors and to suggest policy levers that may be used to counter its effects. The model allowed us to focus on how location and household incomes and preferences interact over time to influence store availability and supply of healthy foods and hence have the capacity to affect income differences in healthy eating. See Figure 1 for a conceptual sketch of core features included in the model. We imposed several extreme scenarios for economic residential segregation and spatial clustering of healthy food stores (for details, see Table 1 at Auchincloss et al. 11). Then, we identified which particular scenario showed income differentials in diet that have been observed in previous empirical studies in the U.S., where higher incomes generally have better diet than low incomes 31,32. Then we used the selected scenario to run experiments that explored whether pricing and preference factors were capable of reducing income differentials in diet generated by segregation.
Only two types of agents were included: households and food stores 11.
Our question was abstract and not grounded in a specific city, thus the world did not require GIS layers or data that grounded it to a particular context. However, we needed to measure distance/proximity between agent locations and allow for clustering, thus, our model required a world with a measureable grid space. We chose a small grid space (50x50 grid) and each cell in the grid contained one household, thus 2,500 households in the world. At baseline, stores filled 2% of the grid cells, thus 50 stores (each store shared its cell with a household). In our model, stores made decisions after counting the number of customers. Thus, we needed a sufficient number of households to generate customers shopping at stores and the size of the world needed to be large enough to not skew results due to small samples/distances. We specified the space as toroidal, meaning that the world is a continuous space projection, so that boundaries would not present problems when agents calculated distances between themselves and the stores 37.
Households’ objective is to select a store and shop for food, measured by which food store is selected. Stores’ objective is to attract customers, measured by number of customers per period who selected the store.
At each time step, each household selected a store to shop. A time step was roughly conceived to represent about every 2–3 days as that frequency corresponded to food shopping frequency in empiric studies 38. However, the duration of the model did not literally translate to human months or years. In our model, the frequency of shopping did not change across households and time, because that was not central to our research question.
We needed households to choose which store to shop at by ranking the stores on dimensions via a utility function, described in the Equation 1. The dimensions selected for this model are not universal; rather, they were selected due to their relevance for the question we posed. The four dimensions for ranking stores were price of food at the store, distance to the store, the stores that household shopped at previously (household’s habitual shopping behavior) and the household’s preference for healthy foods. Justification for each of these dimensions is included in the supplementary data for the original paper 11. We selected a utility function that was able to balance each dimension, such that a low score in one dimension would not affect scores in other dimensions. We ended up using an additive form of the Cobb-Douglas function 39 that utilized both scores and weights. We did not use the multiplicative form because a low score in one dimension would make it difficult for a household to choose that store, even if the other scores were very high. We normalized the weights so they add to 1.0; thus, they have meaning only relative to each other. In Equation 1, i is the household, k is the dimension and ε is random noise (random variable, μ = 0, σ = 0.05) to represent bounded rationality 18:
In our model, scores for price and distance were allowed to vary by household income, because we wanted to match existing evidence that high-income households pay more for food and travel farther than low-income households. Each score was on a scale from 0 to 1, where 1 was the most preferred score. Table 1 shows details on the scoring and brief justification for the choices we made. Weights were constant parameters for all households and did not vary by household attributes. The values for weights were determined through iteratively testing and changing model rules to adhere to calibration criteria: high-income households should spend more on food 40 and travel at least as far as low-income households 41. Sensitivity to alternate weighting and scoring for the utility function and size and household/store density of the grid were examined (see Verification, Calibration, External Validation).
Stores were able to change the type of food they sold, but store prices remained fixed throughout the experiment. We devised a simple way to proxy dynamic processes in store behaviors in order to test the effect of stronger feedbacks between households and stores and to allow the household choice set to be slightly more dynamic. This “move-out/move-in” sub-model allowed low-performing stores to close. In locations without a store for a certain period (180 time steps), a new store could move into the old store’s location, either selling the same food type as the old one or changing food type. We preferred a this simple “move-out/move-in” sub-model for the following reasons: our model was not focused on store location decision making, we knew that we had imperfect information for modeling this process, and it would take a lot of effort to construct a retail site selection sub-model.
Main results are not reported here but the reader can find them in the original paper 11. Figure 2 is an example of the display from one simulation. The primary outcome measure was the income differential in diet (diet of high-income households minus diet of low-income households). Absolute diet values for high- and low-income households were secondary outcomes. A simplifying assumption was used to derive each household’s diet: if the household shopped at a healthy food store, they ate healthier food and had a better diet. Diet was summarized as the average proportion of times the household shopped at a healthy food store (i.e., diet of 0.5 meant they shopped at healthy food stores half of the time, diet values close to 0 meant they infrequently shopped at healthy food stores). Figure 3 is an example of how results can be summarized. Because uncertainty and randomness was built into agent initialization (e.g., agent location and attribute assignment) as well as store behaviors and households’ selection of which store to go to, each experiment was run 60 times. From this, we obtained the distribution of outcomes and then summarized as the median and the 5th to 95th simulation percentile. Experimental results were summarized by averaging diet for the final 20% of the run of the model.
The model was simple and very abstract, not intended to have high external validity or be highly realistic or quantitatively calibrated to data. As a tool for explaining observable phenomena and stimulating questions, this model had reasonable face validity. The calibration stage used observational studies and survey data from government and industry sources to guide agent decision-making rules for generating plausible behaviors. Agent behaviors were tested against available data to reflect intuitive and known behaviors, such as high-income households spending more on food 40 and traveling at least as far or farther than low-income households 41. Verification and calibration included testing sensitivity to alternate weighting and scoring for the utility function and size and household/store density of the grid. Figure 3 shows sensitivity summaries from the store behavior sub-model. The plot shows sensitivity to various assumptions in the store sub-model (“move-out/move-in” and changes in the type of foods are sold at the store; scenario #4 was used for the base scenario reported in the Auchincloss et al. original manuscript 11).
The model was developed using an old Java version of Repast (version 3.30, http://repast.sourceforge.net). Additional libraries and code were from the Center for the Study of Complex Systems at the University of Michigan (http://www.cscs.umich.edu) and were written in Java using a Windows/Eclipse environment (Figure 4).
We briefly discuss here three limitations of the model. First, we did not envision or execute a full representation of the processes that result in income differentials in diet. However, our stylization of the world is not itself a shortcoming and roughly matched our objective. Second, we did not “generate” changes in the built environment. Rather, we tested how the contexts shape behaviors by exogenously imposing various segregation contexts. This strategy was not elegant, but is not a significant shortcoming. There were two reasons we did not “generate” the spatial sorting and neighborhood segregation. First, the point of the model was to see what happens in segregated contexts, not to generate the context. Second, generating segregation is an ongoing investigation topic that a number of researchers have taken on and requires a lot of effort 42. The third limitation is that our model did not fully exploit the opportunity to model dynamics and feedback processes. We consider this a significant shortcoming. Feedbacks were primarily structural (not behavioral) and there was no formal learning and adaptation. For example, households reacted to their environment based largely on static attributes (their income, location, and preference) and only a few dynamics (habitual/past behavior and distance to store, which was somewhat dynamic due to move-out/ in store sub-model). Store agents exhibited only slightly more feedbacks: customer volume determined the probability of moving-out/in, which also enabled probabilities of changing the store’s food type.
Systems modeling tools are still new for urban health researchers, but could be applied to a diverse series of questions, such as: Under what conditions do particular urban problems change over time and why?; To what extent are interactions and feedbacks within and between entities shaping particular urban problems?; Under what conditions are we most likely to see unintended consequences to a planned intervention?. However, operationalizing these types of questions in a computational model will be difficult for many researchers. Modeling requires a large investment of time in computer programming and requires new ways of thinking. What follows are a few reminders when undertaking this work.
Complex systems models require training ourselves to think differently. The earliest stages of model conception are difficult. Despite wanting to go beyond traditional linear thinking, it can be challenging to envision how multiple influences and pathways are more than independent correlations among components and focus on feedbacks and interdependence between entities rather than direct causal linkages.
Given the limitless range of options available in ABM, the beginning modeler must ask a narrow question, work to establish a clear model purpose, and ignore processes that are not directly relevant. Those new to ABM will be surprised to find that a very simple question becomes very complicated to operationalize.
The researcher needs to constantly check that (s)he is not establishing conditions or behavior rules that essentially already verify the hypothesis of interest. For example, if one wants to explore income differentials in diet but our “base” models fix expensive stores as having healthy foods, then one would essentially pre-determine an income differential in the base model for all scenarios.
Do not become preoccupied with calibration and validation. Creating reliable and valid models is a difficult undertaking and should be approached sensibly. Many researchers spend most of their time and energy on calibration and validation and no time and energy remain for expanding on the science and exploring the most important questions.
Due to the stochastic nature of micro-processes, ABM is not appropriate for detailed prediction and outputs should not be interpreted as precise estimates.
Not all questions posed within a system framework need to be answered using a computation model. Even if the questions require a computational model, the type of product may not meet the researcher’s needs to make it worth the effort. First, the greatest value from modeling often comes from the modeling process itself rather than from the final model and its outputs 12. Second, model results allow for a qualitative interpretation that may not be satisfying to some audiences. Third, ABM results can be difficult to summarize and communicate, especially to audiences unaccustomed to interpreting simulations and ABM. For example, caveats need to be mentioned such as results are conditional on a confluence of other factors and on inputs and algorithms programmed into the model. Empirical research analyses also requires strong caveats/assumptions. However, because agent-based models are constructed under fully simulated conditions, some audiences will discount the value of findings from ABM.
In sum, conceptual and computational models of complex systems forces us to carefully identify problems and processes that are likely impacted by dynamics and feedbacks that we typically ignore. The process of envisioning these models can propel us to think more realistically about complex mechanisms and perhaps think more creatively about potential solutions. ABM is a new computational tool for urban health researchers to use to address seemingly intractable urban health problems. Researchers will need to evaluate for themselves whether it is a promising tool for their own research question.
A. H. Auchincloss was supported in part by the United States National Institute of Child Health and Human Development (Grant R01-NIH-NICHD). L. M. T. Garcia was supported by a scholarship from the Brazilian Coordination for the Improvement of Higher Education Personnel. We thank Jeremy Cook, Rick Riolo, Daniel Brown, and Ana Diez Roux for their contributions to the original article that is referenced in this manuscript.
ContributorsA. H. Auchincloss conceived the original idea of the paper, discussed, wrote and reviewed its content and approved the final version. L. M. T. Garcia discussed, wrote and reviewed the paper content and approved the final version.