Skip to main content

A Simple Model of Business Fluctuations with Heterogeneous Interacting Agents and Credit Networks

  • Chapter
  • First Online:
Economics with Heterogeneous Interacting Agents

Part of the book series: New Economic Windows ((NEW))

  • 992 Accesses

Abstract

In what follows we firstly describe and then implement and simulate a very simple model, that is a simplified version of Riccetti et al. (2013), by using R. In the original paper, a multitude of heterogeneous firms and banks interact in the credit market. Firms want to produce and sell a homogeneous commodity in the goods market and, in order to finance production, they need credit from banks. Firms look at a random subset of potential partners (due to imperfect information) and then choose the most convenient bank (i.e. the bank charging the lowest interest rate); as a consequence, an endogenous network of credit interlinkages evolves over time. The model shows the emergence of business fluctuations and highlights both the role of financial fragility and network structure in shaping economic dynamics.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 99.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 129.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 129.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Readers who already have good programming skills may quickly read this section and then go to the next one in which many steps of the implementation procedures are similar though proposed in a more complicated environment.

  2. 2.

    Consider that even though we will talk about business fluctuations and the like, we are developing a partial dis(equilibrium) model, which is not a stock-flow consistent macroeconomic model. Initial conditions are not stock-flow consistent as well.

  3. 3.

    For the moment, we assume that there is no depreciation of capital. In Sect. 2.1.4.1 we introduce a depreciation rate.

  4. 4.

    In this case, the banking sector would suffer from a non-performing loan; however, we are not modeling such a process related to the banking system’s balance sheet in this simplified model.

  5. 5.

    For now, we are not considering aggregate variables.

  6. 6.

    It is worth noticing that the first step, that is the investment choice, is based on a lagged value of another variable, that is past profit, which is available at the beginning of the time period t from the computations of the previous period \(t-\)1.

  7. 7.

    This does not mean that, in general, it is not possible to simulate simultaneous events in an agent-based model.

  8. 8.

    To simplify some tasks it could be useful to install R-Studio (on the top of R) so to use this platform as the programming environment. However, this is not a necessary step: one can just install and employ R to write the code in a text file and then run it with the Source button.

  9. 9.

    A possible implementation of such a cycle could be: for (n in 1:Ni) { I(n,t) = gamma * Z(n,t-1) }.

  10. 10.

    It is worth to note that the last variable to be updated, according to entry–exit conditions, has to be A, because this matrix is used to check other matrices for negative values of firms’ net worth (that is, when some of the values of the matrix A can be negative yet).

  11. 11.

    Other aggregate variables can be computed in a similar way.

  12. 12.

    This is an arbitrary choice we make for providing an example. Obviously, you can set the seed you prefer, though only 15 allow you to reproduce exactly the simulation presented in this section. More on random numbers can be found below, when this topic will be analyzed within an extended modeling framework.

  13. 13.

    However, changing the seed should not lead to significant differences in the qualitative behavior of the model; indeed, if qualitative results greatly differ from one simulation to another this would mean that model dynamics are too much sensitive to stochastic variables and thus that the model does not represent a good tool for analyzing any phenomenon. As we will see later, instead, qualitative results may change when varying parameter values or introducing some modifications of the model.

  14. 14.

    You may check the correspondence between the code you developed following the instructions and the code in the file toymodel.R we provide in the appendix to the book. If all steps were followed accurately, including the exercises, the two codes should match. Now, you can save your own file and then use the same code to create a new file in which implement the modifications suggested in this section. Alternatively, you may open the file toymodel.R and start from it to practice this section.

  15. 15.

    After the modifications introduced in this subsection the R code should correspond to that in the file toymodelmod.R.

  16. 16.

    For the sake of simplicity, we are keeping the (not so realistic) assumption that firms pay a remuneration on their own capital which corresponds to the interest rate on external debt.

  17. 17.

    The reference file after these modifications is toymodelmod2.R.

  18. 18.

    The reference file for this section is toymodelMC.R.

  19. 19.

    The implementation of the large computational experiment with robust statistics is provided in the file toymodelMC100mad.R. We suggest to look at this file only after the Exercise 4 presented in the Appendix of the chapter has been done.

  20. 20.

    You can follow a similar approach in order to assess the sensitivity of the model to other parameters.

  21. 21.

    The file corresponding to this section is toymodelSens.R.

  22. 22.

    The reference file for the first part of this section is toymodelPolicy.R.

  23. 23.

    The complete implementation of the policy experiment described in the second part of this section is provided in the file toymodelMC100madPolicy.R. We suggest to look at this file only after the Exercise 6 in the appendix has been done.

  24. 24.

    For instance, a firm with net worth A equal to 10 and debt B equal to 20, has an initial capital K equal to 30. If the profits are \(-15\), the firm defaults because its net worth goes below zero (it is \(-5\)). However, it has a capital equal to \(30-15\) = 15; this amount can be recovered by the lender that loses only \(20-15\) = 5. The LGD is equal to \(\frac{-(10-15)}{20} = \frac{5}{20} = 25\,\%\).

  25. 25.

    These are the most common objects employed for collecting data in the vast majority of programming languages.

  26. 26.

    A pseudo random numbers generator (PRNG) is a deterministic algorithm which produces a sequence of numbers which has almost the same statistical features of a sequence generated by a random process. The PRNG-generated sequence of numbers is not truly random, because it is completely determined by a relatively small set of initial values (possibly just one) called “seeds”. PRNGs are employed in a wide range of applications involving programming and are crucial in simulations applications, in particular when running Monte Carlo experiments.

  27. 27.

    We might as well declare these variables without specifying the initial values, using the following syntax: variable = matrix (, ncol=numberOfAgents, nrow=1). In this case R would create a matrix of NA values. The two implementations are absolutely equivalent.

  28. 28.

    Hence, we might had specified them as vectors as well, using the syntax variable = vector(mode = “any", length = numberOfAgents). Each agent within a specific group (households, firm, and banks) is identified by an index which gives its position within each one of these vectors. So, for example, the \(i^{th}\) element of the Rb vector declared in the code below always represents the bank-specific component of the \(i^{th}\) bank. Notice that this vector representation is somehow related to the fact that in the current specification of the model we do not have any heuristics employing information referring to periods other than current and past ones. However, in a later stage of development we might decide to change some heuristics in a way that they come to depend on the values of some variables over a time span of n past periods. For example, we might change the simple adaptive expectations formation scheme in favor of a rule which defines expectations as a weighted average of the values assumed by the correspondent variable over the last n periods. To allow this rule to work, we should declare the variables on which we want to compute expectations in a format which allows to store the necessary information (i.e. the values of the variable in the last n periods for each agent). In our example this would require to declare the variable as a matrix of dimension \(n \times number Of Agents\). Therefore, in order to keep the declaration of the variables compatible with this and other possible revisions, we preferred to use a matrix object rather than a vector.

    One might in principle decide to keep track of every agent’s attributes along the whole simulation, thereby declaring by default the correspondent variables as a matrix of dimension \(Time\times number Of Agents\), regardless the type of heuristics employed. However, let us recall again the programming tenet according to which one should be as parsimonious as possible to avoid useless wastefulnesses of computer memory and slowdowns in execution times.

  29. 29.

    In the first period of the simulation this is the index of the bank which was randomly assigned to i in the initialization of the simulation.

  30. 30.

    This counter will be employed to calculate the aggregate switching rate.

  31. 31.

    Notice that the operator * in R, when applied to two equally long vectors, multiplies each element of the former for the correspondent element of the latter, so that the output is still a vector of the same length. Here instead the operator %*% is employed to calculate the internal product between the two vectors whose outcome is a number.

  32. 32.

    Please notice that we might move the block referring to the replacement procedure to the bottom of the code developed at this stage without altering in any way the execution flow of the program. However, to be consistent with the timeline presented in Sect. 2.2.2.2, we prefer to embed this part on the top of the simulation for loop.

  33. 33.

    This part of the code should be easily understood by the reader as it does not present any peculiarity, apart from the if statement in the growth rate report update by which we assign value 0 to the report in the first period. This is motivated by merely technical reasons: in the first period (t==1) of the simulation we would have YF[t-1,mc]=YF[0,mc] which would raise an error message because in R indexation of vectors and matrices starts from 1.

  34. 34.

    The command dev.off(), if uncommented, would allow to save the graphs without showing them on the console of R.

  35. 35.

    A very similar function in R is acf, which computes the autocorrelation function for a given variable. The arguments of the acf function are very similar to ccf.

  36. 36.

    Admittedly, it is common practice to neglect the initial periods of the simulation, which usually represent the transient phase, that is a sort of training of the model, and to focus the attention just on the time span in which the model shows an inherent coherent dynamics. In our examples below we analyze the time span [200:Time].

  37. 37.

    In the last versions of R, we need to force the matrix gr to a vector in order to employ the function sd() to calculate the standard deviations over all the elements of the matrix.

  38. 38.

    Similarly, we might compute the kurtosis and skewness of this distribution by employing the kurtosis() and skewness() functions which require the installation and import of the package “moments” of R.

  39. 39.

    These data files will be subsequently employed in the sensitivity and policy analysis sections, providing a benchmark to assess the impact of different parameterizations or policy changes on the model dynamics. These files can be loaded in our R workspace through the command YF.trend1=read.csv(paste(folder,"/fileName.csv",sep="")).

  40. 40.

    The first line may be alternatively expressed as YF.avTrend=apply(YF.trend, 1, mean).

  41. 41.

    To tell the truth, it is common practice to terminate a script with a code line similar to this: print(paste("Elapsed time is ",proc.time()[3],"seconds")). The function proc.time() is called to evaluate how much CPU or real time (as in our example) the currently running process has taken. In this way we can precisely figure out how much time our simulations take to be executed, thus having also a benchmark to assess the efficacy of possible variations of the script intended to speed up the simulations.

  42. 42.

    It should be noticed that by first assigning a vector of string elements to the first column of the sensMat matrix, as we have done here, all the elements that will be embedded in the matrix later on, such as the values of the statistics computed for each variable, will be treated by default as strings as well, thus eventually implying the need to coerce them in a different type (e.g. numeric), when needed.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Alessandro Caiani .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this chapter

Cite this chapter

Bargigli, L., Caiani, A., Riccetti, L., Russo, A. (2016). A Simple Model of Business Fluctuations with Heterogeneous Interacting Agents and Credit Networks. In: Caiani, A., Russo, A., Palestrini, A., Gallegati, M. (eds) Economics with Heterogeneous Interacting Agents. New Economic Windows. Springer, Cham. https://doi.org/10.1007/978-3-319-44058-3_2

Download citation

Publish with us

Policies and ethics