AGENT-BASED SIMULATION AS TOOL FOR TEACHING PRINCIPLES OF MICROECONOMICS Michal Kvasnička Masaryk University, Faculty of Economics michal.kvasnicka@econ.muni.cz Key words: agent-based modeling, teaching microeconomics, price, scarcity Abstract: The paper proposes an agent-based computer simulation as a supplementary tool for teaching the principles of microeconomics. Such simulation can graphically illustrate how the individual behavior produces the studied aggregate outcomes, can bridge the gap between the abstract theories and the real world, and can mitigate the emotional aversion students have against some theories. The approach is demonstrated on a case of allocation of a scare resource: the model is described, the simulator is created, and its features are analyzed. The simulator has been made available on the Internet for free. Introduction Teaching principles of microeconomics has always been a difficult task for at least two reasons: 1) some students have a problem to grasp some theories because of their prejudices and value judgments (it is especially true for topics from the welfare theory), and 2) students often cannot see how the highly abstract theory corresponds to the real world. As the increasing part of the population studies at the college level, the teaching becomes even more difficult because of rising diversity of students’ abilities and prior education. In particular, more and more students are not helped by the language of mathematics and graphs we use to teach them but rather see them as an obstacle. The traditional way around these problems is to use classroom experiments (see e.g. [1]). In this paper, I propose another approach: computer simulations. The simulation has many advantages: 1) it is faster, more graphic, independent from the number of participants, and can be run at home, 2) it can be repeated many times, possibly with a changed setting, which allows the students to learn in an inductive way: the teacher asks questions, the students try to find answers from a simulation, formulate hypotheses with the help of the standard theory, and test their hypotheses by experimenting with the simulation, and 3) it can be framed with emotionally touching stories to overcome students’ prejudices. The best type of educational computer simulation in microeconomics seem to be the agent-based simulation (see e.g. [5] for a good introduction into this mathematical technique) because with a proper visualization it allows the students to observe how the individual agents’ respond to stimuli, how their individual behavior produces the aggregate outcomes, and what aggregate behavior correspond to what set of conditions. Moreover, it can introduce the students into the scientific use of the agent-based simulation (see e.g. [2] or [3]). In the rest of this paper, I will describe a new simulation I have created and use in teaching the principles of microeconomics course at Masaryk University. 1. Case study: price and scarcity One topic the students find especially challenging is the relationship between a price and scarcity and the way in which prices allocate scarce resources. It is difficult on the technical level because it is not obvious from the static charts what the consumers’ and producers’ surpluses might be at disequilibrium prices because it is not certain which customers buy and which producers sell at such prices. On the emotional level, it is difficult for students to accept that the price should rise when the resource get scarcer, e.g. after a disaster (various anti-price gouging laws show that it is difficult for the general public and law makers too). To address the problem, one might use a mental experiment, e.g. a question whether the parking in front of the only children’s hospital in the city should be free if the number of the parking lots is small and the hospital is near the city center (as in Brno) so that there is a great demand for parking both from the parents of the sick kids and from other city center visitors. Assuming that the parents of the sick kids are willing to pay for parking more than the visitors, it is efficient (and also better for the sick kids) if the parking is paid. If it was not, the place would be occupied by the visitors, and the sick kids would not be able to park there. However, the problem is somewhat tricky: 1) the optimal price depends on the number of the parking lots, the number of cars, the proportion of the cars with the sick kids, and the willingness to pay of the two groups of customers, 2) the cars come at a particular time, i.e. the demand randomly fluctuates, 3) the price affects not only what cars use the parking lot but also how long they stay, and 4) the market for parking is not competitive, hence it is not obvious whether the efficiency is higher if the price is monopolistic or if it is zero. For all these reasons, students might not be convinced with such a mental experiment. The simulation can provide a graphic illustration of the case. 2. Model implementation The simulator has been implemented in NetLogo 5.0.4 [6] and exported as an applet available at http://www.econ.muni.cz/~qasar/mse/netlogo_5_0_4/parking.html. For the model’s graphical interface, see Fig. 1. The model setting is as follows: There is a circular road consisting of forty “patches”, four parking lots (the white patches), and thirty two cars wanting to park. The red cars carry sick kids, the blue ones do not. Each car’s willingness to pay for a period of parking depends on three factors:  its general willingness to pay (WTP) in cents which is randomly drawn from a uniform distribution U(0,100) and is constant over the whole simulation,  whether the car carries a sick kid: if it does, its WTP is increased by 100 cents per period, and  how long the car is parking: its WTP decreases by 10 cents per period. Example: If a car has the general willingness to pay equal to 53, carries a sick kid, and has been parking three periods, its willingness to pay is 123 cents per one period now. The model is initialized in this way: 1) the road and parking lots are created, 2) the cars are created and assigned its general WTP, 3) some cars (ten in the initial setting) are assigned to carry sick kids; their WTP is increased temporarily by 100. The simulation proceeds in “days”; each simulation day consists of forty “ticks”. In each tick, the actual WTP of the parking cars is decreased by 10, each car that wants to leave the parking lot leaves (its actual WTP is reset), each car on the road moves one patch ahead, and each car that is staying in front of an unoccupied parking lot and wants to park (i.e. is willing to pay the price) moves into the parking lot. When a car with a sick kid leaves the parking lot, the kid in the car gets well and another kid gets sick at the same time to keep the number of the sick kids constant over time; their actual WTPs are modified accordingly. Aggregate statistics are calculated at the end of the day. FIG. 1: Part of the model web interface The user of the model can change the price for the period of parking at any time and watch what cars do and what cars do not park in the parking lot at any moment. The user can also see the parking lots owner’s profit, consumers’ surplus, total surplus, parking lot usage (total, by the visitors, and by the cars carrying the sick kids), and the number of cars with sick kids unable to park at the current price. (Since the daily values fluctuate a lot, the simulator shows their moving averages by default.) The user can slow the simulation down to see better the individual behavior, or speed it up to see better the aggregate statistics. 3. Features of the model Even though the structure of the model is very simple, its aggregate behavior is interesting and heavily stochastic. Its basic features are shown in Fig. 2 which was calculated for one particular initialization of the model (random seed 1); each number is an average of 2100 “daily” values (the first 100 “daily” values were rejected). FIG. 2: Model features (a) (b) (c) (d) Fig. 2a shows a typical dependence of the welfare (the total surplus) on the price charged (depicted for the case with ten sick kids). When the price is small and rises, the consumers’ surplus decreases less than the profit rises, and hence the welfare rises. When the price is high, its further rise decreases the welfare and from some level even the profit decreases. Fig. 2b shows how the welfare depends on the price charged for zero, five, ten, and fifteen sick kids. The price maximizing the welfare is denoted with a dot. The welfare maximizing price rises with the number of sick kids, i.e. with the demand for parking. The square denotes the profit-maximizing price, the triangle the price minimizing the number of sick kids unable to park in front of the hospital. Fig. 2c shows how the price maximizing the welfare, maximizing the profit, and minimizing the number of kids unable to park depends on the number of sick kids. All the prices are always positive and are rising in the number of sick kids. Since the owner of the parking lot has some monopoly power, the profit-maximizing price is higher than the welfare-maximizing price; however, it is usually lower than the price minimizing the risk that a sick kid would not be able to park in front of the hospital. Fig. 2d shows how the welfare depends on the number of sick kids and the price charged. In every case, the welfare rises in the number of sick kids, which increases the demand. With the exception of the lowest numbers of the sick kids, the loss of welfare is lower when the owner charges the monopoly price than when the parking is free. 4. Pedagogic use of the simulator Since we use the textbook [4] at Masaryk University, our students know all terms and theories necessary to be able to analyze the results of the simulation. It is sufficient to tell them to watch the aggregate statistics and what cars park in front of the hospital at various prices and ask them the following questions: 1. What price should you charge (a) if you care only about your own profit, (b) about the overall welfare, and (c) about the sick kids’ ability to find parking? 2. The owner of the parking lot has a monopoly power. Does the profit-maximizing price coincide with the welfare maximizing price? If not, what causes a higher inefficiency: the monopoly price or the zero price? 3. Is it optimal to have such a price that each parking lot is occupied at every moment? What is the welfare cost and benefit (if any) of having a lot empty? 4. Why a price increase raises the owner’s profit more than it decreases the consumers’ surplus (i.e. it rises the overall surplus) when the price is low? 5. Is there any way to allocate the scare parking lots efficiently other than charging a price? Is there any such way not involving a “parking police”? 6. How does the optimal price change when you start a new simulation with a lower or higher number of the sick kids? Can the same price be optimal at healthy time and after a disaster? If not, when it should be higher if you care only about (a) the overall efficiency or (b) the sick kids’ ability to park? Conclusion The course opinion polls have shown that our students consider the animated charts, simulations, and other e-learning tools provided them in the past to be highly beneficial. The more complex simulations (such as the one described above) can not only help them to understand difficult topics but also create an exploratory mindset and raise an interest in the economic theory. References: [1] BERGSTROM, T. C. and MILLER, J. H. Experiments with Microeconomic Principles, McGraw-Hill, 2nd ed., 2000, ISBN 0071161724. [2] KRČÁL, O. An agent-based model of price flexing by chain-store retailers. Proceedings of the 30th International Conference Mathematical Methods in Economics 2012. 2012, p. 461–466, ISBN 978-80-7248-779-0. [3] KVASNIČKA, M. Markets, social networks, endogenous preferences, and opinion leaders. Proceedings of the 31st International Conference Mathematical Methods in Economics 2013, 2013, vol. 1, p. 512–517. ISBN 978-80-87035-76-4. [4] MANKIW, N. G., Principles of Economics, Cengage Learning; 6th ed., 2011, ISBN 0538453052. [5] TESFATSION, L., Agent-Based Computational Economics: A Constructive Approach To Economic Theory. Handbook of Computational Economics, vol. 2, North-Holland, 2006, pp. 831–880, ISBN 0-444-51253-5 [6] WILENSKY, U. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL. 1999. Ing. Michal Kvasnička, Ph.D. Masaryk University, Faculty of Economics Lipová 41a 602 00, Brno the Czech Republic