BAM: The Bottomup Adaptive Macroeconomics Model 1.1.0
Overview
Purpose
Modeling an economy with stable macro signals, that works as a benchmark for studying the effects of the agent activities, e.g. extortion, at the service of the elaboration of public policies..
Entities, state variables, and scales

Agents: Firms (also know as producers), workers (also know as consumers and households) and banks.

Environment: Virtual or geographically characterized markets.

Labor market.

Goods market

Credit market.


State variables: Productivity, net worth, wage and loans.
Process overview and scheduling

Firms calculate production based on expected demand.

A decentralized labor market opens.

A decentralized credit market opens.

Firms produce.

Market for goods open.

Firms will pay loan and dividends.

Firms and banks will survive or die.

Replacing of bankrupt firms/banks.
Design concepts
Basic Principles
Neo classical economy.
Emergence
Model as a whole has the objective of generating adaptive behavior of the agents, without the imposition of an equation that governs the actions of the agents.
Adaptation
Firms can adapt in each period $t$ price or amount to supply (only one of the two strategies). Adaptation of each strategy depends on the condition of the firm (level of excessive supply / demand in the previous period) and/or the market environment (the difference between the individual price and the market price in the previous period).
Objectives
Just firms has the objetive of maximizing their net worth.
Learning
Firms do not have learning, they present different responses to an environment that is constantly evolving.
Prediction
Firms use both their own elements and the environment to make the prediction of the quantity to be produced or the price. As an internal element, it uses the excessive amount of supply / demand in the previous period; while the environment takes the differential of its price and the market.
Sensing

Firms are able to perceive their produced quantity, their price and the market price, offered wages, profits, net value, their labor force and interest rate of randomly chosen banks.

Workers/consumers perceive the size of firms visited in the previous period, prices published by the firms in actual period and wages offered by the firms.

Banks are able to sense net value of potential borrower (firms) in order to calculate interest rate.
Interaction
Macroeconomic results come from continuous adaptive dispersed interactions of autonomous, heterogeneous and rationally bounded agents that coincide in an uncertain environment.
Stochasticity
Elements that have random shocks are:

Determination of wages (when vacancies are offered),
wagesshockxi
. 
Determination of contractual interest rate offered by banks to
firms,interestshockphi
. 
Strategy to set prices,
priceshocketa
. 
Strategy to determine the quantity to produce,
productionshockrho
.
Collectives
In addition to the sets of agents (consumers, producers and banks), groups of firms and consumers are selected as an emergent property of the simulation (rich and poor).
Observation
Along simulation are observed:

Logarithm of real GDP.

Unemployment rate.

Annual inflation rate.
At end of simulation are computed:
 Distribution of the size of firms.
Details
Initialization
Parameter  Parameter  Value 

I  Consumers  500 
J  Producers  100 
K  Banks  10 
T  Periods  1000 
C<sub>P</sub>  Propensity to consume of poorest people  1 
C<sub>R</sub>  Propensity to consume of richest people  0.5 
h<sub>&xi</sub>  Maximum growth rate of wages  0.05 
H<sub>&eta</sub>  Maximum growth rate of prices  0.1 
H<sub>&rho</sub>  Maximum growth rate of quantities  0.1 
H<sub>&phi</sub>  Maximum amount of banks’ costs  0.1 
Z  Number of trials in the goods market  2 
M  Number of trials in the labor market  4 
H  Number of trials in the credit market  2 
ŵ  Minimum wage (set by a mandatory law)  1 
P<sub>t<sub></sub></sub>  Base price  1 
&delta  Fixed fraction to share dividends  0.15 
r̄  Interest rate (set by the central monetary authority)  0.07 
Input data
No input data were needed to represent process.
Submodels

Production with constant returns to scale and technological multiplier.
.

Desired production level is equal to the expected
demand . 
Desired labor force (employees) is
.

Current number of employees is the sum of employees with and without a valid contract.

Number of vacancies offered by firms is
.

is the minimum wage determined by law.

If there are no vacancies , wage offered is:
,
 If number of vacancies is greater than 0, wage offered is:
,

is a random term evenly distributed between
. 
At the beginning of each period, a firm has a net value .
If total payroll to be paid is greater than ,
firm asks for a loan: 
For the loan search costs, it must be met that

In each period the thmost bank can distribute a total amount
of credit equivalent to a multiple of its patrimonial base:,

where can be interpreted as the capital requirement
coefficient. Therefore, the reciprocal represents the maximum
allowed leverage by the bank. 
Bank offers credit , with its respective interest rate
and contract for 1 period. 
Payment scheme if :

If , bank retrieves
.

Contractual interest rate offered by the bank to the firm
is determined as a margin on a rate policy established by
Central Monetary Authority :.

Margin is a function of the specificity of the bank as possible
variations in its operating costs and captured by the uniform random
variable in the interval . 
Margin is also a function of the borrower’s financial fragility,
captured by the term , . Whereis the leverage of borrower.

Demand for credit is divisible, that is, if a single bank is not
able to satisfy the requested credit, it can request in the
remaining randomly selected banks. 
Each firm has an inventory of unsold goods , where excess
supply or demand is reflected. 
Deviation of the individual price from the average market price
during the previous period is represented as: 
If deviation is positive , firm recognizes
that its price is high compared to its competitors, and is induced
to decrease the price or quantity to prevent a migration massive in
favor of its rivals. 
Vice versa.

In case of adjusting price to downside, this is bounded below
to not be less than your average costs
. 
Aggregate price is common knowledge (global variable), while
inventory and individual price private
knowledge child (local variables). 
Only the price or quantity to be produced can be modified. In the
case of price, we have the following rule:
$$\begin{aligned} P_{it}^s= \begin{cases} \text{max}[P_{it}^l, P_{it1}(1+\eta_{it})] & \text{if $S_{it1}=0$ and $P_{it1}<P$ }\\ \text{max}[P_{it}^l, P_{it1}(1\eta_{it})] & \text{if $S_{it1}>0$ and $P_{it1}\geq P$} \end{cases}\end{aligned}$$ 
is a randomized term uniformly distributed in the
range and is the minimum price at which firm
can solve its minimal costs at time
(previously defined). 
In the case of quantities, these are adjusted adaptively according
to the following rule:$$\begin{aligned}
D_{it}^e=
\begin{cases}
Y_{it1}(1+\rho_{it}) & \text{if $S_{it1}=0$ and $P_{it1}\geq P$} \
Y_{it1}(1\rho_{it}) & \text{if $S_{it1}>0$ and $P_{it1}< P$}
\end{cases}\end{aligned}$$ 
is a random term uniform distributed and bounded
between . 
Total income of households (workers/consumers) is the sum of the
payroll paid to the workers (each household represents a worker) in
and the dividends distributed to the shareholders in . 
Wealth is defined as the sum of labor income plus the sum of all
savings of the past. 
Marginal propensity to consume is a decreasing function of the
worker’s total wealth (higher the wealth lower the proportion spent
on consumption) defined as: 
is the average savings. is the real saving of
the th consumer. 
The revenue of a firm after the goods market closes is
equal to: 
At the end of period, each firm computes benefits
. 
If the benefits are positive, the shareholders of firms receive
dividends:.

Residual, after discounting dividends, is added to net value
inherited from previous period, . Therefore, net worth of
a profitable firm in is:.

If firm, say , accumulates a net value
goes bankrupt. 
Firm that goes bankrupt is replaced with another one of smaller size
than the average of incumbent firms. 
Nonincumbent firms are those whose size is above and below 5%, is
used to calculate a more robust estimator of the average. 
Bank’s capital
.

is the bank’s loan portfolio, represents
the portfolio of firms that go bankrupt. 
If a bank goes bankrupt, it is replaced with a copy of the
surviving banks.
Reference
Delli Gatti, D. et. al, (2011). Macroeconomics from the Bottomup. SpringerVerlag Mailand, Milan.
Release Notes
 Set configuration of parameters.
 Click Setup with your prefered parameters.
 Click Go
 Simulation will stop at 1000 ticks.
 Initial configuration of parameters gives an average economy, according to data from World Bank.