<<

Tipping points in macroeconomic Agent-Based models

Stanislao Gualdi,1 Marco Tarzia,2 Francesco Zamponi,3 and Jean-Philippe Bouchaud4 1 Universit´ePierre et Marie Curie - Paris 6, Laboratoire de Physique Th´eoriquede la Mati`ere Condens´ee, 4, Place Jussieu, Tour 12, 75252 Paris Cedex 05, France and IRAMIS, CEA-Saclay, 91191 Gif sur Yvette Cedex, France ∗ 2 Universit´ePierre et Marie Curie - Paris 6, Laboratoire de Physique Th´eoriquede la Mati`ere Condens´ee, 4, Place Jussieu, Tour 12, 75252 Paris Cedex 05, France 3Laboratoire de Physique Th´eorique, Ecole´ Normale Sup´erieure, UMR 8549 CNRS, 24 Rue Lhomond, 75231 Paris Cedex 05, France 4CFM, 23 rue de l’Universit´e,75007 Paris, France, and Ecole Polytechnique, 91120 Palaiseau, France.

The aim of this work is to explore the possible types of phenomena that simple macroeconomic Agent-Based models (ABM) can reproduce. Our motivation is to understand the large macro- economic fluctuations observed in the “Mark I” ABM devised by D. Delli Gatti and collaborators. Our major finding is the existence of a first order (discontinuous) phase transition between a “good economy” where unemployment is low, and a “bad economy” where unemployment is high. We show that this transition is robust against many modifications of the model, and is induced by an asymmetry between the rate of hiring and the rate of firing of the firms. This asymmetry is induced, in Mark I, by the interest rate. As the interest rate increases, the firms become more and more reluctant to take further loans. The unemployment level remains small until a tipping point beyond which the economy suddenly collapses. If the parameters are such that the system is close to this transition, any small fluctuation is amplified as the system jumps between the two equilibria. We have also explored several natural extensions. One is to allow this hiring/firing propensity to depend on the financial fragility of firms. Quite interestingly, we find that in this case, the above transition survives but becomes second order. We also studied simple wage policies and confidence feedback effects, whereby higher unemployment increases the saving propensity of . We observe several interesting effects, such as the appearance of acute endogenous crises, during which the unemployment rate shoots up before the economy recovers. We end the paper with general comments on the usefulness of ABMs to model macroeconomic phenomena, in particular in view of the time needed to reach a steady state.

It is human nature to think wisely and to act absurdly – Anatole France

I. INTRODUCTION: FROM MICRO-RULES TO MACRO-BEHAVIOUR

Inferring the behaviour of large assemblies from the behaviour of its elementary constituents is arguably one of the most important problems in a host of different disciplines: physics, material sciences, biology, computer sciences, sociology and, of course, and finance. It is also a notoriously hard problem; statistical physics has developed in last 150 years essentially to understand this micro-macro link. Clearly, when interactions are absent or small enough, the system as a whole merely reflects the properties of individual entities. This is the canvas of traditional macro- economic approaches. Economic agents are assumed to be identical, non-interacting, rational agents, an idealization known as the “” (RA). In this framework, micro and macro trivially coincide. However, we know (in particular from physics) that discreteness, heterogeneities and/or interactions can lead to totally unexpected phenomena. Think for example of super-conductivity or super-fluidity: before their experimental discovery, it was simply beyond human imagination that individual electrons or atoms could “conspire” to create a collective state that can flow without friction. Micro and macro behaviour not only do not coincide in general, but genuinely surprising behaviour can emerge through aggregation. From the point of view of economic theory, this is interesting, because financial and economic history is strewn with bubbles, crashes, crises and upheavals of all sorts. These are very hard to fathom within a Representative Agent framework [1], within which crises would require large aggregate shocks, when in fact small local shocks can trigger large systemic effects when heterogeneities, interactions and network effects are taken into account [2, 3]. The need to include these effects has spurred a large activity in “Agent-Based models”

∗Electronic address: [email protected] 2

(ABMs) [4–6]. These models need numerical simulations, but are extremely versatile because any possible behavioural rules, interactions, heterogeneities can be taken into account. In fact, these models are so versatile that they suffer from the “wilderness of high dimensional spaces” (paraphrasing Sims [7]). The number of parameters and explicit or implicit choices of behavioural rules is so large (∼ 10 or more, even in the simplest models, see below) that the results of the model may appear unreliable and arbitrary, and the calibration of the parameters is an hopeless (or highly unstable) task. Mainstream RA models, on the other hand, are simple enough to lead to closed form analytical results, with simple narratives and well trodden calibration avenues. In spite of their unrealistic character, these traditional models are still favoured by most economists, both in academia and in institutional and professional circles. ABMs are seen at best as a promising research direction and at worst as an unwarranted “black box” (see [8] for an enlightening discussion on the debate between traditional DSGE models and ABMs, and [9, 10] for further insights). At this stage, it seems to us that some clarifications are indeed needed, concerning both the objectives and method- ology of Agent-Based models. ABMs do indeed suffer from the wilderness of high dimensional spaces, and some guidance is necessary to put these models on a firm footing. In this respect, statistical physics offers a key concept: the phase diagram in parameter space [11]. A classic example, shown in Fig. 1, is the phase diagram of usual substances as a function of two parameters, here temperature and pressure. The generic picture is that the number of distinct phases is usually small (e.g. three in the example of Fig. 1: solid, liquid, gas). Well within each phase, the properties are qualitatively similar and small changes of parameters have a small effect. Macroscopic (aggregate) properties do not fluctuate any more for very large systems and are robust against changes of microscopic details. This is the “nice” scenario, where the dynamics of the system can be described in terms of a small number of macroscopic (aggregate) variables, with some “effective” parameters that encode the microscopic details. Other scenarios are of course possible; for example, if one sits close to the boundary between two phases, fluctuations can remain large even for large systems and small changes of parameters can radically change the macroscopic behaviour of the system. There may be mechanisms naturally driving the system close to criticality (like in Self Organized Criticality [12]), or, alternatively, situations in which whole phases are critical, like for “spin-glasses” [13]. In any case, the very first step in exploring the properties of an Agent-Based model should be, we believe, to identify the different possible phases in parameter space and the location of the phase boundaries. In order to do this, numerical simulations turn out to be very helpful [14, 15]: aggregate behaviour usually quickly sets in, even for small sizes. Some parameters usually turn out to be crucial, while others are found to play little role. This is useful to establish a qualitative phenomenology of the model – what kind of behaviour can the model reproduce, which basic mechanisms are important, which effects are potentially missing. This first, qualitative step allows one to unveil the “skeleton” of the ABM. Simplified models that retain most of the phenomenology can then be constructed and perhaps solved analytically, enhancing the understanding of the important mechanisms, and providing some narrative to make sense of the observed effects. In our opinion, calibration of an ABM using real data can only start to make sense after this initial qualitative investigation is in full command – which is in itself not trivial when the number of parameters is large. The phase diagram of the model allows one to restrict the region of parameters that lead to “reasonable” outcomes (see for example the discussion in [16, 17]). The aim of this paper is to put these ideas into practice in the context of a well-studied macroeconomic Agent-Based model (called “Mark I” below), devised by Delli Gatti and collaborators [18, 19]. This model is at the core of the European project “CRISIS”, which justifies our attempt to shed some theoretical light on this framework.1 In the first part of the paper, we briefly recall the main ingredients of the model and show that as one increases the baseline interest rate, there is a phase transition between a “good” state of the economy, where unemployment is low and a “bad” state of the economy where production and demand collapse. In the second part of the paper, we propose a highly simplified version of Mark I that aims at capturing the main drivers of this phase transition. We show that the most important parameter is the asymmetry between the firms’ propensity to hire (when business is good) or to fire (when business is bad). In Mark I, this asymmetry is induced by the reaction of firms to the level of interest rates, but other plausible mechanisms would lead to the same effect. The simplest version of the model is amenable to an analytic treatment and exhibits a “tipping point” (i.e. a discontinuous transition) between high employment and high unemployment. Enriching the model by, e.g. endowing firms with a strategy that depends on their financial wealth, leads to a modified picture, where the level of unemployment is now continuous, and where low frequency fluctuations of the employment rate/production appear due to the proximity of a second order transition. Finally, we allow wages to adapt (whereas they are kept fixed in Mark I) and include confidence effects, that reduce the spending propensity when unemployment increases. The model reveals an extremely rich phenomenology, with endogenous crises, which we briefly document. Open questions and future directions, in particular concerning macroeconomic

1 see www.crisis-economics.eu 3

FIG. 1: A typical “phase diagram”, here the solid-liquid-gas phases in the temperature-pressure plane. Far from phase transitions, within a given phase, the behaviour of the system is qualitatively similar for all values of the parameters. Close to phase boundaries, on the other hand, small changes of parameters can lead to dramatic macroscopic changes. models in general, are discussed in our final section. The source codes for the models discussed in this paper are available on the website of the CRISIS project1.

II. A PHASE TRANSITION IN “MARK I”

A. Description of the model in a nutshell

The Mark I family of agent-based models was proposed by Delli Gatti and collaborators as a family of simple stylized macroeconomic models [18, 19]; it is the cornerstone of the more comprehensive Agent-Based model currently put together by the members of the CRISIS project. Note that several other macroeconomic Agent-Based models have been put forth in the recent years, see [20–25]. Mark I is interesting in part because large fluctuations in unemployment and output seem to persist in the stationary state (a feature in fact shared by many ABMs cited above). The Mark I economy [18] is made up of a set of firms, households, firms owners and a bank. Firms produce a certain quantity of a single (and not storable) good, proportional to the number of their employees at a time-dependent and firm-dependent price. When the cash owned by a firm is not enough to pay wages, it asks banks for a loan. The bank provides loans to the firms at an interest rate that depends on the financial fragility of the firm. Households provide workforce in exchange of a salary and want to spend a fixed fraction of their savings. The owners of the firms do not work but receive dividends if the firms make profits. Firms are adaptive, in the sense that they continuously update their production (i.e. they hire/fire workers) and their prices, in an attempt to match their production with the demand of goods issued by the households. They also choose how much extra loan they want to take on, as a function of the offered interest rate. This last feature, combined with the price and production update rules, will turn out to be crucial in the dynamics of the model. The above description defines the basic structure of the Mark I family, but it is of course totally insufficient to code the model, since many additional choices have to be made, leading to several different possible implementations of the model. Here we will use as a baseline model one of the simplest implementation of Mark I, whose description can be found in [26]; the total number of parameters in this version is 10 (but some parameters are actually implicitly fixed from the beginning). We have recoded this basic version and also a slightly different version that we call “Mark I+”, which differs on minor details (some that we will specify below) but also on one major aspect: our version of the model strictly conserves the amount of money in circulation, i.e. the money in the bank + total firm assets + total households savings, in order to avoid at this stage any effect due to (uncontrolled) money creation. A detailed pseudo-code of Mark I+ is provided in Appendix A. 4

B. State variables

In short (see Appendix A for a complete description), the dynamic evolution of the model is defined by the following state variables. The state of each firm i = 1 ··· NF is specified by its price pi(t), the salary it offers Wi(t), its production T T Yi(t), its target production Yi (t), its demand Di(t), its liquidity Li(t), its total debt Di (t). Moreover, each firm is owned by a and has a list of employees that is dynamically updated. The state of each household a = 1 ··· NH is specified by its savings Sa(t) and by the firm for which it works (if any).

C. Update rules for prices and production

Among all the micro-rules that any Agent-Based model has to postulate, some seem to be more crucial than others. An important item in Mark I is the behavioural rule for firms adaptation to their economic environment. Instead of the standard, infinite horizon, utility optimizing firm framework (that is both unrealistic and intractable), Mark I postulates a heuristic rule for production Yi(t) and price pi(t) update, which reads as follows:

T Yi(t) = Di(t)& pi(t) > p¯(t) ⇒ Yi (t + 1) = Yi(t)[1 + γyRi(t)] Yi(t) = Di(t)& pi(t) < p¯(t) ⇒ pi(t + 1) = pi(t)[1 + γpRi(t)] (1) T Yi(t) > Di(t)& pi(t) < p¯(t) ⇒ Yi (t + 1) = Yi(t)[1 − γyRi(t)] Yi(t) > Di(t)& pi(t) > p¯(t) ⇒ pi(t + 1) = pi(t)[1 − γpRi(t)], where Di(t) is the total demand for the goods produced by firm i at time t, and P i pi(t)Di(t) p¯(t) = P (2) i Di(t) is the average price of sold goods at time t, Ri(t) a U[0, 1] random variable, independent across firms and across T times, and γy, γp two parameters in [0, 1]. The quantity Yi (t) is the target production at time t, not necessarily the realized one, as described below. These heuristic rules can be interpreted as a plausible tˆatonnement process of the firms, that attempt to guess their correct production level and price based on the information on the last time step. In spirit, each unit time step might correspond to a quarter, so the order of magnitude of the γ parameters should be a few percent. Note that in the version of Mark I that we consider, wages are fixed to a constant Wi(t) ≡ 1, for all times and all firms.

D. Debt and loans

The model further assumes linear productivity, hence the target production corresponds to a target workforce T Yi (t)/α, where α is a constant coefficient that can always be set to unity (gains in productivity are not considered at T this stage). The financial need of the firm is max [0,Yi (t)Wi(t) − Li(t)], where Li(t) is the cash available. The total T current debt of the firm is Di (t). The financial fragility of the firm `i(t) is defined in Mark I as the ratio of debt over cash. The offered rate by the banks for the loan is given by:

ρi(t) = ρ0G(`i(t))(1 + ξi(t)), (3) where ρ0 is the baseline () interest rate, G is an increasing function (taken to be G(`) = 1 + tanh(`) in the reference Mark I and G(`) = 1 + ln(1 + `) in Mark I+), and ξ a noise term. Depending on the rate offered, firms decide to take the full loan they need or only a fraction F (ρ) of it, where F ≤ 1 is a decreasing function of ρ, called “credit contraction”. For example, in the reference Mark I, F (ρ ≤ 5%) = 1 and F (ρ > 5%) = 0.8. We have played with the choice of the two functions F,G and the phase transition reported below is in fact robust whenever these functions are reasonable. In Mark I+, we chose a continuous function, such as to avoid built in discontinuities:  1 if x < 5%  x−5% F (x) = 1 − 5% if 5% < x < 10% (4) 0 if x > 10%.

The important feature here is that when F < 1, the firm does not have enough money to hire the target workforce T Yi (t) and is therefore obliged to hire less, or even to start firing in order to match its financial constraints. Note 5 that financial constraints induce an asymmetry in the hiring/firing process: when firms are indebted, hiring will be slowed down by the cost of further loans. As we will see later, this asymmetry is responsible for an abrupt change in the steady state of the economy.

E. Spending budget and bankruptcy

Firms pay salaries to workers and households determine their budget as a fraction c (constant in time and across households) of their total savings (including the latest salary). Each household then selects M firms at random and sorts them according to the price; it then buys all it can buy from each firm sequentially, from the lower price to 2 the highest price . The budget left-over is added to the savings. Each firm sells a quantity Di(t) ≤ Yi(t), compute its profits (that includes interests paid on debt), and updates its cash and debt accordingly. Moreover, each firm T pays back to the bank a fraction τ of its total debt Di (t). It also pays dividends to the firm owners if profits are positive. Firms with negative liquidity Li(t) < 0 go bankrupt. In Mark I+, the cost of the bankruptcy (i.e. −Li(t)) is spread over healthy firms and on households. Once a firm is bankrupt it is re-initialized in the next time step with the owner’s money, to a firm with a price and production equal to their corresponding average values at that moment in time, and zero debt (see Appendix A for more precise statements).

F. Numerical results: a phase transition

When exploring the phase space of Mark I, it soon becomes clear that the baseline interest rate ρ0 plays a major role. In order not to mix different effects, we remove altogether the noise term ξ that affects the actual rate offered to the firms. We find that as long as ρ0 is smaller than a certain threshold ρc, firms are on average below the credit contraction threshold and always manage to have enough loans to pay wages. In this case the economy is stable and after few (∼ 100) time steps reaches a stationary state where the unemployment rate is low. If on the other hand the baseline interest rate ρ0 exceeds a critical value ρc, firms cannot afford to take as much loans as they would need to hire (or keep) the desired amount of workers. Surprisingly, this induces a sudden, catastrophic breakdown of the economy. Production collapses to very small values and unemployment sky-rockets. This transition between two states of the economy takes place in both the reference Mark I and in the modified Mark I+; as we shall show in the next section, this transition is actually generic and occurs in simplified models as well. Note that ρc is different from the value at which F (x) starts decreasing. The data we show in Fig. 2 corresponds to Mark I+ with parameters γp = γy = 0.1 and M = 3 (see Appendix A for the general parameter setting of the model). While the qualitative behaviour of the model is robust, the details of the transition may change with other parameter settings. For example, smaller values of γp, γy lead to lower critical thresholds ρc (as well as smaller values of M) and to longer equilibration times (Teq scales approximately as 1/γy,p for ρ0 < ρc). Increasing the size of the economy only affects the magnitude of the fluctuations within one phase leaving the essential features of the transition unchanged. Interestingly, although it is not clear from Fig. 2, the model exhibits oscillatory patterns of the employment rate. The presence of these oscillations can be seen in the frequency domain of the employment rate time series (not shown here), which is essentially characterized by a white noise power spectrum with a well defined peak at intermediate frequencies. All these effects will become clearer within the reduced model described in the next section. To sum up, our most salient finding is that Mark I (or Mark I+) has essentially two stationary states, with a first order (discontinuous) transition line separating the two. If the parameters are such that the system lies close to this critical line, then it is plausible that any small modulation of these parameters – such as the noise term that appears in Eq. (3) – will be amplified by the proximity of the transition, and lead to interesting boom/bust oscillations, of the kind originally observed in Mark I [26], and perhaps of economic relevance. The question, of course, is how generic this scenario is. We will now show, by studying much simplified versions of Mark I, that this transition is indeed generic, and is induced by any asymmetry between hiring and firing. We will then progressively enrich our watered-down model (call “Mark 0” below) and see how the qualitative picture that we propose is affected by additional features.

2 In this sense, the good is not efficient since the household demand is not necessarily satisfied when M is small. The job market, instead, is efficient because all the workers can contact all the firms until all the open positions are filled. 6

8 10 1 NF = 100 N = 1000 6 F 10 0.8 0.89 Teq 4 10 0.88

2 0.6 0.87 5000 5250 5500 101 u 0.01 0.8 0.4 0.6 u 0.4 0.2 0 5000 5250 5500 0.2 0 0 1 1.5 2.0 2.5 3.0 3.5 4.0 0 2000 4000 6000 8000 10000 ρ0 (%) t

FIG. 2: Left: Average unemployment rate u as a function of the interest rate ρ0 for two system sizes (with NH = 10NF in both cases). The average is over 100 000 time steps discarding the first 50 000 time steps. The phase transition at ρc = 2.1% is of first order with u jumping discontinuously from small values to 1 (intermediate values obtained for ρ0 ∈ [2.1%, 3.1%] are only due to a much longer equilibration time near the critical point). Note that in the bottom graph we show averages for Teq = 50 000 regardless of ρ0 while an estimate of the time needed to reach the steady state as a function of ρ0 is plotted in logarithmic scale in the top graph. Right: Two trajectories of the unemployment rate with NF = 1000 at ρ0 = 1.9% and ρ0 = 2.5%.

III. HYBRID ABMS: THE MINIMAL “MARK 0” MODEL

Moving away from the RA framework, Agent-Based Modeling bites the bullet and attempts to represent in details all the individual components of the economy (as, for example, in [20, 21]). This might however be counter-productive, at least in the research stage we are still in: keeping too many details is not only computer-time consuming, it may also hobble the understanding of the effects that ABMs attempt to capture. It may well be that some sectors of the economy can be adequately represented in terms of aggregate variables, while discreteness, heterogeneities and interactions are crucial in other sectors. In our attempt to simplify Mark I, we posit that the whole household sector can be represented by aggregate variables: total savings S(t), total income W (t) and total consumption budget B(t). We also remove the banking sector and treat the loans in the simplest possible way – see below. While the interest rate is zero in the simplest version, the incentive to hire/fire provided by the interest rate, that was at play in Mark I, will be encoded in a phenomenological way in the update rule for production. The firms, on the other hand, are kept as individual entities (but the above simplifications will allow us to simulate very large economies, with NF = 100 000 firms or more).

A. Set-up of the model

The minimal version of the Mark 0 model is defined as follows. The salient features are:

3 • There are NF firms in total and µNF agents, µ > 1. Each firm i = 1 ··· NF pays a salary Wi(t) and has a production Yi(t). Productivity is fixed to α = 1, therefore Yi(t) is also equal to the number of employees of firm i. Therefore the employment ζ(t) and unemployment u(t) are

1 X ε(t) = Y (t) , µN i F i (5) u(t) = 1 − ε(t) .

P • Agents are described by their total savings S(t) and by their total income i Wi(t)Yi(t). At each time step,

3 Actually, agents are treated as a unique aggregate variable, therefore µ is not a relevant parameter: one can see that its value is irrelevant and one can always set µ = 1 for simplicity. Yet it is useful to think that the aggregate variables represents in an effective way a certain number of individual households, hence we keep the parameter µ explicit in the following. 7

they set a total consumption budget (note that savings might be negative if households are indebted)4 X B(t) = c [max{S(t), 0} + Wi(t)Yi(t)] (6) i

which is distributed among firms using an intensity of choice model [27]. The demand of goods for firm i is therefore:

B(t) e−βpi(t) Di(t) = , (7) P −βpi(t) pi(t) i e where β is the price sensitivity parameter (β = 0 corresponds to complete price insensitivity and β → ∞ means P that households select only the firm with the lowest price). The normalization is such that B(t) = i pi(t)Di(t), as it should be.

• Firms are described by their price pi(t), their salary Wi(t), and their production Yi(t).

– For simplicity, we fix the salary Wi(t) ≡ 1 – an extension that includes wage dynamics is discussed below. – For the price, we keep the Mark I price update rule (1), with the average production-weighted price: P i pi(t)Yi(t) p(t) = P . (8) i Yi(t)

– For production, we assume that firms are more careful with the way they deal with their workforce than posited in Mark I. Independently of their price level, firms try to adjust their production to the observed demand. When firms want to hire, they open positions on the job market; we assume that the total number of unemployed workers, which is µNFu(t), is distributed equally among firms; therefore the maximum number of available workers to each firm is µu(t). In summary, we have ( Yi(t + 1) = Yi(t) + min{η+(Di(t) − Yi(t)), µu(t)} If Yi(t) < Di(t) ⇒ If pi(t) < p(t) ⇒ pi(t + 1) = pi(t)(1 + γpRi(t)) ( (9) Yi(t + 1) = max{Yi(t) − η−[Yi(t) − Di(t)], 0} If Yi(t) > Di(t) ⇒ If pi(t) > p(t) ⇒ pi(t + 1) = pi(t)(1 − γpRi(t))

where η± ∈ [0, 1] are the hiring/firing propensity of the firms: for example say η− = 0.5 means that half of the excess production force of a given firm is fired at each time step. Note that this rule ensures that there is no overshoot in production; furthermore the max in the second rule is not necessary mathematically when η− ≤ 1, but we kept it for clarity.

• Accounting is done as follows. Each firm i = 1 ··· NF pays a total wage bill Wi(t)Yi(t) and receives an amount pi(t) min{Yi(t),Di(t)} from the goods sold. Moreover, if the total profit Pi(t) = pi(t) min{Yi(t),Di(t)} − Wi(t)Yi(t) is positive, the firm pays a dividend δ × Pi(t) to the households. In summary, the accounting equations for total savings S(t) and firms’ liquidities Li(t) are the following (here θ(x) is the Heaviside step function):

Pi(t) = pi(t) min{Yi(t),Di(t)} − Wi(t)Yi(t) , L (t + 1) = L (t) + P (t) − δP (t)θ(P (t)) , i i i i i (10) X X S(t + 1) = S(t) − Pi(t) + δ Pi(t)θ(Pi(t)) , i i P and total money S(t) + i Li(t) is clearly conserved.

4 Of course, one could choose different c’s for the fraction of savings and the fraction of wages devoted to spending. 8

• Note that we allow for negative firms’ liquidities, which we interpret as the firm being indebted. If a firm’s liquid- ity becomes too negative, however, the firm will go bankrupt. This is done as follows. If Li(t) ≥ −ΘYi(t)Wi(t), i.e. when the level of debt is not too high compared to the size of the company (measured as the total payroll), the firm is allowed to continue its activity. If on the other hand Li(t) < −ΘYi(t)Wi(t), the firm defaults. When a firm defaults, its debt Li(t) < 0 is added to the households’ savings, S(t) → S(t) + Li(t) in order to keep total money fixed. A defaulted firm has a finite probability ϕ per unit time to get revived; when it does so its price is fixed to pi(t) = p(t), its workforce is the available workforce, Yi(t) = µu(t), and its liquidity is the amount needed to pay the wage bill, Li(t) = Wi(t)Yi(t). The liquidity is provided by the households, therefore S(t) → S(t) − Wi(t)Yi(t) when the firm is revived, again to ensure total money conservation.

• Note that because of the min{Di(t)−Yi(t), µu(t)} term in Eq. (9), the total production of the model is bounded P by Yi(t) = µNFε(t) ≤ µNF, as it should be because ε(t) = 1 corresponds to full employment and in that Pi case i Yi(t) = µNF. However, in the following we will sometimes (when stated) remove this bound for a better mathematical tractability. This amounts to replace min{Di(t) − Yi(t), µu(t)} → Di(t) − Yi(t) in Eq. (9) (it corresponds to choosing µ = ∞). When the bound is removed the high employment phase translates into an exponential explosion of the employment rate which is of course unrealistic. The above description contains all the details of the definition of the model, however for further clarification a pseudo- code of this minimal Mark 0 model is provided in Appendix B. The total number of relevant parameter of Mark 0 is 8: c, β, γp, η±, δ, Θ, ϕ plus the number of firms NF. However, most of these parameters play very little role in determining the long-time aggregate qualitative behaviour of the model. The most important quantity in this respect turns out to be the difference between η+ and η−, which is meant to capture any asymmetry in the hiring/firing process. As noted above, a rising interest rate leads to such an asymmetry in Mark I and Mark I+; but other sources of asymmetry can be envisaged: for example, overreaction of the firms to bad news and under-reaction to good news, leading to an over-prudent hiring schedule. Capital inertia can also cause a delay in hiring, whereas firing can be immediate.

B. Numerical results

When running numerical simulations of Mark 0, we find the same qualitative phase diagram in the plane (η+, η−) for all parameters β, γp, Θ, ϕ, δ. For a given set of parameters, there is a critical line η+ ≈ Rcη− separating a low unemployment phase below the line from a high employment phase above the line (see Fig. 3), where Rc ≤ 1 is a constant that depends on all other parameters, that we compute analytically in the next section. The transition is strictly discontinuous in the limit Θ → ∞ while for finite values of Θ (e.g. Θ = 5) intermediate values of the 5 unemployment are stabilized in a narrow region around η+ ≈ Rcη−. The width of this intermediate region vanishes as Θ increases. Two typical trajectories, one in each phase, are shown in Fig. 4, for a set of parameters specified in the caption. After a transient that can be surprisingly long6, the unemployment rate settles around a well defined average value, with some fluctuations. These fluctuations reveal a clear periodic pattern in the low unemployment phase; recall that these oscillations were already observed within Mark I+. Oscillating behaviour (perhaps representing the business cycles) often appears in simplified first order differential models of the macro-economy; one of the best known examples is provided by the Goodwin model [28, 29], which is akin to a predator-prey model where these oscillations are well known. But these oscillations also appear in other ABMs, see [23, 25]. Note that these fluctuations/oscillations around the equilibrium do not regress when the number of firms get larger. We have simulated the model with NF = 10 000 firms and NF = 100 000 firms with nearly identical amplitude and frequencies for these fluctuations. We will offer some insight on the origin of these oscillations in the next section. The dependence of the constant Rc on the different parameters is in general quite intuitive. The dependence of Rc on β, for example, is interesting: everything else being kept equal, we find that increasing β (i.e. increasing the selectivity of buyers) makes the economy more unstable: it increases the level of unemployment, and the amplitude

5 The main driver if this effect is the reinitialization of bankrupted firms which manage to stabilize the high employment phase for η+ ≈ Rcη−. This mechanism is qualitatively similar to the stabilizing effect of the parameter Γ which will be discussed in Sec. V A. 6 Think of one time step as a quarter, the equilibration time is 20 years or so, or even much longer as for the convergence to the ‘bad’ state in Mark I, see Fig. 2. Albeit studying a very different ABM, similarly long time scales can be observed in the plots shown in [25]. See also the discussion in the conclusion on this point 9

0.5 4 NF = 10 , γp = 0.01 3 NF = 10 , γp = 0.01 high employment 0 0.4 NF = 10 , γp = 0.01 4 NF = 10 , γp = 0.1 3 0.3 NF = 10 , γp = 0.1 0 η+ NF = 10 , γp = 0.1 0.2 low employment 0.1

0 0 0.1 0.2 0.3 0.4 0.5 η−

FIG. 3: Phase diagram of the basic Mark 0 model with β = 0 and Θ = ∞. There are two distinct phases separated by a critical line which depends mostly on the parameter γp and is less and less sensitive to the system size as long as γp → 0. The dashed lines correspond to the analytical result in Eq. (20) which agrees well with numerical simulations for small values of η+, η− where the perturbative method of Section III-C and Appendix C is justified. 1

1 0.8 0.995 0.6 u 2000 2100 2200 2300 0.4 0.04 0.03 0.2 0.02 2000 2100 2200 2300 0 0 1000 2000 3000 4000 t

FIG. 4: Two typical time evolutions of the unemployment u, starting from an initial condition u ∼ 0.5, for the basic Mark 0 model. The trajectory leading to a “good” state of the economy is obtained for η+ = 0.5 and η− = 0.3. Note the clear endogenous “business cycles” that appear in that case. The trajectory leading to a “bad” state of the economy corresponds to η+ = 0.3 and η− = 0.5. These runs are performed with NF = 10 000 firms, c = 0.5, β = 2, γp = 0.1, ϕ = 0.1, Θ = 5, δ = 0.02.

7 of the fluctuations around the average value. Similarly, increasing γp increases the dispersion of prices around the average value and is thus similar to decreasing β. In any case, the main message of the present section is that in spite of many simplifications, and across a broad range of parameters, the phase transition observed in Mark I as a function of the baseline interest rate is present here. We find that these macroeconomic ABMs display quite generically two very different phases – high demand/low unemployment vs. low demand/high unemployment, with a boundary between the two that is essentially controlled

7 A similar effect was noted in [21]. 10 by the asymmetry between the hiring and firing propensity of the firms. We now explain how this result can be understood, in a still simplified setting, using analytical calculations. We then turn to several interesting extensions of Mark 0.

IV. ANALYTICAL DESCRIPTION

We attempt here to describe analytically some aspects of the dynamics of Mark 0 in its simplest version, namely without bankruptcies (Θ = ∞ for which ϕ becomes irrelevant), with β = 0, fixed wages W = 1, and no dividends (δ = 0). For simplicity, we also fix µ = 1 and c = 1/2. The only relevant parameters are therefore γp and η±. The equations of motion of this very minimal model are: ( Yi(t + 1) = Yi(t) + min{η+[Di(t) − Yi(t)], 1 − Y (t)} If Yi(t) < Di(t) ⇒ If pi(t) < p(t) ⇒ pi(t + 1) = pi(t)(1 + γpRi(t)) ( Y (t + 1) = max{Y (t) − η [Y (t) − D (t)], 0} If Y (t) > D (t) ⇒ i i − i i i i If p (t) > p(t) ⇒ p (t + 1) = p (t)(1 − γ R (t)) i i i p i (11) 1 Di(t) = [max{s(t), 0} + Y (t)] 2pi(t)

Li(t + 1) = Li(t) − Yi(t) + pi(t) min{Yi(t),Di(t)}

s(t) = M0 − L(t) .

Here M0 is the total money in circulation, whose precise value is irrelevant, and s = S/NF are the savings per agent. −1 P −1 P Overlines denote an average over firms, which is flat for Y = NF i Yi(t) and L = NF i Li(t) while it is weighted by production for p, see Eq. (8). Note that the basic variables here are {pi,Yi, Li}, all the other quantities are deduced from these ones. In the high employment phase, the model should admit a stationary state with Y st ∼ 1. In particular, for γp → 0 there are no fluctuations and Yi = Di = pi = 1, while Li = M0 − 1 in such a way that sst = 1. In order to obtain analytical results, in this section we consider the limit in which γp → 0, and we expand around the high employment stationary state. Numerically, the fact that γp is small does not change the qualitative behavior of the model. In order to consider small fluctuations around the high employment stationary state, we define

Yi(t) = 1 − γpζi(t) ,

pi(t) = 1 + γpλi(t) , (12)

Li(t) = M0 − 1 − γpαi(t) . In terms of these basic variables, the other variables are easily written as follows:

Y (t) = 1 − γpζ(t) ,

s(t) = 1 + γpα(t) , (13)

p(t) = 1 + γpλ(t) , where overlines denote flat averages over firms, and 1 1  D (t) = 1 + γ α(t) − ζ(t) − λ (t) . (14) i p 2 2 i Using this, we arrive to the following linearized equations:

 1 1  ζi(t + 1) = ζi(t) − min{η+[ 2 α(t) − 2 ζ(t) − λi(t) + ζi(t)], ζ(t)} 1 1  1 2 If − ζi(t) < α(t) − ζ(t) − λi(t) ⇒ If λi(t) < λ(t) ⇒ λi(t + 1) = λi(t) + Ri(t) − 2 γpRi(t) 2 2   αi(t + 1) = αi(t) − λi(t) (15)  1 1  ζi(t + 1) = ζi(t) − η−[ 2 α(t) − 2 ζ(t) − λi(t) + ζi(t)] 1 1  1 2 If − ζi(t) > α(t) − ζ(t) − λi(t) ⇒ If λi(t) > λ(t) ⇒ λi(t + 1) = λi(t) − Ri(t) − 2 γpRi(t) 2 2  1 1  αi(t + 1) = αi(t) − ζi(t) − 2 α(t) + 2 ζ(t) which can be used as a starting point to study several aspects of the phenomenology of the model. Note that we kept 1 2 the second order term 2 γpRi(t) in the evolution of λi, because as we will show below, this term is important for the stability of the high employment phase. 11

A. Stability of the high employment phase

To study the stability of the high employment phase, we make two further simplifications. First, we neglect the fluctuations of the savings and fix αi ≡ 0. This is justified if the employment rate varies slowly over the time scale τc = −1/ ln(1 − c) that characterizes the dynamics of the savings. But since, as we shall show below, the dynamics of employment becomes very slow in the vicinity of the phase transition. Second, we consider that both η are small. √ ± Then, it is not difficult to see that ζi is a random variable of order η and is therefore also very small. We believe that these approximations should be quite accurate, as is confirmed by the comparison of the theoretical transition line with numerical data. For an arbitrary choice of parameters η±, the time evolution of Y (t) is either exponentially growing with time, or exponentially decaying with time, with rate r. The transition will be set by the condition that this growth rate is zero. With these simplifications (i.e. setting αi = 0 and assuming that η± and ζi are small), Eq. (15) become ( ζi(t + 1) = ζi(t) − min{−η+λi(t), ζ(t)} If λi(t) < 0 ⇒ 1 2 λi(t + 1) = λi(t) + Ri(t) − 2 γpRi(t) ( (16) ζi(t + 1) = ζi(t) + η−λi(t) If λi(t) > 0 ⇒ 1 2 λi(t + 1) = λi(t) − Ri(t) − 2 γpRi(t) Therefore, in this limit, the evolution of λ decouples from that of ζ. So now the problem is to determine the stationary distribution for λ, which satisfies:

Z 1 Z ∞  γ  Z 1 Z 0  γ  P (λ) = dR dλ0P (λ0)δ λ − λ0 + R + R2 + dR dλ0P (λ0)δ λ − λ0 − R + R2 . (17) 0 0 2 0 −∞ 2

The evolution equation for ζ(t) is easily derived if the distribution of prices is stationary and reads

Z ∞ Z 0 ζ(t + 1) = ζ(t) + η− dλ P (λ) λ − dλ P (λ) min{−η+λ, ζ(t)} . (18) 0 −∞ √ Since λ ∼ 1 and ζ ∼ η, then η|λ|  ζ for small η, and we have:

Z ∞ Z 0 ζ(t + 1) = ζ(t) + η− dλ P (λ) λ + η+ dλ P (λ) λ . (19) 0 −∞

In other words, the ζi perform a biased random walk, in presence of a noise whose average is r = η−hλi+ + η+hλi−, R ∞ where hλi+ = 0 dλP (λ)λ and similarly for hλi− (of course, when ζ is too small the minimum will be important, because it is there to prevent ζ from becoming negative). The system will evolve towards full employment (ζ = 0) whenever r < 0, and to full collapse (ζ → ∞) otherwise. The critical line is given by the equality condition, such that r = 0. An approximate solution of the above equation Eq. (17) for the stationary distribution can be computed 8 using the method given in Appendix C, in the limit η  γp  1. The critical boundary line finally reads:

η+ ≈ 1 − 2γp + ... (20) η− in good agreement with the the numerical result, see Fig. 3. Note that right at the critical point, the unemployment rate makes an unbiased random walk in time, meaning that its temporal fluctuations are large and slow. This justifies the adiabatic approximation made above, that lead us to neglect the dynamics of the savings.

B. Oscillations in the high employment phase

Numerical simulations of Mark 0 show that the oscillations in the high employment phase, displayed in Fig. 4, in fact persist for η± → 0. Hence to describe these oscillations we can simplify the model by setting η± = 0 and therefore

8 It would be interesting to compute the first corrections in η. We leave this for a later study. 12

ζi = 0. We get ( 1 If λi(t) < λ(t) ⇒ λi(t + 1) = λi(t) + Ri(t) If λi(t) < α(t) ⇒ 2 αi(t + 1) = αi(t) − λi(t) ( (21) 1 If λi(t) > λ(t) ⇒ λi(t + 1) = λi(t) − Ri(t) If λi(t) > α(t) ⇒ 1 2 αi(t + 1) = αi(t) − 2 α(t)

This very minimal model captures well the oscillations, as we checked numerically (see the inset of Fig. 5). We 1 1 introduce Λ(t) = min{λ(t), 2 α(t)} and Ω(t) = max{λ(t), 2 α(t)}, and we write Eq. (21) equivalently as

αi(t + 1) = αi(t) − min{λi(t), α(t)/2}  If λ (t) < Λ(t) ⇒ λ (t + 1) = λ (t) + R (t)  i i i i (22) If Ω(t) < λi(t) < Λ(t) ⇒ λi(t + 1) = λi(t)   If λi(t) > Ω(t) ⇒ λi(t + 1) = λi(t) − Ri(t)

From Eq. (22) we obtain a closed equation forα ¯ and Pt[λ]: Z ∞ α¯(t + 1) =α ¯(t) − dλ min{λ, α¯(t)/2}Pt[λ] , −∞ Z Λ(t) Z 1 Z ∞ Z 1 0 0 0 0 0 Pt+1[λ ] = dλ dR Pt[λ] δ(λ − λ − R) + θ(Λ(t) ≤ λ ≤ Ω(t))Pt[λ ] + dλ dR Pt[λ] δ(λ − λ + R) . −∞ 0 Ω(t) 0 (23)

It is easy to check that these equations admit a stationary solution where P [λ] = 1 − |λ − 1/6| for |λ − 1/6| ≤ 1 and zero otherwise, and λ = α/2 = 1/6. We observe numerically that, for a generic initial condition, Pt[λ] is indeed very close to the stationary P [λ], but at the same time λ(t) and α(t) oscillate with very small amplitude ≈ 0.01 around their stationary values. An analytical description of this phenomenon should be possible by perturbing around the stationary state, but unfortunately we have not been able yet to fully understand the presence of sustained oscillations. Still, the above analysis elucidates the mechanism behind these oscillations. When prices are low, demand is higher than production and firms increase the prices. But at the same time, households cannot consume what they demand, so they involuntarily save: savings increase when prices are low. These savings keep the demand high for a few rounds even while prices are increasing, therefore prices keep increasing above their equilibrium value. When prices are too high, households need to use their savings to consume, and therefore savings start to fall. Increase of prices and decrease of savings determine a contraction of the demand. At some point demand falls below production and prices start to decrease again, with savings decreasing at the same time. When prices are low enough, demand becomes again higher then production and the cycle is restarted. An example is shown in Fig. 5.

C. The representative firm approximation

Note that we can in fact simplify the model further while still retaining most of the phenomenology of Mark 0. Suppose that one describes the firm sector by a unique “representative firm”, NF = 1, with production Y (t), price p(t) and demand Y (t)/p(t). The dynamics of the production and price are given by the same rule as above, but now the dynamics of the price completely decouples: ( Y (t + 1) = Y (t)(1 + η ( 1 − 1) p(t) < 1 ⇒ + p(t) p(t + 1) = p(t)(1 + γR(t)) ( Y (t + 1) = Y (t)(1 + η ( 1 − 1) p(t) > 1 ⇒ − p(t) (24) p(t + 1) = p(t)(1 − γR(t)).

This model leads to the same phase diagram as the one with many firms, as confirmed by the analytical solution, which is identical to the one above when η is small. However, the oscillations disappear, because in this model savings are not considered, consistently with the above analysis. But since the model is so simple, one can hope that many of the extensions discussed in the next section can be understood analytically within this “representative firm” framework. This would be an important step to put the rich phenomenology that we observe on a firm basis. 13

0.02 0.003 price 0 savings -0.003 0.01 4050 4100

0.00

-0.01 10000 10025 10050 t

FIG. 5: Oscillation in the “good” state of the economy of Mark 0. The simulation is run with η+ = 0.5, η− = 0.3, NF = 10 000 firms, c = 0.5, β = 0, γp = 0.1, ϕ = 1, Θ = ∞, δ = 0. We plot average price and average savings (shifted by their averages for clarity) as a function of time. When prices are low, savings increase, while when prices are high, savings decrease. See text for a more detailed description. In the inset we plot the same quantities obtained by simulating Eq. 21 (as one can see the simplified model well captures oscillations).

V. EXTENSIONS OF MARK 0: ADAPTATION, WAGES AND CONFIDENCE

As emphasized above, the Mark I+ and Mark 0 models investigated up to now both reveal a generic phase transition between a “good” and a “bad” state of the economy. However, many features are clearly missing to make these models plausible – setting full-blown, realistic macroeconomic Agent-Based Models is of course a long and thorny endeavour which is precisely what we want to avoid at this stage, focusing instead on simple mechanisms. Still, it is interesting to enrich these simplified models not only to test for robustness of our phase transition but also to investigate new effects that may be of economic significance. We consider here three meaningful ingredients: Adaptation, Wage dynamics and Confidence, that lead to substantial modifications of the above simple picture, and to quite surprising effects. Yet, it is important to stress that in this Section we report results that are still preliminary and not fully understood. A more thorough analysis of these results will be presented in a subsequent paper.

A. Adaptation of firms

The strategy of firms in Mark 0 is to hire/fire proportionally to the difference between demand for their goods and production. The coefficients η± give the amplitude of this adjustment, and are chosen to be time independent and homogeneous across firms. However, one should expect that depending on the financial fragility of the firm, the production adjustment might be more or less aggressive. Firms that are close to bankruptcy are probably faster to i fire and slower to hire, and viceversa for healthy firms. In order to model this effect, we posit that the coefficients η± for firm i depend on its financial fragility Φi = −Li/(WiYi), as:

i 0 η± = η± (1 ∓ ΓΦi) , (25)

0 9 where η± are fixed coefficients, identical for all firms, and Γ measures the strength of the feedback. Intuitively, this coupling should have a stabilizing effect on the economy; this is indeed what we find numerically. For a given value of Γ, we find that the steady state value of the unemployment rate is no longer ≈ 0 or ≈ 1 depending on the ratio 10 η+/η−, but rather takes continuous values in the range [0, 1].

9 i 0 Actually, we force the coefficients η± to remain in the range [0, 2η±]. 10 As mentioned above, the mere presence of a finite default threshold Θ is enough to induce similar effects, through the stabilizing redistribution of capital between households and firms that occurs when firms are revived. 14

In order to derive an estimate of these continuous values we use an intuitive argument which is justified a posteriori 0 0 by the good match with numerical results. Given the critical ratio η+/η− = Rc separating the high/low unemployment phases when there is no adaptation (i.e. Γ = 0) one can expect that equilibrium values of the unemployment rate i i different from 0 and 1 can only be stable if η+/η− remains around the critical value Rc at Γ = 0, given in Eq. (20). Near criticality therefore we enforce that:

i 0 0 0 η+ η+(1 − ΓΦi) Rcη− − η+ i = 0 = Rc ⇒ −ΓΦ ≈ 0 0 . (26) η− η−(1 + ΓΦi) Rcη− + η+

An explicit form of Φ in terms of the employment rate ε = Y can be obtained with the additional assumption that i i the system is always close to equilibrium (i.e. p ≈ 1 and D ≈ Y , at least when η+/η− ∼ Rc), which allows one to express households savings in terms of the firms’ production. Indeed (recall the discussion at the beginning of Sec. IV) at equilibrium W = B = NFY = c(W + S), from which it follows that NFY = W = Sc/(1 − c). For c = 0.5 as in our simulations one thus has S = NY . Since the total amount of money is conserved (in our simulations NFL + S = NFL + NFY = NF, see Appendix B) one finally obtains that L = 1 − Y and Φ = (Y − 1)/Y = (ε − 1)/ε (recall that in our simulations µ = 1), hence

0 0 Γ Rcη− − η+ = 0 0 + Γ . (27) ε Rcη− + η+

0 0 Note that according to this formula the employment goes to ε = 1 at the critical point η+ = Rcη−. Above this value, 0 0 the economy is in the “good” state and employment sticks to ε = 1. Moreover, when η+ = Rcη−, ε is proportional to 0 0 Γ and therefore in the limit Γ → 0 one has ε = 0 for all η+ < Rcη−. This is the “bad” phase of full unemployment at Γ = 0, which becomes in this case a phase where employment grows steadily but remains of order Γ except very close to the critical point. Eq. (27) is plotted in Fig. 6 together with numerical results. Note that the representative firm approximation is in good agreement with numerical results also for NF = 10 000. In the inset of Fig. 6 one can see that the variance of 0 the fluctuations of employment rate is diverging as long as the critical value of η+ is approached. This is confirmed by a spectral analysis of the unemployment time series (see Fig. 7). In order to obtain the power spectrum we apply the GSL Fast Fourier Transform algorithm to the time series ε(t) − hεi. As one can see in Fig. 7 the power spectrum is well approximated by an Ornstein-Uhlenbeck form:

2 ω0 I(ω) = I0 2 2 (28) ω0 + ω

0 −1 with ω0 going linearly to 0 when η+ approaches its critical value, meaning that the relaxation time ω0 diverges as one approaches the critical point. Note that this is not the case for the Mark I model (or Mark 0 with Γ = 0) which instead has a white noise power spectrum even in proximity of the transition line. The first order (discontinuous) transition for Γ = 0, Θ = ∞ is thus replaced by a second order (continuous) transition when the firms adapt their behaviour as a function of their financial fragility. As mentioned above, a finite default threshold Θ induces a similar phenomenology.

B. Variable Wages

A very important item missing from the basic Mark 0 and Mark I models considered above is the dynamics of wages, which are fixed across time and across firms in these models. Clearly, the ability to modulate the wages is complementary to deciding whether to hire or to fire, and should play a central role in the trajectory of the economy as well as in determining inflation rates. In our money conserving toy economies, a stationary inflation rate different from zero is possible as long as the ratiop ¯(t)/w¯(t) fluctuates around a steady state. Using the wage update rules defined below, we found that the average inflation rate depends on parameters such as the households propensity to consume c and the price/wage adjustment parameters γp,w. Most interestingly, we observe a strong dependence of the inflation rate upon the bankruptcy threshold Θ, with larger bankruptcy thresholds allowing for higher inflation rates and viceversa. Within a broad range of parameters setting we also observe a critical threshold Θc below which the inflation becomes negative. When Θ ∼ Θc periods of inflation and deflation alternate and the model display interesting instabilities. A promising future research direction, that would address some crucial policy problems usually discussed within DSGE models, is to study the coupling inflation with the households propensity to consume (higher inflation resulting in higher c), with the interest rate on loans (affecting the effective bankruptcy threshold), 15 1 102 0 2 10 0.8 -2 10 -4

(ε) / Γ 10 0.6 10-6 Var 10-8 Γ/ε 0 0.025 0.05 0.075 0.1 0.4

0 −3 NF = 10 , Γ = 10 0 −4 0.2 NF = 10 , Γ = 10 4 −3 NF = 10 , Γ = 10 N = 104, Γ = 10−4 0 F 0 0.02 0.04 0.06 0.08 0.1 0 η +

0 0 FIG. 6: Inverse of the average employment rate (over time) as a function of η+ with η− = 0.1 and γ = 0.01 when Γ > 0. The other parameters are set as in Fig. 4. When the employment rate is rescaled with the parameter Γ (here Γ = 10−3, 10−4) the different lines collapse and Eq. (27) agrees with numerical simulations. In the inset we also plot the rescaled variance, still as 0 a function of η+. Approaching the critical point the variance of the unemployment fluctuations diverges, together with their relaxation time going to infinity.

4 0 10,0 7,5 5 5 2 7,5 -2 5,0

∗ 10 5,0 ∗ 10 0 0

0 ω 2,5 -4 ω 2,5 0 0 -2 0 0.05 0.1 -6 0 0.05 0.1 (ω)) η 0 (ω)) η 0 (I -4 + (I -8 + 10 10 -6 -10 Log Log -8 -12 -10 -14 -12 -16 -7 -6 -5 -4 -3 -2 -1 0 -7 -6 -5 -4 -3 -2 -1 0 Log10(ω) Log10(ω)

−3 FIG. 7: Logarithm of the normalized power spectrum for Mark 0 with adaptive firms (Γ = 10 ), γp = 0.05 and NF = 1 (left) and NF = 1000 (right). The other parameters are set as in Fig. 4. The main plot show two examples of the spectrum for 0 0 0 η− = 0.1 and: η+ = 0.05 (black line) and η+ = 0.09 (red line) in the left plot, η+ = 0.05 (black line) and η+ = 0.08 (red line) 28 in the right plot. The time series is made of 2 time steps after Teq = 500 000 and the logarithm of the spectrum is averaged over a moving window of 100 points for a better visualization. With both system sizes the fit with Eq. (28) (blue dashed lines) is good with the only difference that when NF > 1 a clear oscillatory patterns appear at high frequencies, that becomes sharper and sharper as NF increases. In the inset of each figure we plot the value of ω0 in Eq. (28) obtained from the fit as a function 0 of η+. In both cases ω0 goes linearly to 0 as the critical value is approached. etc. We however defer the analysis of these situations for later investigations, and here analyze the influence of wage adjustments on the phase transition discussed in the previous sections. Introducing wages in Mark 0 again involves a number of arbitrary assumptions and choices. Here, we follow (in spirit) the choices made in Mark I for price and production update, and propose the following rules for wages:  Yi(t) < Di(t) T 0  Wi (t + 1) = Wi(t)[1 + γw(1 − ΓΦi)εRi(t)] if pi(t) > p¯(t)  Pi(t) > 0  (29) Yi(t) > Di(t) 0  Wi(t + 1) = Wi(t)[1 − γw(1 + ΓΦi)uRi(t)] if pi(t) < p¯(t)  Pi(t) < 0 16 where u = 1 − ε is the unemployment rate, γw a certain parameter, Pi(t) = min(Di(t),Yi(t))pi(t) − Wi(t)Yi(t) is the 0 T profit of the firm at time t and Ri(t) an independent U[0, 1] random variable. If Wi (t + 1) is such that the profit of firm i at time t with this amount of wages would have been negative, Wi(t + 1) is chosen to be exactly at the T equilibrium point where Pi = 0, hence Wi(t + 1) = min(Di(t),Yi(t))pi(t)/Yi(t); otherwise Wi(t + 1) = Wi (t + 1). As before, the fragility Φ is defined as Φi = −Li/(YiWi), i.e. it is the ratio of the negative of the liquidity of the firm to its total payroll. The corresponding condition for default is Φi > Θ. The above rules are intuitive: if a firm makes a profit, has a large demand for its good while its price is high, it will increase the pay of its workers. The pay rise is expected to be large if the firm is financially healthy and/or if unemployment is low (i.e. if ε is large) because pressure on salaries is high. Conversely, if the firm makes a loss, has a low demand for its good while its price is already low, it will reduce the wages. This reduction is drastic is the company is close to bankruptcy, and/or if unemployment is high, because pressure on salaries is then low. In all other cases, wages are not updated. When a firm is revived from bankruptcy (with probability ϕ per unit time), its wage is set to the production weighted average wage of all firms in activity. The rest of the model is unchanged compared to Mark 0. We first set the adaptation parameter Γ introduced in the previous section to zero, Γ = 0. In this case, the phenomenology that we find is very similar to the simple Mark 0 without wages, at least when Θ  1. We find again a first order critical boundary in the (η+, η−) plane that separates a high unemployment phase from a low unemployment phase. The latter is still characterized by large quasi-periodic oscillations that survive when NF  1. This demonstrates the robustness of our scenario against changes; introducing wages is a rather drastic modification but still does not affect the major finding of this study. One can change the wage update rule further and see how the macro-state of the economy is sensitive to these micro-rules. One can for example change the wage update rules as follows: ( T 0 Yi(t) < Di(t) Wi (t + 1) = Wi(t)[1 + γw(1 − ΓΦi)εRi(t)] if Pi(t) > 0 ( (30) 0 Yi(t) > Di(t) Wi(t + 1) = Wi(t)[1 − γw(1 + ΓΦi)uRi(t)] if Pi(t) < 0 which means that in all cases where the firms need to hire (D > Y ) and make a profit (P > 0), they also raise the wages, and viceversa – but independently of the price of their good compared to the average, as was the case of rule (29). Here we again find a sharp phase transition as above, but the fluctuations of production, savings, firms’ assets, etc. are much smaller in both phases, and in this case go to zero for large economies. Note that we found size independent oscillations for the rule (29), much as what we found for Mark 0. We have at this stage no clear explanation for this difference. We now add in the game the adaptation parameter of the firms, Γ, on top of the wage update rules. As with fixed wages, we find that the transition between a high unemployment state and a low unemployment state is much more progressive, as explained in the previous section. But to our surprise, we find that the low unemployment phase can be, for certain parameters and for both rules (29) and (30), unstable against sudden endogenous crisis, during which the unemployment shoots up, before reverting to a small value for a rather long time (see Fig. 8). We find in particular that a large price sensitivity (i.e. a larger value of β) favors the appearance of these endogeneous crises. This is in agreement with the general idea that more efficiency leads to more fragility (see e.g. [16, 30, 31]) – i.e. as consumers are more and more looking for the best price and concentrating their demand on fewer firms, the system as a whole is more unstable (see also [21] where similar effects are discussed). In summary, the main conclusions of the present section on wage dynamics are: • The phase transition between low and high unemployment is robust against the introduction of wage dynamics. • The precise wage update rules seem to influence the macro-state of the economy – some rules leading to more fluctuations and instabilities, others leading to very small fluctuations that disappear with the size of the system. • Adding both wage adjustments and feedback between financial fragility of the firm and their hiring/firing policy leads to a very rich phenomenology, with endogenous crisis that derail the economy and lead to unemployment spikes, before reverting to “normal”. Our analytical understanding of these effects is however still very poor; we feel it would be important to bolster the above numerical results by solving simpler “toy models” as we did for the basic Mark 0 (see section IV and Appendix C). 17 1

0.8

0.6 u 0.4

0.2

0 0 2500 5000 t

0 − FIG. 8: We show here two examples of “endogeneous crises”, for wage update rule (29), η+ = 0.5, η0 = 0.3, Γ = 0.1, β = 2. 0 − (black line) and update rule (30), η+ = 0.5, η0 = 0.3, Γ = 0.5, β = 2. (red line). The value of all γ parameters is 0.05 here. Increasing β tends to increase the frequency of the crises. Note that in the first case, the economy seems to stabilize during quite a long time in a favorable state, before a crisis unravels.

C. Confidence effects

Another effect that we feel should be included in any realistic macroeconomic Agent-Based Model is trust or confidence, that may appear and disappear on time scales much shorter than the evolution time scale of any “true” economic factor, and lead to market instabilities and crises (see e.g. [3, 32]). There are again many ways to model the potentially destabilizing feedback of confidence. One of the most important channel is the loss of confidence induced by raising unemployment, that increases the saving propensity of households and reduces the demand. The simplest way to encode this in Mark 0 is to let the “c” parameter, that determines the fraction of wages and savings that is devoted to consumption, be an increasing function of the employment rate ε = 1 − u. We parametrize this by replacing c → c × ε$, where $ is an exponent that determines the strength of the unemployment → savings feedback. When $ = 0, we recover the Mark 0 specification where c is constant, independent of ε. When $ > 0, on the other hand, the demand decreases as unemployment becomes larger. We find that this feedback loop can indeed also induce purely endogenous swings of economic activity. We show here one example with wage update rule (29) and with Γ = 0 – see Fig. 9. Note in particular the large fluctuations in output that follow after recovery. As we warned at the beginning of this section, the results presented here are neither exhaustive nor fully understood. Mapping out the full phase space of the model takes time, and we are still very much in an exploratory mode concerning the extension of Mark 0 to include variable wages and confidence effects. Still, we believe that it is interesting to show how rich the phenomenology of our hybrid Mark 0 model is.

VI. SUMMARY, CONCLUSION

The aim of this work (which is part of the CRISIS project and still ongoing) is to explore the possible types of phenomena that simple macroeconomic Agent-Based Models can reproduce. The precise motivation for our study was to understand in detail the nature of the macro-economic fluctuations observed in the “Mark I” model devised by D. Delli Gatti and collaborators, which is at the core of the CRISIS project. Our major finding is the generic existence, in Mark I (and variations around that model) of a first order (discontinuous) phase transition between a “good economy” where unemployment is low, and a “bad economy” where unemployment is high. By studying a simpler hybrid model (Mark 0), where the household sector is described by aggregate variables and not at the level 18 1

0.8

0.6 u 0.4

0.2

0 0 2500 5000 t

FIG. 9: An example of crises induced by a loss confidence, due to rising unemployment that affects demand. We show here 0 − data for wage update rule (29), c = 0.5, η+ = 0.5, η0 = 0.3, Γ = 0., β = 2., γp = γy = γw = 0.1, and with $ = 0 (red line, “good” economy and no crises) and $ = 2. (black line, appearance of crises). Note again the periodic oscillations in the former case, and the large fluctuations in output (“clustered volatility”) that follow after recovery.

of agents11, we have shown that this transition is induced by an asymmetry between the rate of hiring and the rate of firing of the firms. This asymmetry can have many causes at the micro-level – in Mark I, for example, it reflects the reluctance of firms to take loans when the interest rate is too high. As the interest rate increases, the unemployment level remains small until a tipping point beyond which the economy suddenly collapses. If the parameters are such that the system is close to this transition, any small fluctuations (for example in the level of interest rates) is amplified as the system jumps between the two equilibria. It is actually plausible that the central bank policy (absent in our current model) does bring the system close to this transition, since too low an interest rate leads to overheating and inflation, and too high an interest rate leads to large unemployment. The aim of the central bank is therefore to control the system in the vicinity of an instability and could therefore be a natural realization of the ‘self-organized criticality’ scenario recently proposed in [34]. Mark 0 is simple enough to be amenable to an analytic treatment, that allows us to compute approximately the location of the transition line as a function of the hiring/firing propensity of firms. Mark 0 can furthermore be extended in several natural directions. One is to allow this hiring/firing propensity to depend on the financial fragility of firms – hiring more when firms are financially healthy and firing more when they are close to bankruptcy. Quite interestingly, we find that in this case, the above transition survives but becomes second order. As the transition is approached, unemployment fluctuations become larger and larger, and the corresponding correlation time becomes infinite, leading to very low frequency fluctuations. There again, we are able to give some analytical arguments to locate the transition line. Other stabilizing mechanisms, such as the bankruptcy of indebted firms and their replacement by healthy firms (financed by the savings of households), lead to a similar phenomenology. Two further extensions have been considered: one is to allow firms to vary the wages of their employees according to some plausible rules of thumb (wages in Mark I and Mark 0 are fixed); the second is to introduce some confidence feedback effects, whereby higher unemployment increases the saving propensity of households and decreases the demand for goods, possibly leading to an unstable loop. Although our results are not as tight in these cases, we find several interesting effects, in particular the appearance of acute endogenous crises, during which the unemployment rate shoots up before the economy recovers. The existence of purely endogenous crises in such simple settings is quite interesting from a general standpoint (see also [21, 23], and reinforces the idea that many economic and financial crises may not require large exogenous shocks (see [3, 19, 35–39] for related discussions). Several extensions are of obvious interest, and we plan to study them in the near future in the same stylized way as above. The most obvious ones is to understand how inflation sets in and how a central bank that prints money and sets exogenously the interest rate can control the inflation rate in the vicinity of an unstable point, as we just

11 For a recent study exploring the idea of hybrid models, see [33]. 19 mentioned. Other interesting topics are: modeling research and innovation, allowing firms to produce different types of goods, and introducing a financial sector and a housing market [40]. Beyond the generic phase transition discussed in the whole paper, we found another notable, robust feature: the low unemployment phase of all the ABMs we considered are characterized by endogenous oscillations that do not vanish as the system size becomes large, with a period corresponding, in real time, to ∼ 5 − 10 years [23]. It is tempting to interpret these oscillations as real and corresponding to the “business cycle”, as they arise from a very plausible loop between prices, demand and savings. These oscillations actually also appear in highly simplified models, where both the household and the firm sectors are represented by aggregate variables [41]. Building on this last remark, a very important question, it seems to us, is how much can be understood of the phenomenology of ABMs using “mean-field” approaches, i.e. dynamical equations for aggregate variables of the type considered, for example, in [28, 29]? A preliminary analysis reveals that the dynamical equations corresponding to Mark 0 or Mark I already lead to an amazingly complex phase-diagram [41]. Are these mean-field descriptions quantitatively accurate? When do we really need agents and when is an aggregate description sufficient? The answer to this question is quite important, since it would allow one to devise faithful “hybrid” ABMs, where whole sectors of the economy would be effectively described in terms of these aggregate variables, only keeping agents where they are most needed. Another nagging question concerns the calibration of macroeconomic ABMs. It seems to us that before attempting any kind of quantitative calibration, exploring and making a catalogue of the different possible qualitative “phases” of the model is mandatory. Is the model qualitatively plausible or is the dynamics clearly unrealistic? In what “phase” is the true economy likely to be? On this point, one of the surprise of the present study is the appearance of very long time scales. For example, even in the case of perfectly stable economy with wage update rule (30) and all γ parameters equal to 10% (a rather large value), the equilibrium state of the economy (starting from an arbitrary initial condition) is only reached after ≈ 200 time steps. If one thinks that the elementary time scale in these models is of the order of three months, this means that the physical equilibration time of the economy is 20-50 years, or even much longer, see Figs. 2 & 4. But there is no reason to believe that on these long periods all the micro-rules and their associated parameters are stable in time. Therefore, studying the stationary state of macroeconomic ABMs might be completely irrelevant to understand the real economy. The economy could be in a perpetual transient state (aka “non ergodic”), unless one is able to endogenize the time evolution of all the relevant parameters governing its evolution (see the conclusion of [8] for a related discussion). If this is the case, is there any use in studying ABMs at all? We strongly believe that ABMs would still be genuinely helpful. ABMs allow us to experiment and scan the universe of possible outcomes – not missing important scenarios is already very good macroeconomics. Human imagination turns out to be very limited, and that is the reason we like models and equations, that help us guessing what can happen, especially in the presence of collective effects that are often very counterintuitive. In this respect, ABMs provide extremely valuable tools for generating scenarios, that can be used to test the effect of policy decisions (see e.g. the pleas by Buchanan [14], and Farmer & Foley [15]). In order to become more quantitative, we think that ABMs will have to be calibrated at the micro-level, using detailed behavioural experiments and field studies to fine tune all the micro-rules needed to build the economy from bottom up (see [40, 42] for work in this direction). Calibrating on historical data the emergent macro-dynamics of ABMs will most probably fail, because of the dimensionality curse and of the Lucas critique (i.e. the feedback between the trajectory of the economy and policy decisions that dynamically change the parameters of the model).

Acknowledgements

This work was partially financed by the CRISIS project. We want to thank all the members of CRISIS for most useful discussions, in particular during the CRISIS meetings. The input and comments of P. Aliferis, T. Assenza, J. Batista, E. Beinhocker, D. Challet, D. Delli Gatti, D. Farmer, J. Grazzini, C. Hommes, F. Lillo, G. Tedeschi, S. Battiston, A. Kirman, A. Mandel, M. Marsili and A. Roventini are warmly acknowledged. 20

Appendix A: Pseudo-code for Mark I+

We describe here the pseudo-code of our version of Mark I, which we call Mark I+. To keep the length reasonable, a few irrelevant details will be omitted, but the information given here is enough to reproduce the results presented in the paper. In particular, we describe here only the part of the code that is needed to generate the dynamical evolution of the model, and we omit the part that is needed to generate the data output. The source code is available on the website of the CRISIS project (www.crisis-economics.eu).

1. Notations

We describe the algorithm in an object-oriented fashion, where the different agents are described as representatives of a few classes. We use an object oriented syntax. This syntax should be very intuitive and easy to follow. However, it is useful to clarify a few notational conventions: • The declaration of a variable a (for example of integer type int) will be written in C syntax as int a. • If a is an object of some class, then a.f(x) means that we are calling the method (function) f(x) of object a with argument x. • For simplicity, in the for loops we will use the C syntax where, for example, for(t ← 1; t ≤ T ; t ← t + 1) means that t is set to one before the loop starts, t is increased by 1 at the end of each iteration, and the loop continues if the condition t ≤ T is true. • Instead of arrays we will use vectors of objects, and we will follow the notation of C++12. For example, vector will denote an ordered set (array) of integers. Moreover: – A vector of size N will be declared as vector A(N), and by default the declaration vector A means that the set A is initiated as empty. – |A| will denote the size of the set A – The notation A[i] will denote the i-th element of the set (with i = 0, ··· , |A| − 1). – The notation A ← a will denote the operation of adding the element a to the set A, therefore increasing its size by one (this correspond to the “push back” operation in C++).

– The notation a ←R A will denote the extraction of a random element from A, which is set equal to a. 0 Note that the element is not removed from A so the size of A remains constant. The notation A ←R,M A denotes extraction at random of M different elements from the set A, that constitute the set A0. – The notation A 6→ a will denote the removal of element a from set A, therefore reducing the size of A by one. – To denote an ordered iteration over an ordered set A, we will use a loop for(a ∈ A). – We define a function average(a.f(), a ∈ A) that returns the average of the |A| numbers a[i].f(), i = 0, ··· , |A| − 1 • For logical operators, we use the C++ convention13 which should be quite transparent.

2. Classes

The classes are: • Firm • Household • Bank

12 See for example http://www.cplusplus.com/reference/vector/vector/ 13 http://en.wikipedia.org/wiki/Operators_in_C_and_C++#Logical_operators 21

The role of the bank is very limited at this level and this class is mainly included for the purpose of future extension. One household has a special role as it is the “owner” of the firms, which will pay dividends to this one household. The main loop is described in Algorithm 1 below. The implementation of the firm class is in Algorithm 3, the household class in Algorithm 6 and the bank class in Algorithm 7.

Algorithm 1 Main loop of Mark I+

Require: NF Number of firms; NH Number of households; ρ0 baseline interest rate; T total evolution time;

. Initialisation vector H(NH) household O . The owner of all firms vector F (NF) bank B

p ← 1 . Average price for f ∈ F do f.set owner(O) end for B.set ρ(ρ0) . Main loop for (t ← 1; t ≤ T ; t ← t + 1) do

vector E,D for f ∈ F do . Firm decide new strategy on prices and production f.set new strategy(p) f.get loans(B) f.compute interests() f.define labor demand() if f.n vacancies() > 0 then D ← f . Firms in D demand workforce else if f.n vacancies() < 0 then E ← f . Firms in E have an excess of workforce end if end for

for f ∈ E do . Job market and production while f.n vacancies() < 0 do f.fire random worker() . Firms with excess workforce fire random workers end while end for vector U for h ∈ H do if !h.working() then U ← h . U is the set of unemployed households end if end for while |U| > 0 && |D| > 0 do . Random match of unemployed households and demanding firms h ←R U f ←R D f.hire(h) U 6→ h if f.n vacancies()==0 then D 6→ f end if end while 22

Algorithm 2 Main loop of Mark I+ (continued) for f ∈ F do . Firms produce and pay workers f.produce() f.pay workers() if f.age()<100 then f.markup rule() . Young firms apply a markup rule to avoid bankrupt end if end for . Goods market H ←random permutation(H) for h ∈ H do h.consume(F ) . Consume in random order end for . Accounting and bankrupts bad debts ← 0 vector L for f ∈ F do f.accounting(B) if f.liquidity() < 0 then . Firms with negative liquidity go bankrupt bad debts ← bad debts + f.liquidity() . Note: bad debts is negative! L ← f . L is the sent of bankrupt firms else L ← f .L is the set of healthy firms end if end for if |L| == 0 then break . If all firms are bankrupt, exit the program end if

pb ← average(f[i].price(), f ∈ L) T Y ← average(f[i].target production(), f ∈ L) Y ← average (f[i].production(), f ∈ L) T for f ∈ L do f.reinit(pb, Y , Y ) . Bankrupt firms are reinitialized with the average parameters of healthy firms end for PNF PNH total liquidity ← i=0 f[i].equity() + i=0 h[i].wealth() for f ∈ F do f.get money(bad debts * f[i].equity() / total liquidity) end for for h ∈ H do h.get money(bad debts * h[i].wealth() / total liquidity) end for . Bad debt is spread over firms and households proportionally to their wealth P|F |−1 i=0 f[i].price() f[i].sales() p ← P|F |−1 . Update average price i=0 f[i].sales() end for 23

Algorithm 3 The class firm

Parameters : W = 1, α = 1, γp = 0.1, γy = 0.1, µ = 0, δ = 0.2, τ = 0.05 Dynamic variables : vector E; household O; p, Y, Y T ,D, L, v, DT , t Dynamic variables (auxiliary): Ld, ρ, I . Initialization methods function init E ←empty . The set E is the list of employees and is initialized as empty p ← 1 . Price Y ← 1 . Production Y T ← 1 . Target production D ← 1 . Demand L ← 50 . Liquidity v ← 0 . Number of vacancies DT ← 0 . Total debt t ← 0 . Internal clock end function

function set owner(household Oe) O ← Oe end function

T function reinit(p,e Ye , Ye) p ← pe Y ← Ye Y T ← Ye T D ← 0 L ← min{O.wealth(), Y/α} . The owner injects money to restart the bankrupt firm O.get money(-L) v ← 0 DT ← 0 t ← 0 v ← 0 for h ∈ E do fire(h) end for end function . Output methods function price return p end function

function production return Y end function

function stock return Y − D end function

function sales return D end function

function target production return Y T end function

function equity return L − DT end function

function liquidity return L end function

function n vacancies return v end function 24

Algorithm 4 The class firm (continued) function age return t end function . Accounting methods function get money(me ) L ← L + me end function function get loans(bank Be) Ln ← WLd − L . Financial need if Ln > 0 then T ` ← (D + Ln)/(L + 0.001) . This is the leverage ρoffer ← Be.compute offer rate(`) . New offered interest rate c D ← Ln F (ρoffer) . The function F (ρ) can be whatever decreasing function of ρ, see Eq. (4) if Dc > 0 then ρ ← ρoffer . If new credit is contracted, the interest rate is updated DT ← DT + Dc . Total debt is increased by current debt Dc L ← L + Dc Be.get money(-Dc) end if end if end function function compute interests I ← ρDT . Interests to be paid in this round end function function pay workers for h ∈ E do h.get money(W ) end for L ← L − W |E| end function function markup rule if Y > 0 then pmarkup ← (1 + µ)(W |E| + I)/Y p ← max{p, pmarkup} end if end function function accounting(bank Be) L ← L − I − τDT . Firm pays interests and repays a fraction τ of its debt Be.get money(I + τDT ) DT ← (1 − τ)DT P ← pD − W |E| − I . Profit if P > 0 then O.get money(δP) . Firm pays dividends to the owner L ← L − δP end if end function function sell(qe) D ← D + qe L ← L + pqe end function 25

Algorithm 5 The class firm (continued) . Production and job market methods function set new strategy(pe) t ← t + 1 T if Y = D && p ≥ pe then Y ← Y (1 + γy random) . This is Eq. (1) in the main text else if Y = D && p < pe then p ← p(1 + γp random) else if Y > D && p ≥ p then p ← p(1 − γp random) e T else if Y > D && p < pe then Y ← Y (1 − γy random) end if Y T ← max{Y T , α} T Ld ←ceil(Y /α) end function function define labor demand Ld ← min{Ld, floor(L/W )} Ld ← max{Ld, 0} v ← Ld − |E| end function function produce Y = min{Y T , α|E|} D = 0 . The demand is reset to zero at each production cycle end function function hire(household h) E ← h h.get job(W ) v ← v − 1 end function function fire(household h) h.lose job() E 6→ h v ← v + 1 end function function fire random worker if |E| > 0 then h ←R E fire(h) end if end function 26

Algorithm 6 The class household Parameters : M = 3, c = 0.8 Dynamic variables : S, W . Initialization methods function init S ← 0 . Savings W ← 0 . Salary end function . Accounting methods function get money(me ) S ← S + me end function . Output methods function wealth return S end function

function working if W > 0 then return True else return False end if end function . Job and goods market methods function get job(Wf) W ← Wf end function

function lose job W ← 0 end function

function consume( vector Fe ) budget ← cS if budget > 0 then Fc ←R,M F.e Extract M random firms from Fe and put them in the set Fc Fc ← sort(f ∈ Fc, f.price()) . Order the set Fc according to firms’ prices spent ← 0 for (i ← 0; i < |Fc| && spent < budget; i ← i + 1) do s ← f[i].stock() . s is the stock available from this firm if s > 0 then q ← (budget - spent)/f[i].price() . Maximum possible consumption from this firm if s > q then f[i].sell(q) spent ← budget . The household has finished the budget, the loop ends else f[i].sell(s) spent ← spent + s f[i].price() end if end if end for end if S ← S−spent end function 27

Algorithm 7 The class bank

Dynamic variables : E, ρb

function init E ← 0 . Bank liquidity ρb ← 0 . Baseline interest rate end function

function set ρ(ρe) ρb ← ρe end function

function compute offer rate(`e) return ρb G(`e) . We chose G(`) = 1 + log(1 + `) end function

function get money(me ) E ← E + me end function 28

Appendix B: Pseudo-code of Mark 0

We present here the pseudo-code for the minimal Mark 0 model discussed in Sec. III A. The source code of Mark 0 (including the extensions discussed in Sec. V) is available on the website of the CRISIS project (www.crisis- economics.eu).

Algorithm 8 The basic Mark 0

Require: NF Number of firms; µ, c, β, γp, η+, η−, δ, Θ, ϕ; T total evolution time;

. Initialization for (i ← 0; i < NF; i ← i + 1) do W [i] ← 1 . Salaries are always fixed to one p[i] ← 1 + 0.2(random − 0.5) Y [i] ← µ[1 + 0.2(random − 0.5)]/2 . Initial employment is 0.5 L[i] ← W [i]Y [i] 2 random a[i] ← 1 end for P S ← i W [i]Y [i]

. Main loop for (t ← 1; t ≤ T ; t ← t + 1) do u ← 1 − 1 P Y [i] µNF i P i p[i]Y [i] p ← P i Y [i] . Firms update prices and productions for (i ← 0; i < NF; i ← i + 1) do if a[i] == 1 then if Y [i] < D[i] then . This is Eq. (9) in the main text Y [i] ← Y [i] + min{η+(D[i] − Y [i]), µu} if p[i] < p then p[i] ← p[i](1 + γp random) end if else if Y [i] > D[i] then Y [i] ← max{0,Y [i] − η−(D[i] − Y [i])} if p[i] < p then p[i] ← p[i](1 − γp random) end if end if end if end for u ← 1 − 1 P Y [i] . Update u and p µNF i P i p[i]Y [i] p ← P i Y [i] . Households decide the demand P B ← c(max{S, 0} + i W [i]Y [i]) for (i ← 0; i < NF; i ← i + 1) do Ba[i] exp(−βp[i]/p) D[i] ← P . Inactive firms have no demand p[i] i a[i] exp(−βp[i]/p) end for

. Accounting for (i ← 0; i < NF; i ← i + 1) do if a[i] == 1 then P[i] ← p[i] min{Y [i],D[i]} − W [i]Y [i] S ← S − P[i] L[i] ← L[i] + P[i] if P[i] > 0 && L[i] > 0 then . Pay dividends S ← S + δ P[i] L[i] ← L[i] − δ P[i] end if end if end for 29

Algorithm 9 The basic Mark0 (continued) . Bankrupts and revivals for (i ← 0; i < NF; i ← i + 1) do if a[i] == 0 && random < ϕ then . Reactivate firm a[i] ← 1 p[i] ← p Y [i] ← µu random L[i] ← W [i]Y [i] S ← S − W [i]Y [i] end if if a[i] == 1 && L[i] < −ΘY [i]W [i] then . Bankrupt a[i] ← 0 Y [i] ← 0 S ← S + L[i] L[i] ← 0 end if end for end for 30

Appendix C: Perturbative solution of the schematic model

In the limit γ, η → 0, the stationary distribution for λ obeys Eq. (17):

Z 1−max(λ,0) Z 1−max(−λ,0) P (λ) = dRP (λ + R) + dRP (λ − R) (C1) max(0,−λ) max(0,λ)

We will call L the linear operator that appears on the right hand side. n n When one compute the action of L on the functions gn(λ) = sign(λ)λ and hn(λ) = λ , one finds, for λ > 0:

n−1 n X k k n−k (n + 1)Lgn(λ) = 1 − (−1) − Dn(−1) λ (C2) k=0 and for λ < 0:

n−1 n X k n−k (n + 1)Lgn(λ) = 1 − (−1) + Dnλ (C3) k=0

k Pn k with Dn = j=k Cj , and, for λ > 0:

n n+1 n+1 n n+1 X k k n+1−k (n + 1)Lhn(λ) = 1 − λ − (λ − 1) = 1 + (−1) − 2λ − Cn+1(−1) λ . (C4) k=1 For λ < 0, one finds instead:

n n+1 n+1 n n n+1 X k n+1−k (n + 1)Lhn(λ) = (1 + λ) + λ + (−1) = 1 + (−1) + 2λ + Cn+1λ . (C5) k=1 For example:

n = 0 → Lg0 = 0; Lh0 = 2(h0 − g1) (C6)

n = 1 → Lg1 = 1 − g1; Lh1 = −g2 + h1 (C7)

2 n = 2 → Lg = h − g ; Lh = (h − g ) + h − g . (C8) 2 1 2 2 3 0 3 2 1 So one has:

L(h0 − g1) = 2(h0 − g1) − 1 + g1 = (h0 − g1). (C9)

Therefore P0(λ) = h0(λ)−g1(λ) = 1− |λ| (the tent) is an eigenvector of L with eigenvalue 1, i.e. this is the stationary state. This basic solution allows us to obtain perturbatively the stationary solution for small γ, η. Looking first at the case η± = 0, one has:

Z a+ 1 Z b+ 1 P (λ) = dRP (λ + R + γR2) + dRP (λ − R + γR2) (C10) a− 2 b− 2 with: γ γ a = max(0, −λ(1 + λ)), a = min(1, 1 − λ − (1 − λ)2) (C11) − 2 + 2 and γ γ b = max(0, λ(1 + λ)), b = min(1, 1 + λ + (1 + λ)2). (C12) − 2 + 2 31

Now one should write P = P0 + γP1 where P0 is the tent solution. The equation has the form:

(1 − L)P1 = S. (C13)

1 We find for the source term: S = 2 h1 − g2. This is nice because one can look for a solution of the form:

P1 = αh1 + βg2 (C14)

Using: Lg2 = h1 − g2 = Lh1, one finds:

(1 − L)P1 = αh1 + βg2 − (α + β)(h1 − g2) = −βh1 + (α + 2β)g2 (C15)

So the identification is: 1 β = − ; α = 0. (C16) 2 The final solution for the stationary state to first order in γ is: 1 P = 1 − |λ| − γ sign(λ)λ2. (C17) 2 Note that P is still normalized, as it should and goes to zero at the correctly shifted values (to first order in γ). The last subtlety concerns the fact that to order γ, one should expand D − Y to second order in λ, which leads to the following critical condition: 1 1 η (λ − γλ2)− + η (λ − γλ2)+ = 0. (C18) + 2 − 2 To the same level of approximation, the final result reads: η 1 − γ + = , (C19) η− 1 + γ in very agreement with our numerical data for Mark 0 and for its NF = 1 approximation (see text).

[1] A. Kirman, Whom or What Does the Representative Individual Represent?, Journal of Economic Perspectives, 6: 117-136 (1992). [2] see e.g.: P. Ball. Why Society is a Complex Matter. Springer, Berlin (2012) for an introductory review. [3] for a recent review, see: J.-P. Bouchaud, Crises and Collective Socio-Economic Phenomena: Simple Models and Challenges, J. Stat. Phys. 151: 567-606 (2013), and refs. therein. [4] for a concise overview of ABM for collective phenomena, see: R. Goldstone, M. Janssen, Computational Models of Collective Behavior, Trends in Cognitive Science 9: 424-30 (2005). [5] for early papers on ABM for economics, see e.g.: R. L. Axtell, Why agents? On the varied motivations for agent computing in the social sciences, in: Sallach, C. M. Macal and D. (Eds.), Proceedings of the Workshop on Agent Simulation, 2000; L. Tesfatsion, Agent-Based : Growing Economies From Bottom Up, Artificial Life, 8: 55-82 (2002). [6] for some review papers on ABM for economics and finance, see e.g.: A. Leijonhufvud, Agent-Based Macro in Tesfatsion,L. and Judd, K. (eds.), Handbook of Computational Economics, 1625-1636 (2006); C. H. Hommes, Heterogeneous Agent Models in Economics and Finance, Handbooks in Economics Series 23, 1109-1186 North-Holland: Elsevier (2006); B. LeBaron and L. Tesfatsion, Modeling macroeconomies as open-ended systems of interacting agents, American Economic Review: Papers and Proceedings, 98: 246-250 (2008); H. Dawid and M. Neugart, Agent-based Models for Economic Policy Design Eastern Economic Journal, 37: 44-50 (2011). M. Cristelli, L. Pietronero, A. Zaccaria: Critical overview of agent-based models for economics. arXiv:1101.1847. [7] C. Sims, Macroeconomics and Reality, Econometrica, 48: 1-48 (1980) [8] G. Fagiolo, A. Roventini, Macroeconomic Policy in DSGE and Agent-Based Models University of Verona Working Paper (2012) [9] A. Kirman, The Economic Crisis is a Crisis for Economic Theory, CESifo Economic Studies, 56: 498-535 (2010) [10] R. J. Caballero, Macroeconomics after the Crisis: Time to Deal with the Pretense-of-Knowledge Syndrome, Journal of Economic Perspectives, 24: 85-102 (2010) [11] for a general, insightful introduction, see: N. Goldenfeld, Lectures on Phase Transitions and the Renormalization Group. AddisonWesley, Reading (1992) 32

[12] P. Bak, How Nature Works: The Science of Self- Organized Criticality, Copernicus, Springer, New York, 1996. [13] on this point, see the interesting discussion in: I. Kondor, I. Csabai, G. Papp, E. Mones, G. Czimbalmos, M. Cs. Sandor, Strong random correlations in networks of heterogeneous agents, arXiv:1210.2224 [14] M. Buchanan, This Economy does not compute, New York Times, October 1, 2008. [15] D. Farmer, D. Foley, The economy needs agent-based modelling, Nature 460, 685-686 (2009) [16] I. Giardina, J.-P. Bouchaud, Bubbles, Crashes and Intermittency in Agent Based Market Models, The European Physics Journal B 31: 421-37 (2003). [17] R. Lyea, J. Peng, L. Tana, S. A. Cheonga Understanding agent-based models of financial markets: a bottom-up approach based on order parameters and phase diagrams, arXiv:1202.0606; [18] The Mark I family of models was elaborated in a series of papers and books, in particular: E. Gaffeo, D. Delli Gatti, S. Desiderio, and M. Gallegati, Adaptive for Emergent Macroeconomics, Eastern Economic Journal, 34: 441-463 (2008); D. Delli Gatti, E. Gaffeo, M. Gallegati, G. Giulioni, and A. Palestrini, Emergent Macroeconomics: An Agent-Based Approach to Business Fluctuations, Springer: Berlin, 2008. [19] D. Delli Gatti, S. Desiderio, E. Gaffeo, P. Cirillo, M. Gallegati, Macroeconomics from the Bottom-up, Springer: Berlin (2011). [20] C. Deissenberg, S. van der Hoog, H. Dawid, Eurace: A massively parallel agent-based model of the european economy, Applied Mathematics and Computation, 204: 541-552 (2008); [21] H. Dawid, S. Gemkow, P. Harting, S. van der Hoog, M. Neugarty; The Eurace@Unibi Model: An Agent-Based Macroeco- nomic Model for Economic Policy Analysis, Working paper, Bielefeld University. 2011. [22] G. Dosi, G. Fagiolo, A. Roventini, An evolutionary model of endogenous business cycles. Computational Economics, 27: 3-24 (2005) [23] G. Dosi, G. Fagiolo, and A. Roventini, Schumpeter meeting Keynes: A policy-friendly model of endogenous growth and business cycles, Journal of Economic Dynamics and Control, 34, 1748-1767 (2010); and [8]. [24] A. Mandel, S. Furst, W. Lass, F. Meissner, C. Jaeger; Lagom generiC: an agent-based model of growing economies, ECF Working Paper 1 /2009. [25] C. Metzig, M. Gordon, Heterogeneous Enterprises in a Macroeconomic Agent-Based Model, arXiv:1211.5575. [26] The version of Mark I that we used as a reference is the one presented by J. Grazzini and D. Delli Gatti at the Crisis Workshop in Milan, November 2012. [27] see e.g. S. P. Anderson, A. De Palma, J. F. Thisse, Discrete Choice Theory of Product Differentiation. MIT Press, New York (1992), and [3] for a recent discussion and further references. [28] R. M. Goodwin, A Growth Cycle, in Feinstein, C.H. (ed) Socialism, Capitalism and Economic Growth, Cambridge Uni- versity Press (1967) [29] P. Flaschel, The Macrodynamics of Capitalism, Springer, Berlin 2010. [30] D. Challet, M. Marsili and Y. C. Zhang, Minority Games, Oxford University Press, 2005. [31] F. Caccioli, P. Vivo and M. Marsili, Eroding Market Stability by Proliferation of Financial Instruments, European Physical Journal B, 71: 467-479 (2009). [32] K. Anand, P. Gai, M. Marsili, The rise and fall of trust networks, Progress in Artificial Economics. Lect. Notes Econ. Math. Syst. 645: 77 (2010) [33] T. Assenza, D. Delli Gatti, E Pluribus Unum: Macroeconomic Modelling for Multi-agent Economies, UCSC Working paper (2013). [34] F. Patzelt and K. Pawelzik, Criticality of Adaptive Control Dynamics, Phys. Rev. Lett. 107: 238103 (2011) [35] H. Minsky, Stabilizing an Unstable Economy, McGraw-Hill, New York (2008) [36] D. Sornette, Endogenous versus exogenous origins of crises. In: Albeverio, S., Jentsch, V., Kantz, H. (eds.) Extreme Events in Nature and Society. Springer, Heidelberg (2005) [37] K. Anand, A. Kirman, M. Marsili, Epidemics of rules, rational negligence and market crashes Eur. J. Financ. (2011) [38] J. Lorenz, S. Battiston, F. Schweitzer, Systemic risk in a unifying framework for cascading processes on networks Eur. Phys. J. B 71, 441 (2009) [39] J.-P. Bouchaud The endogenous dynamics of markets: price impact, feedback loops and instabilities In: Berd, A. (ed.) Lessons from the 2008 Crisis. Risk Books, Incisive Media, London (2011) [40] see e.g. J. Geanakoplos, R. Axtell, D. J. Farmer, P. Howitt, B. Conlee, J. Goldstein, M. Hendrey, N. M. Palmer, C.-Y. Yang, Getting at Systemic Risk via an Agent-Based Model of the Housing Market, Cowles Foundation Discussion Papers 1852, Cowles Foundation for Research in Economics, Yale University, 2012. [41] S. Gualdi, M. Tarzia, F. Zamponi, J.-P. Bouchaud, On simple aggregate descriptions of ABMs (and the real economy), in preparation [42] see e.g. C. Hommes, Behavioral Rationality and Heterogeneous Expectations in Complex Economic Systems, Cambridge University Press (2013) for a review on behavioral experiments.