Macroeconomics
Macroeconomics: growth, business cycles, investment, international trade, and mortal monetary economies.
BusinessElement(label, visual=None, *, money=0.0, loans=0.0, stock=0.0, wage=4.0, price=1.0, owner=-1.0, workers=1.0, vacancies=1.0, revenue=0.0, interest=0.003, repayment=0.004, adjustment=0.05, stock_limit=30.0)
Bases: Element
Firm on a patch that harvests with its workers, pays wages with money it borrows, and sells food in its shop.
Every step the workers pool their labour on the firm's patch, the firm pays each the wage, borrowing what it
lacks from the bank, and pays the interest and a share of the principal of its loans. A firm that sold out
raises its price, and one with a stock above stock_limit lowers it and lays a worker off. Otherwise a firm
posts vacancies up to the workforce that harvests the whole capacity of its patch, raises the wage while a
vacancy went unfilled, and lowers it while its sales fall short of its wage bill. Profits above twice the wage
bill go to the owner, and a firm without a living owner passes to one of its workers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the firm or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
money
|
Annotated[float, StateSpec(quantity=money)]
|
The money the firm holds. |
0.0
|
loans
|
Annotated[float, StateSpec(quantity=credit)]
|
The loans of the firm, negative for its debt. |
0.0
|
stock
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The food in the shop. |
0.0
|
wage
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The wage of a worker. |
4.0
|
price
|
Annotated[float, StateSpec(domain=open(0, oo))]
|
The price of a unit of food. |
1.0
|
owner
|
Annotated[float, StateSpec(reference=people)]
|
The id of the owner. |
-1.0
|
workers
|
Annotated[float, StateSpec(domain=NN)]
|
The number of workers in the step. |
1.0
|
vacancies
|
Annotated[float, StateSpec(domain=NN)]
|
The open vacancies. |
1.0
|
revenue
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The sales of the step. |
0.0
|
interest
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The interest rate of loans per step. |
0.003
|
repayment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the principal repaid per step. |
0.004
|
adjustment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The relative step of a change of price or wage. |
0.05
|
stock_limit
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The stock above which the firm lowers its price and lays off. |
30.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import BusinessElement
>>> GroupElement('businesses', element=BusinessElement, size=2, variable=True).size
2
Source code in src/skcomplex/models/economics/macroeconomics/_business.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
produce(agent, model)
Harvest with the workers, pay wages and the bank, adjust, and pay a dividend to the owner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
BusinessView
|
The firm. |
required |
model
|
ModelView
|
The model. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_business.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
CapitalStockElement(label, visual=None, *, K=100.0, investment_fraction=0.2, output_per_capital=1 / 3, lifetime=15.0)
Bases: Element
Capital stock that reinvests a fraction of its output and depreciates over its lifetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the stock. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
K
|
Annotated[object, StateSpec(domain=closed_open(0, oo))]
|
The capital stock. |
100.0
|
investment_fraction
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The fraction of the output that is reinvested. |
0.2
|
output_per_capital
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The output per unit of capital and unit time. |
1 / 3
|
lifetime
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The average lifetime of the capital. |
15.0
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import CapitalStockElement
>>> CapitalStockElement('economy', lifetime=20.0).lifetime
20.0
Source code in src/skcomplex/models/economics/macroeconomics/_capital.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
CentralBankElement(label, visual=None, *, money=0.0, loans=0.0)
Bases: Element
Bank that creates money as loans and pays its interest income to a random person as a dividend.
The transfer dividends of the model pays the income to a random person, or to a random firm when nobody lives.
The money it issued, a negative holding, and the loans it holds sum to zero after every step, so every unit of money in the economy is matched by a loan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the bank or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
money
|
Annotated[float, StateSpec(quantity=money)]
|
The money of the bank, the negative of the money it issued plus its income of the step. |
0.0
|
loans
|
Annotated[float, StateSpec(quantity=credit)]
|
The loans the bank holds. |
0.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import CentralBankElement
>>> GroupElement('bank', element=CentralBankElement, size=1).size
1
Source code in src/skcomplex/models/economics/macroeconomics/_central_bank.py
45 46 47 48 49 50 51 52 53 54 55 | |
get_income(agent, holder, model)
staticmethod
Return the income of the step that the bank pays as a dividend, its money plus its loans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
CentralBankView
|
The bank. |
required |
holder
|
AgentView
|
The person, or the firm when nobody lives, that receives the dividend. |
required |
model
|
ModelView
|
The model view of the dividends. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
income |
float
|
The income. |
Source code in src/skcomplex/models/economics/macroeconomics/_central_bank.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
CircuitInteraction(label, *, households, firms, bank)
Bases: TransferInteraction
Circuit of money between households, firms, and a bank, one period per step.
The flows of a period are the legs of one transfer between the deposits of the sectors, consumption, wages,
interest, dividends, and profits, lending from the environment, and repayments to it, each reading the parameters
of the sectors. Every leg is named by its flow, so the reporters <label>.<flow> record it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the circuit. |
required |
households
|
Annotated[str, RoleSpec()]
|
The path of the households. |
required |
firms
|
Annotated[str, RoleSpec()]
|
The path of the firms. |
required |
bank
|
Annotated[str, RoleSpec()]
|
The path of the bank. |
required |
Examples:
>>> from skcomplex.models.economics.macroeconomics import CircuitInteraction
>>> CircuitInteraction('circuit', households='households', firms='firms', bank='bank').bank
'bank'
Source code in src/skcomplex/models/economics/macroeconomics/_circuit.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
CommonsInteraction(label, *, people)
Bases: Interaction
Harvest of the hunter-gatherers, who pool the labour of the adults on a patch and share the food equally.
The adults of a patch harvest min(food, labour - resistance), and everyone on the patch, child or adult, gets an
equal share.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
people
|
Annotated[str, RoleSpec()]
|
The path of the group of people. |
required |
Examples:
>>> from skcomplex.models.economics.macroeconomics import CommonsInteraction
>>> CommonsInteraction('commons', people='people').people
'people'
Source code in src/skcomplex/models/economics/macroeconomics/_commons.py
38 39 40 41 42 43 44 45 | |
harvest(model)
Harvest every occupied patch and share the food among the people on it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
ModelView
|
The model view of the interaction. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_commons.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
CreditMarketInteraction(label, *, requesters, providers, rule=RandomSearchSpec(), limit='limit', quantity='quantity', allowance='allowance', transfers=(), phase=None, on_match=None)
Bases: MatchingInteraction[ModelView]
Credit market that also reports the spread of the rates firms pay over the cheapest bank's rate.
The firms request loans and the banks provide them. The spread is the mean of r_i / r_min - 1 over the borrowing
firms, the dispersion of rates that a market with costly search leaves and that switching to cheaper lenders
erodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the market. |
required |
requesters
|
Annotated[str, RoleSpec()]
|
The path of the group of firms. |
required |
providers
|
Annotated[str, RoleSpec()]
|
The path of the group of banks. |
required |
rule
|
MatchingRule | Pairing
|
The spec of the algorithm that matches firms with banks, such as |
RandomSearchSpec()
|
limit
|
str | tuple[str, str]
|
The state with the rate of both sides, or a pair of the firms' and the banks' states. |
'limit'
|
quantity
|
str | tuple[str, str]
|
The state with the loan of both sides, or a pair of the firms' and the banks' states. |
'quantity'
|
allowance
|
str
|
The state of a firm with what it can spend. |
'allowance'
|
transfers
|
Sequence[tuple[str, int]]
|
The states every loan moves, each with the sign |
()
|
phase
|
str | None
|
The phase the market clears in, or |
None
|
on_match
|
Callable[[MatchSpec, ModelT], None] | None
|
A function of every loan and the model view, run after the transfers, or |
None
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import CreditMarketInteraction
>>> CreditMarketInteraction('credit', requesters='firms', providers='banks').reports[-1]
'spread'
Source code in src/skcomplex/core/interactions/_matching.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
DepositorElement(label, visual=None, *, bank=-1, deposit=10.0, loan=0.0, spending=0.1, repayment=0.05)
Bases: Element
Customer of a bank, with a deposit at the bank its reference state bank names and a loan from it.
The model pays a share of the deposit to a random customer, which moves deposits and as many reserves from the payer's bank to the payee's bank, and repays a share of the loan from the deposit, which cancels as much deposit and loan at the customer's bank and destroys broad money.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
bank
|
Annotated[float, StateSpec(domain=ZZ, reference=banks)]
|
The id of the customer's bank in the group |
-1
|
deposit
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The deposit at the bank. |
10.0
|
loan
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loan owed to the bank. |
0.0
|
spending
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the deposit paid to a random customer every step. |
0.1
|
repayment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the loan repaid every step. |
0.05
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import DepositorElement
>>> GroupElement('customers', element=DepositorElement, size=10, values={'deposit': 5.0}).size
10
Source code in src/skcomplex/models/economics/macroeconomics/_depositor.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
get_payment(payer, payee, model)
staticmethod
Return the payment of a customer to another, a share spending of its deposit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payer
|
DepositorView
|
The customer who pays. |
required |
payee
|
DepositorView
|
The customer who is paid. |
required |
model
|
ModelView
|
The model view of the payments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
amount |
float
|
The payment. |
Source code in src/skcomplex/models/economics/macroeconomics/_depositor.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_repayment(customer, same, model)
staticmethod
Return the repayment of a customer, a share repayment of its loan, at most its deposit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
customer
|
DepositorView
|
The customer who repays. |
required |
same
|
DepositorView
|
The customer again, the target of a transfer within members. |
required |
model
|
ModelView
|
The model view of the repayments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
amount |
float
|
The repayment. |
Source code in src/skcomplex/models/economics/macroeconomics/_depositor.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
EconomyElement(label, visual=None, *, k=1.0)
Bases: Element
Economy described by its capital per worker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the economy. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
k
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial capital per worker. |
1.0
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import EconomyElement
>>> EconomyElement('country', k=1.0).k
1.0
Source code in src/skcomplex/models/economics/macroeconomics/_economy.py
34 35 36 37 38 39 40 41 42 | |
EstateInteraction(label, *, people)
Bases: Interaction
Settlement of the estates of the dead, who leave their money and loans to an heir, with a census of the step.
The money and the loans of a dead person go to a random living person of its patch, or of anywhere. When nobody
lives to inherit them, the dead person stays as an estate that holds them. The reporters births, starvations,
and old_age count the events of a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
people
|
Annotated[str, RoleSpec()]
|
The path of the group of people. |
required |
Examples:
>>> from skcomplex.models.economics.macroeconomics import EstateInteraction
>>> EstateInteraction('census', people='people').reports
('births', 'starvations', 'old_age')
Source code in src/skcomplex/models/economics/macroeconomics/_estate.py
42 43 44 45 46 47 48 49 | |
count(model)
Count the births and deaths of the step and remove the dead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
ModelView
|
The model view of the interaction. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_estate.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
FirmElement(label, visual=None, *, net_worth=10.0, demand=0.0, bid=1.0, loan=0.0, rate=0.0, partner=-1, gross_return=0.0, injected=0.0, defaulted=0, leverage=1.0, mean_return=0.03, volatility=0.3, entry=10.0)
Bases: Element
Firm that borrows in proportion to its net worth, invests at a random return, and defaults on negative worth.
Every step the firm asks for leverage times its net worth from its bank, invests its net worth and the loan at
the return mean_return + volatility * z, and pays the interest. When its net worth becomes negative it repays
what it can, the bank writes off the rest, and a new firm with the net worth entry replaces it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
net_worth
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial net worth. |
10.0
|
demand
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loan still wanted in the current step. |
0.0
|
bid
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The highest interest rate the firm pays. |
1.0
|
loan
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loan of the current step. |
0.0
|
rate
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The interest rate of the loan, zero without a loan. |
0.0
|
partner
|
Annotated[float, StateSpec(domain=ZZ, reference=banks)]
|
The id of the bank of the firm, |
-1
|
gross_return
|
Annotated[float, StateSpec()]
|
The return on the capital of the last step. |
0.0
|
injected
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The net worth of an entrant that replaced the firm in the last step, zero otherwise. |
0.0
|
defaulted
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
Whether the firm defaulted in the last step. |
0
|
leverage
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The ratio of the loan wanted to the net worth. |
1.0
|
mean_return
|
Annotated[float, ParameterSpec()]
|
The mean return on capital. |
0.03
|
volatility
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The standard deviation of the return on capital. |
0.3
|
entry
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The net worth of an entrant. |
10.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import FirmElement
>>> GroupElement('firms', element=FirmElement, size=10, values={'net_worth': 5.0}).size
10
Source code in src/skcomplex/models/economics/macroeconomics/_firm.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
get_default()
staticmethod
Return the states a firm sets after its return, those of an entrant for a firm that defaults.
Returns:
| Name | Type | Description |
|---|---|---|
default |
tuple[tuple[str, Callable[[FirmView, ModelView], float]], ...]
|
The name of every state and the function of its value, of the firm and the model view. |
Source code in src/skcomplex/models/economics/macroeconomics/_firm.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
get_plan()
staticmethod
Return the states a firm sets in the plan of a step, a loan request of leverage times its net worth.
Returns:
| Name | Type | Description |
|---|---|---|
plan |
tuple[tuple[str, Callable[[FirmView, ModelView], float]], ...]
|
The name of every state and the function of its value, of the firm and the model view. |
Source code in src/skcomplex/models/economics/macroeconomics/_firm.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
get_return(agent, model)
staticmethod
Return the return on the net worth and the loan invested, at a normal rate of return of at least -1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
FirmView
|
The firm. |
required |
model
|
ModelView
|
The model view of the investment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
gross_return |
float
|
The return of the step. |
Source code in src/skcomplex/models/economics/macroeconomics/_firm.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
get_worth(agent)
staticmethod
Return the net worth after the return and the interest, negative for a firm that defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
FirmView
|
The firm. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
worth |
float
|
The net worth before a default. |
Source code in src/skcomplex/models/economics/macroeconomics/_firm.py
140 141 142 143 144 145 146 147 148 149 150 151 152 | |
FirmsElement(label, visual=None, *, deposits=20.0, loans=50.0, sales=40.0, wage_share=0.7, distribution=0.3, repayment=0.08)
Bases: Element
Firms sector, with its deposits, its loans, and the sales of the last period, which pays wages and profits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the sector. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
deposits
|
Annotated[object, StateSpec(domain=closed_open(0, oo), quantity=money)]
|
The deposits of the firms, which are money. |
20.0
|
loans
|
Annotated[object, StateSpec(domain=closed_open(0, oo))]
|
The loans of the firms. |
50.0
|
sales
|
Annotated[object, StateSpec(domain=closed_open(0, oo))]
|
The sales of the last period. |
40.0
|
wage_share
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of sales paid as wages. |
0.7
|
distribution
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the firms' deposits distributed as profits per period. |
0.3
|
repayment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of loans repaid per period. |
0.08
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import FirmsElement
>>> FirmsElement('firms').loans
50.0
Source code in src/skcomplex/models/economics/macroeconomics/_firms_element.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
FoodMarketInteraction(label, *, requesters, providers, rule=RandomSearchSpec(), limit='limit', quantity='quantity', allowance='allowance', transfers=(), phase=None, on_match=None)
Bases: MatchingInteraction[ModelView]
Food market in which people short of food, in random order, buy from the cheapest stocked shop within sight.
A matching of the people, who request their shortfall of food for reserve steps within the budget of
their money, with the firms, which provide their stock at their price. Every purchase moves the money to the firm,
which books it as revenue, and the food to the buyer. Build it with
PartnerSpec(sight, 'score', score=FoodMarketInteraction.score, clearing='provider'), whose score prefers the
lowest price. Besides the reporters of a matching, the reporter gdp sums the value of
the sales of a step.
Examples:
>>> from skcomplex.specs import PartnerSpec
>>> from skcomplex.models.economics.macroeconomics import FoodMarketInteraction
>>> rule = PartnerSpec(5.0, 'score', score=FoodMarketInteraction.score, clearing='provider')
>>> FoodMarketInteraction('shops', requesters='people', providers='businesses', rule=rule).reports[-1]
'gdp'
Source code in src/skcomplex/core/interactions/_matching.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
score(person, firm)
staticmethod
Return the score of a firm for a person, higher for a lower price.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
person
|
object
|
The person that buys. |
required |
firm
|
object
|
The firm that sells. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
score |
float
|
Minus the price of the firm. |
Source code in src/skcomplex/models/economics/macroeconomics/_food_market.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
sell(match, model)
staticmethod
Book the value of a sale as revenue of the firm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
MatchSpec
|
The match of a buyer with a firm. |
required |
model
|
ModelView
|
The model view of the market. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_food_market.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
HouseholdsElement(label, visual=None, *, deposits=60.0, alpha_income=0.6, alpha_wealth=0.4)
Bases: Element
Households sector, whose deposits are money, and which consumes out of its wages and its deposits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the sector. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
deposits
|
Annotated[object, StateSpec(domain=closed_open(0, oo), quantity=money)]
|
The deposits of the households. |
60.0
|
alpha_income
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The propensity to consume out of wages. |
0.6
|
alpha_wealth
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The propensity to consume out of deposits. |
0.4
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import HouseholdsElement
>>> HouseholdsElement('households').deposits
60.0
Source code in src/skcomplex/models/economics/macroeconomics/_households.py
40 41 42 43 44 45 46 47 48 49 50 51 52 | |
IncomeElement(label, visual=None, *, Y=110.0, Y_lag1=100.0, c=0.8, v=1.5, G=20.0)
Bases: Element
Economy described by its national income, which keeps the income of the previous period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the economy. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
Y
|
Annotated[object, StateSpec(lags=1, initial=(100.0,))]
|
The income of the current period. |
110.0
|
Y_lag1
|
float
|
The income of the previous period. |
100.0
|
c
|
Annotated[object, ParameterSpec()]
|
The marginal propensity to consume. |
0.8
|
v
|
Annotated[object, ParameterSpec()]
|
The accelerator, the investment response to the change in consumption. |
1.5
|
G
|
Annotated[object, ParameterSpec()]
|
The government spending. |
20.0
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import IncomeElement
>>> IncomeElement('economy', c=0.5).c
0.5
Source code in src/skcomplex/models/economics/macroeconomics/_income.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
InvestingFirmElement(label, visual=None, *, A=1.0, K=1.0, Z=0.0, B=0.0, Y=0.0, P=0.0, gamma=1.1, phi=0.1, r=0.1, pbar=0.01)
Bases: Element
Firm of the toy business-cycle model, which invests a share of its last profit and sells at a random price.
Every period the firm invests I = gamma * Z, accumulates capital K = K + I, produces Y = phi * K, borrows
B = max(K - A, 0), sells at the price P = pbar + 2 U(0, 1), earns Z = P * Y - r * K, and adds the profit to
its net worth A. A firm whose net worth turns negative is replaced by an entrant with A = K = 1 and Z = 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
A
|
Annotated[float, StateSpec()]
|
The initial net worth. |
1.0
|
K
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial capital. |
1.0
|
Z
|
Annotated[float, StateSpec()]
|
The initial profit. |
0.0
|
B
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial debt. |
0.0
|
Y
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial production. |
0.0
|
P
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial price. |
0.0
|
gamma
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The investment accelerator. |
1.1
|
phi
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The productivity of capital. |
0.1
|
r
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The interest rate. |
0.1
|
pbar
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The constant part of the price. |
0.01
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import InvestingFirmElement
>>> GroupElement('firms', element=InvestingFirmElement, size=10, values={'gamma': 1.2}).size
10
Source code in src/skcomplex/models/economics/macroeconomics/_firms.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_price(agent, model)
staticmethod
Return a random price, pbar + 2 U(0, 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
InvestingFirmView
|
The firm. |
required |
model
|
ModelView
|
The model view of the pricing. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
price |
float
|
The price of the period. |
Source code in src/skcomplex/models/economics/macroeconomics/_firms.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_steps()
staticmethod
Return the steps of a period in their order, each a label, a state, and the function of its next value.
A firm invests, produces, borrows, sells, earns, adds the profit to its net worth, and, when the net worth turns negative, is replaced by an entrant, whose profit, capital, and net worth the last three steps reset.
Returns:
| Name | Type | Description |
|---|---|---|
steps |
tuple[tuple[str, str, Callable[[InvestingFirmView, ModelView], float]], ...]
|
The label of every step, the state it sets, and the function of its next value of the firm and the model view. |
Source code in src/skcomplex/models/economics/macroeconomics/_firms.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
LabourMarketInteraction(label, *, requesters, providers, rule=RandomSearchSpec(), limit='limit', quantity='quantity', allowance='allowance', transfers=(), phase=None, on_match=None)
Bases: MatchingInteraction[ModelView]
Labour market in which unemployed adults, in random order, take the best-paying vacancy within their sight.
A matching of the people, who request a job, with the firms, which provide their vacancies: a person whose
hireable limit admits a job takes the firm of the highest wage within its sight that still has a vacancy, and
moves to it. Build it with
PartnerSpec(sight, 'score', score=LabourMarketInteraction.score, clearing='provider').
Examples:
>>> from skcomplex.specs import PartnerSpec
>>> from skcomplex.models.economics.macroeconomics import LabourMarketInteraction
>>> LabourMarketInteraction(
... 'jobs',
... requesters='people',
... providers='businesses',
... rule=PartnerSpec(5.0, 'score', score=LabourMarketInteraction.score, clearing='provider'),
... limit=('hireable', 'limit'),
... quantity=('quantity', 'vacancies'),
... on_match=LabourMarketInteraction.hire,
... ).check().providers
'businesses'
Source code in src/skcomplex/core/interactions/_matching.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
hire(match, model)
staticmethod
Employ a matched person at its firm and move it there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
MatchSpec
|
The match of a person with a firm. |
required |
model
|
ModelView
|
The model view of the market. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_labour_market.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
score(person, firm)
staticmethod
Return the wage of a firm, the score by which a person prefers it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
person
|
object
|
The person who seeks a job. |
required |
firm
|
object
|
The firm with a vacancy. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
score |
float
|
The wage of the firm. |
Source code in src/skcomplex/models/economics/macroeconomics/_labour_market.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
LenderElement(label, visual=None, *, equity=100.0, ask=0.0, supply=0.0, lent=0.0, losses=0.0, alpha=0.1, capital_ratio=0.1)
Bases: Element
Bank that lends up to a multiple of its equity at a rate that falls with its equity.
The bank asks the rate alpha * equity ** -alpha of Delli Gatti et al. (2010), so better capitalised banks lend
cheaper, and it offers loans up to equity / capital_ratio. The maps of its settlement read the firms bound to
their role sources, whose interest and defaults reach the bank they name in their reference state partner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
equity
|
Annotated[float, StateSpec()]
|
The initial equity. |
100.0
|
ask
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The interest rate the bank asks. |
0.0
|
supply
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loans the bank can still grant in the current step. |
0.0
|
lent
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loans granted in the current step. |
0.0
|
losses
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loans written off in the current step. |
0.0
|
alpha
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The elasticity of the interest rate to the equity. |
0.1
|
capital_ratio
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The smallest ratio of equity to loans. |
0.1
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import LenderElement
>>> GroupElement('banks', element=LenderElement, size=5, values={'equity': 100.0}).size
5
Source code in src/skcomplex/models/economics/macroeconomics/_lender.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
get_income(agent, model)
staticmethod
Return the interest a bank earns in the step, less what its defaulting borrowers cannot repay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
LenderView
|
The bank. |
required |
model
|
ModelView
|
The model view of the settlement. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
income |
float
|
The change of the equity. |
Source code in src/skcomplex/models/economics/macroeconomics/_lender.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
get_losses(agent, model)
staticmethod
Return the loans of a bank written off in the step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
LenderView
|
The bank. |
required |
model
|
ModelView
|
The model view of the settlement. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
losses |
float
|
The change of the losses. |
Source code in src/skcomplex/models/economics/macroeconomics/_lender.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
get_quote()
staticmethod
Return the states a bank sets in the plan of a step, its rate and lending capacity from its equity.
Returns:
| Name | Type | Description |
|---|---|---|
quote |
tuple[tuple[str, Callable[[LenderView, ModelView], float]], ...]
|
The name of every state and the function of its value, of the bank and the model view. |
Source code in src/skcomplex/models/economics/macroeconomics/_lender.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
MonetaryBankElement(label, visual=None, *, deposits=10.0, interest=0.03, payout=0.5, credit=0.1)
Bases: Element
Bank of a stock-flow consistent economy, whose own funds are money, and which lends and charges interest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the bank. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
deposits
|
Annotated[object, StateSpec(domain=closed_open(0, oo), quantity=money)]
|
The own funds of the bank. |
10.0
|
interest
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The interest rate on loans per period. |
0.03
|
payout
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the bank's funds paid out as dividends per period. |
0.5
|
credit
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The new loans per unit of sales. |
0.1
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import MonetaryBankElement
>>> MonetaryBankElement('bank').deposits
10.0
Source code in src/skcomplex/models/economics/macroeconomics/_monetary_bank.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
PlotElement(label, visual=None, *, food=0.0, capacity=10.0, resistance=0.0, regrowth=1.0)
Bases: Element
Patch of land whose food grows back by a share of its capacity every step, harvested against a resistance.
The regrowth is a RegrowthInteraction of the group of patches, relative to the capacity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the patch or the site group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
food
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The food on the patch. |
0.0
|
capacity
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The most food the patch holds. |
10.0
|
resistance
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The labour lost to the resistance of the patch before any food is harvested. |
0.0
|
regrowth
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the capacity that grows back in a step. |
1.0
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import PlotElement
>>> PlotElement('patch').regrowth
1.0
Source code in src/skcomplex/models/economics/macroeconomics/_plot.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
PolicySwitchInteraction(label, *, rule=None, phase=None, ratio=0.1, new_ratio=0.1, change_at=0.0, banks='banks')
Bases: FeedbackInteraction[ModelView]
Policy switch of a central bank, which moves the reserve ratio of the banks from ratio to new_ratio.
The ratio switches at the time change_at.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the institution. |
required |
rule
|
Callable[[ModelView], None] | None
|
Unused, the regulator overrides |
None
|
phase
|
str | None
|
The phase the regulator acts in, or |
None
|
ratio
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The reserve ratio before the change. |
0.1
|
new_ratio
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The reserve ratio after the change. |
0.1
|
change_at
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The time of the change. |
0.0
|
banks
|
str
|
The path of the group of banks. |
'banks'
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import PolicySwitchInteraction
>>> PolicySwitchInteraction('regulator', ratio=0.1, new_ratio=0.2, change_at=100.0).new_ratio
0.2
Source code in src/skcomplex/models/economics/macroeconomics/_policy_switch.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
act(model)
Set the reserve ratio of the banks from the schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
ModelView
|
The model view of the regulator. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_policy_switch.py
67 68 69 70 71 72 73 74 75 76 77 78 | |
RamseyEconomyElement(label, visual=None, *, k=1.0, c=0.5, A=1.0, alpha=0.3, delta=0.05, rho=0.03, v=0.7)
Bases: Element
Economy that splits its output between consumption and capital, after Ramsey, Cass, and Koopmans.
Capital follows k' = A k^alpha - delta k - c, a rate interaction of the factory, under the consumption c, a
bounded control input. The planner maximises the discounted utility ∫ exp(-rho t) log(c) dt plus the discounted
value exp(-rho T) v k(T) of the capital left at the horizon T. Pontryagin's principle gives the Euler
equation c' / c = alpha A k^(alpha - 1) - delta - rho, so capital approaches the modified golden rule
alpha A k*^(alpha - 1) = delta + rho along the saddle path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the economy. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
k
|
Annotated[float, StateSpec(domain=open(0, oo))]
|
The initial capital per worker. |
1.0
|
c
|
Annotated[float, ParameterSpec(adaptive=True, bounds=(MIN_CONSUMPTION, MAX_CONSUMPTION))]
|
The consumption per worker, the control input. |
0.5
|
A
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The total factor productivity. |
1.0
|
alpha
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The capital share of output. |
0.3
|
delta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The depreciation rate. |
0.05
|
rho
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The discount rate. |
0.03
|
v
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The value per unit of capital left at the horizon. |
0.7
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import RamseyEconomyElement
>>> RamseyEconomyElement('economy', k=2.0).k
2.0
Source code in src/skcomplex/models/economics/macroeconomics/_optimal_growth.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
ReserveBankElement(label, visual=None, *, reserves=0.0, deposits=0.0, loans=0.0, reserve_ratio=0.1, customers='customers')
Bases: Element
Bank that lends its reserves in excess of the required share of its deposits to one of its customers.
The borrower spends the loan at once, and the payee, a random customer, deposits it at its own bank, whose
reserves and deposits grow by the loan. The customers of a bank are those whose reference state bank names it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
reserves
|
Annotated[float, StateSpec()]
|
The reserves of the bank. |
0.0
|
deposits
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The deposits of its customers. |
0.0
|
loans
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The loans to its customers. |
0.0
|
reserve_ratio
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The required ratio of reserves to deposits. |
0.1
|
customers
|
str
|
The path of the group of customers. |
'customers'
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import ReserveBankElement
>>> GroupElement('banks', element=ReserveBankElement, size=3, values={'reserves': 10.0}).size
3
Source code in src/skcomplex/models/economics/macroeconomics/_reserve_bank.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
lend(agent, model)
Lend the excess reserves to a random customer, whose payment is redeposited at a random customer's bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
ReserveBankView
|
The bank. |
required |
model
|
ModelView
|
The model. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_reserve_bank.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
SettlerElement(label, visual=None, *, food=10.0, money=0.0, loans=0.0, age=20.0, parent=-1.0, employer=-1.0, harvested=0.0, born=-100.0, fate=ALIVE, fertility=0.5, exploration=0.5, enterprise=0.5, restlessness=0.1, labour=5.0, need=2.0, maturity=15.0, lifespan=85.0, spacing=2.0, endowment=5.0, mutation=0.05, sight=5.0, reserve=5.0, monetary=0.0)
Bases: Element
Mortal person who eats, ages, raises children, moves, and, in the monetary economy, works and founds firms.
Every step a person eats need food and starves when its food runs out, and past lifespan it dies of old age
with probability 1/7. A child takes need food from its parent and follows it. A fed adult has a child with the
probability fertility, at most once every spacing steps, and gives it endowment food. The child inherits the
four propensities, each moved by a normal mutation and kept in [0, 1]. A person that harvested too little and holds
less than reserve steps of food moves, far with the probability exploration. In the monetary economy an
unemployed adult on a patch with food but no firm founds one with the probability enterprise, and a worker quits
with the probability restlessness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the person or the group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
food
|
Annotated[float, StateSpec()]
|
The food the person holds. |
10.0
|
money
|
Annotated[float, StateSpec(quantity=money)]
|
The money the person holds. |
0.0
|
loans
|
Annotated[float, StateSpec(quantity=credit)]
|
The loans the person holds, negative for a debt taken over from a firm. |
0.0
|
age
|
Annotated[float, StateSpec(domain=NN)]
|
The age in steps. |
20.0
|
parent
|
Annotated[float, StateSpec(reference=people)]
|
The id of the parent, or -1. |
-1.0
|
employer
|
Annotated[float, StateSpec(reference=businesses)]
|
The id of the firm that employs the person, or -1. |
-1.0
|
harvested
|
Annotated[float, StateSpec()]
|
The food the person harvested or earned in the step. |
0.0
|
born
|
Annotated[float, StateSpec()]
|
The step of the person's last child. |
-100.0
|
fate
|
Annotated[float, StateSpec()]
|
0 while alive, 1 after starving, and 2 after dying of old age, until the census removes the person. |
ALIVE
|
fertility
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The probability of a child in a step. |
0.5
|
exploration
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The probability of moving far. |
0.5
|
enterprise
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The probability of founding a firm. |
0.5
|
restlessness
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The probability of quitting a job. |
0.1
|
labour
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The labour of an adult in a step. |
5.0
|
need
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The food a person eats in a step. |
2.0
|
maturity
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The age of adulthood. |
15.0
|
lifespan
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The age after which death by old age is possible. |
85.0
|
spacing
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The fewest steps between two children. |
2.0
|
endowment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The food a parent gives a newborn child. |
5.0
|
mutation
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The standard deviation of the mutation of a propensity. |
0.05
|
sight
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The distance within which a person sees firms and explores. |
5.0
|
reserve
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The steps of food a person buys up to, and below which a person that harvests too little moves. |
5.0
|
monetary
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
One in the monetary economy, zero among hunter-gatherers. |
0.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.economics.macroeconomics import SettlerElement
>>> GroupElement('people', element=SettlerElement, size=3, variable=True).size
3
Source code in src/skcomplex/models/economics/macroeconomics/_settler.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
live(agent, model)
Age, eat, die, have children, and move or work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
SettlerView
|
The person. |
required |
model
|
ModelView
|
The model. |
required |
Source code in src/skcomplex/models/economics/macroeconomics/_settler.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
SolowGrowthInteraction(label, *, target, s=0.2, alpha=0.3, delta=0.05)
Bases: RateInteraction
Solow growth of the capital per worker k of a target, dk/dt = s * k**alpha - delta * k.
A rate interaction on the state k whose rate is the saving of a Cobb-Douglas output minus depreciation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the economy. |
required |
s
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The saving rate. |
0.2
|
alpha
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The output elasticity of capital. |
0.3
|
delta
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The depreciation rate. |
0.05
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import SolowGrowthInteraction
>>> SolowGrowthInteraction('solow', target='country', s=0.3).s
0.3
Source code in src/skcomplex/models/economics/macroeconomics/_solow_growth.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
TradingEconomyElement(label, visual=None, *, E=0.885, X=32.0, M=34.0, PH=1.2, home_price=1.2, inflation=0.1, world_price=1.0, exports=32.0, imports=34.0, export_price=1.062, import_price=1.13, export_elasticity=-1.0, import_elasticity=-1.0, floating=1.0, import_share=0.34, demand=52.0, government=50.0)
Bases: Element
Open economy that trades with the World at an exchange rate, floating or fixed.
Its states are the exchange rate E in World currency per unit of home currency, the export and import volumes
X and M, and the home price PH; its parameters are the prices, volumes, and elasticities of the balanced
start, the rise inflation of home prices, whether the rate floats, and the shares of the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the economy. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
E
|
Annotated[object, StateSpec(domain=open(0, oo))]
|
The exchange rate. |
0.885
|
X
|
Annotated[object, StateSpec(domain=closed_open(0, oo))]
|
The export volume. |
32.0
|
M
|
Annotated[object, StateSpec(domain=closed_open(0, oo))]
|
The import volume. |
34.0
|
PH
|
Annotated[object, StateSpec(domain=open(0, oo))]
|
The home price of home-produced goods. |
1.2
|
home_price
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The home price before the rise. |
1.2
|
inflation
|
Annotated[object, ParameterSpec()]
|
The relative rise of the home prices. |
0.1
|
world_price
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The world price level. |
1.0
|
exports
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The export volume of the balanced start. |
32.0
|
imports
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The import volume of the balanced start. |
34.0
|
export_price
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The World price of the exports at the start. |
1.062
|
import_price
|
Annotated[object, ParameterSpec(domain=open(0, oo))]
|
The home price of the imports at the start. |
1.13
|
export_elasticity
|
Annotated[object, ParameterSpec()]
|
The price elasticity of the exports. |
-1.0
|
import_elasticity
|
Annotated[object, ParameterSpec()]
|
The price elasticity of the imports. |
-1.0
|
floating
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
1 when the exchange rate floats, 0 when it is fixed. |
1.0
|
import_share
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The share of the imports in the output. |
0.34
|
demand
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The private domestic demand. |
52.0
|
government
|
Annotated[object, ParameterSpec(domain=closed_open(0, oo))]
|
The government spending. |
50.0
|
Examples:
>>> from skcomplex.models.economics.macroeconomics import TradingEconomyElement
>>> TradingEconomyElement('home').floating
1.0
Source code in src/skcomplex/models/economics/macroeconomics/_trade.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
capital_stock(capital=100.0, *, investment_fraction=0.2, output_per_capital=1 / 3, lifetime=15.0)
Return Meadows' capital stock, grown by reinvested output and drained by depreciation.
The stock follows dK/dt = investment_fraction * output_per_capital * K - K / lifetime. It grows exponentially when
the capital lives longer than 1 / (investment_fraction * output_per_capital), declines when it lives shorter, and
stays in dynamic equilibrium otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capital
|
float
|
The initial capital stock. |
100.0
|
investment_fraction
|
float
|
The fraction of the output that is reinvested. |
0.2
|
output_per_capital
|
float
|
The annual output per unit of capital. |
1 / 3
|
lifetime
|
float
|
The average lifetime of the capital. |
15.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the capital stock |
Examples:
>>> from skcomplex.models.economics.macroeconomics import capital_stock
>>> capital_stock(lifetime=20.0).elements[0].lifetime
20.0
Source code in src/skcomplex/models/economics/macroeconomics/_capital.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
credit_networks(firms=100, banks=10, *, sample=3, intensity=4.0, leverage=1.0, mean_return=0.03, volatility=0.3, net_worth=10.0, equity=100.0, alpha=0.1, capital_ratio=0.1, random_state=0)
Return a credit market where firms sample banks and switch to cheaper lenders, and defaults hit the lenders.
Every step the banks quote rates that fall with their equity, every firm samples sample banks and switches from
its lender to the cheapest of them with probability 1 - exp(intensity * (r_new - r_old) / r_new), borrows, and
invests at a random return. Interest and write-offs of defaulted firms move net worth between firms and banks, so
the total net worth changes only by the firms' returns and the entrants' net worth. A higher intensity of switching
concentrates the loans in the cheapest banks and narrows the spread of the rates that firms pay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
firms
|
int
|
The number of firms. |
100
|
banks
|
int
|
The number of banks. |
10
|
sample
|
int
|
The number of banks every firm samples. |
3
|
intensity
|
float
|
The intensity of switching to a cheaper bank. |
4.0
|
leverage
|
float
|
The ratio of the loan a firm wants to its net worth. |
1.0
|
mean_return
|
float
|
The mean return on capital. |
0.03
|
volatility
|
float
|
The standard deviation of the return on capital. |
0.3
|
net_worth
|
float
|
The initial net worth of every firm and of every entrant. |
10.0
|
equity
|
float
|
The mean initial equity of the banks, drawn uniformly within 50% of it. |
100.0
|
alpha
|
float
|
The elasticity of the interest rate to the equity. |
0.1
|
capital_ratio
|
float
|
The smallest ratio of a bank's equity to its loans. |
0.1
|
random_state
|
int | Generator | None
|
The seed or generator of the initial equities. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the groups |
Examples:
>>> from skcomplex.models.economics.macroeconomics import credit_networks
>>> [element.label for element in credit_networks().elements]
['firms', 'banks']
Source code in src/skcomplex/models/economics/macroeconomics/_credit.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
exchange_rates(exports=32.0, imports=34.0, *, home_price=1.2, inflation=0.1, export_elasticity=-1.0, import_elasticity=-1.0, floating=True, demand=52.0, government=50.0, world_price=1.0)
Return Hamill and Gilbert's staged adjustment of trade and the exchange rate to a rise in home prices.
The economy starts in balance at the exchange rate E = M * PW / (X * PH), in units of World currency per unit of
Home currency, with the export and import volumes and prices of the United Kingdom in 1999 by default. Home prices
rise by inflation at the first stage. At every stage a floating rate takes the value that balances the currency
market at the current volumes, a fixed rate stays, and the volumes respond to the prices of the stage before with
constant price elasticities. The book follows two stages, the default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exports
|
float
|
The initial export volume. |
32.0
|
imports
|
float
|
The initial import volume. |
34.0
|
home_price
|
float
|
The home price of home-produced goods before the rise. |
1.2
|
inflation
|
float
|
The relative rise of the home prices. |
0.1
|
export_elasticity
|
float
|
The price elasticity of the exports. |
-1.0
|
import_elasticity
|
float
|
The price elasticity of the imports. |
-1.0
|
floating
|
bool
|
Whether the exchange rate floats, or is fixed as in the Eurozone. |
True
|
demand
|
float
|
The private domestic demand, consumption and investment. |
52.0
|
government
|
float
|
The government spending. |
50.0
|
world_price
|
float
|
The world price level. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the economy |
Examples:
>>> from skcomplex.models.economics.macroeconomics import exchange_rates
>>> round(exchange_rates().elements[0].E, 3)
0.885
Source code in src/skcomplex/models/economics/macroeconomics/_trade.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
fractional_reserve_banking(customers=100, banks=5, *, base_money=1000.0, ratio=0.1, new_ratio=None, change_at=150.0, spending=0.1, repayment=0.05, random_state=0)
Return customers and banks whose lending of excess reserves multiplies the base money by 1 / ratio.
The base money starts as equal deposits of the customers, held as reserves by their banks, picked at random. Every
step the customers pay a share of their deposits to random customers and repay a share of their loans from their
deposits, and every bank lends its reserves above the
required share of its deposits; the loans are spent and redeposited at random banks. The reserves stay equal to the
base money, so the broad money, the sum of deposits, settles near base_money / ratio. A regulator changes the
reserve ratio to new_ratio at change_at, and the broad money moves to the new multiplier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
customers
|
int
|
The number of customers. |
100
|
banks
|
int
|
The number of banks. |
5
|
base_money
|
float
|
The base money, deposited by the customers in equal shares. |
1000.0
|
ratio
|
float
|
The reserve ratio. |
0.1
|
new_ratio
|
float | None
|
The reserve ratio from |
None
|
change_at
|
float
|
The time the reserve ratio changes. |
150.0
|
spending
|
float
|
The share of its deposit a customer pays to a random customer every step. |
0.1
|
repayment
|
float
|
The share of its loan a customer repays every step. |
0.05
|
random_state
|
int | Generator | None
|
The seed or generator of the customers' banks. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the groups |
Examples:
>>> from skcomplex.models.economics.macroeconomics import fractional_reserve_banking
>>> fractional_reserve_banking(new_ratio=0.2).interactions[0].new_ratio
0.2
Source code in src/skcomplex/models/economics/macroeconomics/_banking.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
metaphoria(n_people=100, *, mode='hunter_gatherer', shape=(20, 20), max_food=15.0, max_resistance=5.0, regrowth=1.0, need=2.0, labour=5.0, interest=0.003, repayment=0.004, n_firms=5, random_state=0)
Return Gooding's Metaphoria, a mortal population of hunter-gatherers or of a monetary economy.
Patches of a periodic lattice hold food that grows back to a random capacity and resist harvesting with a random resistance. People need food every step, age, die of starvation or old age, and have children who inherit their propensities to breed, explore, found firms, and quit jobs, with mutations, so the propensities evolve under the test of survival. Hunter-gatherers pool the labour of the adults on a patch and share the harvest. In the monetary economy firms harvest with paid workers, sell the food in shops, and borrow the wages from a bank that creates money as loans, so the money of all holders sums to zero at every step. Gooding found the hunter-gatherers stable, and the monetary population smaller and less healthy, with money concentrating to a Gini coefficient near 0.5. On land where the hunter-gatherers thrive the monetary population dwindles towards extinction, and with abundant food it lives on with persistent starvation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_people
|
int
|
The initial number of adults. |
100
|
mode
|
str
|
|
'hunter_gatherer'
|
shape
|
Sequence[int]
|
The number of patches along each axis. |
(20, 20)
|
max_food
|
float
|
The largest capacity of a patch, drawn uniformly from 0. |
15.0
|
max_resistance
|
float
|
The largest resistance of a patch, drawn uniformly from 0. |
5.0
|
regrowth
|
float
|
The share of the capacity that grows back in a step. |
1.0
|
need
|
float
|
The food a person eats in a step. |
2.0
|
labour
|
float
|
The labour of an adult in a step. |
5.0
|
interest
|
float
|
The interest rate of loans per step. |
0.003
|
repayment
|
float
|
The share of the principal repaid per step. |
0.004
|
n_firms
|
int
|
The number of firms of the monetary economy at the start, each without an owner until it has a worker. |
5
|
random_state
|
int | Generator | None
|
The seed or generator of the patches, the places, ages, and propensities of the people. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the group |
Raises:
| Type | Description |
|---|---|
ValueError
|
The mode is unknown. |
Examples:
>>> from skcomplex.models.economics.macroeconomics import metaphoria
>>> [group.label for group in metaphoria(10, mode='monetary', shape=(5, 5)).elements]
['patches', 'people', 'businesses', 'bank']
Source code in src/skcomplex/models/economics/macroeconomics/_metaphoria.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
multiplier_accelerator(income=110.0, previous=100.0, *, c=0.8, v=1.5, G=20.0)
Return Samuelson's multiplier-accelerator, Y_{t+1} = c (1 + v) Y_t - c v Y_{t-1} + G.
Income oscillates around G / (1 - c), with growing amplitude when c v > 1 and complex characteristic roots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
income
|
float
|
The income of the current period. |
110.0
|
previous
|
float
|
The income of the previous period. |
100.0
|
c
|
float
|
The marginal propensity to consume. |
0.8
|
v
|
float
|
The accelerator, the investment response to the change in consumption. |
1.5
|
G
|
float
|
The government spending. |
20.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the income |
Examples:
>>> from skcomplex.models.economics.macroeconomics import multiplier_accelerator
>>> multiplier_accelerator(v=0.5).elements[0].v
0.5
Source code in src/skcomplex/models/economics/macroeconomics/_growth.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
optimal_consumption(k=1.0, *, A=1.0, alpha=0.3, delta=0.05, rho=0.03, v=0.7)
Return the Ramsey economy that chooses the consumption path maximising its discounted utility.
Run with an optimal control solver from little capital, consumption rises with capital along the saddle path towards the modified golden rule, and the economy saves a falling share of its output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
float
|
The initial capital per worker. |
1.0
|
A
|
float
|
The total factor productivity. |
1.0
|
alpha
|
float
|
The capital share of output. |
0.3
|
delta
|
float
|
The depreciation rate. |
0.05
|
rho
|
float
|
The discount rate. |
0.03
|
v
|
float
|
The value per unit of capital left at the horizon. |
0.7
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the capital |
Examples:
>>> from skcomplex.models.economics.macroeconomics import optimal_consumption
>>> optimal_consumption(rho=0.05).elements[0].rho
0.05
Source code in src/skcomplex/models/economics/macroeconomics/_optimal_growth.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
solow(k=1.0, *, s=0.2, alpha=0.3, delta=0.05)
Return an economy whose capital per worker approaches its steady state through saving and depreciation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k
|
float
|
The initial capital per worker. |
1.0
|
s
|
float
|
The saving rate. |
0.2
|
alpha
|
float
|
The capital share of output. |
0.3
|
delta
|
float
|
The depreciation rate. |
0.05
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the economy |
Examples:
>>> from skcomplex.models.economics.macroeconomics import solow
>>> solow(s=0.3).interactions[0].s
0.3
Source code in src/skcomplex/models/economics/macroeconomics/_growth.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
stock_flow_consistent_economy(*, household_deposits=60.0, firm_deposits=20.0, bank_deposits=10.0, loans=50.0, sales=40.0, alpha_income=0.6, alpha_wealth=0.4, wage_share=0.7, interest=0.03, payout=0.5, distribution=0.3, credit=0.1, repayment=0.08)
Return a stock-flow consistent economy, a closed circuit of money between households, firms, and a bank.
Money is the deposits of the three sectors, tagged as the quantity money, and every transaction of a period is
a flow, so each payment is one sector's outflow and another's inflow. Households consume a share alpha_income of
their wages and a share alpha_wealth of their deposits, firms pay the wage share of last period's sales and the
interest on their loans, and distribute a share of their deposits as profits, and the bank pays out a share of its
funds as dividends. Lending creates money and
repayment destroys it, the only flows with the environment, so the total money changes exactly by lending minus
repayment, in the spirit of the models of Godley and Lavoie (2007) and the balance sheets of Caiani et al. (2016).
Loans approach credit * sales / repayment and sales settle where the stocks stop growing. The circuit moves the
money of a period, and the maps loans and sales set the loans and the sales of the firms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
household_deposits
|
float
|
The initial deposits of the households. |
60.0
|
firm_deposits
|
float
|
The initial deposits of the firms. |
20.0
|
bank_deposits
|
float
|
The initial own funds of the bank. |
10.0
|
loans
|
float
|
The initial loans of the firms. |
50.0
|
sales
|
float
|
The sales of the previous period. |
40.0
|
alpha_income
|
float
|
The propensity to consume out of wages. |
0.6
|
alpha_wealth
|
float
|
The propensity to consume out of deposits. |
0.4
|
wage_share
|
float
|
The share of sales paid as wages. |
0.7
|
interest
|
float
|
The interest rate on loans per period. |
0.03
|
payout
|
float
|
The share of the bank's funds paid out as dividends per period. |
0.5
|
distribution
|
float
|
The share of the firms' deposits distributed to households as profits per period. |
0.3
|
credit
|
float
|
The new loans per unit of sales. |
0.1
|
repayment
|
float
|
The share of loans repaid per period. |
0.08
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the deposits |
Examples:
>>> from skcomplex.models.economics.macroeconomics import stock_flow_consistent_economy
>>> [element.label for element in stock_flow_consistent_economy().elements]
['households', 'firms', 'bank']
Source code in src/skcomplex/models/economics/macroeconomics/_monetary.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
toy_firm_investment(n_firms=100, *, gamma=1.1, phi=0.1, r=0.1, pbar=0.01, random_state=0)
Return heterogeneous firms that invest out of past profits and sell at random prices, with entry and exit.
The firms start with net worth and capital 1 and a profit drawn from pbar + 2 U(0, 1), as in the toy model of
Bargigli et al. in Caiani et al. (2016, sect. 2.1). Aggregate production fluctuates as bankrupt firms are replaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_firms
|
int
|
The number of firms. |
100
|
gamma
|
float
|
The investment accelerator. |
1.1
|
phi
|
float
|
The productivity of capital. |
0.1
|
r
|
float
|
The interest rate. |
0.1
|
pbar
|
float
|
The constant part of the price. |
0.01
|
random_state
|
int | Generator | None
|
The seed or generator of the initial profits. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the group |
Examples:
>>> from skcomplex.models.economics.macroeconomics import toy_firm_investment
>>> toy_firm_investment(20).elements[0].check().prepare().size_
20
Source code in src/skcomplex/models/economics/macroeconomics/_firms.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |