Skip to content

Instantly share code, notes, and snippets.

@danodriscoll
Last active June 26, 2023 12:24
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
ABMLP Agent Comments
class Government(Agent):
def __init__(self, unique_id, model) -> None:
super().__init__(unique_id, model)
self.breed = "Government"
def step(self) -> None:
"""
ABMLP Government Functions (each and every step):
1 Interact with and distribute pure expenditures to producers.
2 Distribute interest on Treasury bills and long-term bond coupon payments, if any,
to households and the central bank. (t-1)
3 Calculate the value of a perpetuity.
4 Government Budget Constraint: Issue or redeem existing Treasury bills. (t)
"""
# 3
"""
G&L pp131-132: The value of a perpetuity (long-term bond) in this step.
"""
# Use the interest rate from the previoius step to calculate the current price of a long-term bond.
# Use the current bond price of a bond to calculate the long-term rate of interest (bond yield (to maturity)).
# 4
"""
G&L p146: Govt Budget Constraint (Bs):
(5.14) ΔBs ≡ Bs - Bs₋₁ == (G + rb₋₁ * Bs₋₁ + BLs₋₁) - (T + rb₋₁ * Bcb₋₁) - ΔBLs₋₁ * PbL
"The bills 'Bs' that need to be newly issued are equal to government expenditures,
including its interest payments minus the govt revenues - taxes and central bank profits - plus
the value of the newly issued long-term bonds. Needless to say, when there is a government surplus,
or when the government deficit is financed by new issues of long-term bonds, the change in
Treasury bills will be negative and bills will be redeemed."
G&L p147:
"... equation (5.14) says that the government issues new bills as a response to a government deficit
and as a response to changes in the value of newly issued or newly retired bonds."
"""
class Producer(Agent):
def __init__(self, unique_id, model) -> None:
super().__init__(unique_id, model)
self.breed = "Producer"
def step(self) -> None:
"""
ABMLP Producer Functions (each and every step):
1 Choose and employ a household agent.
2 Account for government and household consumption demands.
3 Communicate to employed household agents their wage this step.
"""
class Household(Agent):
def __init__(self, unique_id, model) -> None:
super().__init__(unique_id, model)
self.breed = "Household"
def step(self) -> None:
"""
ABMLP Household Functions (each and every step):
1 Calculate disposable income, the wage, interest and coupon payments received minus tax.
2 Consumption Decision: Decide how much to save out of income.
3 Calculate new wealth including capital gains or losses this step.
4 Agent Bond Price Expectations:
Household expectations feed into the 'Effect of Household Liquidity Preference'.
5 Rebalance asset portfolio:
Liquidity preference. Two traditions:
Quantity theory of money: Link money balances to the flow of income.
Make money balances some proportion of wealth.
"""
# 1
"""
See G&L Equations, p137:
Y ≡ C + G (5.1)
"""
# 2
consumption_income = incomeConsumption(self.YD)
consumption_wealth = wealthConsumption(self.Vh)
total_consumption = consumption_income + consumption_wealth # Combine consumptions.
# 3
"""
G&L p141:
"Capital gains (CG) only have an impact in the next period, since they then appear in the
wealth accumulated in previous periods. Thus, capital gains or losses feed into the consumption
function with a lag, via the term in wealth (V₋₁)."
V = V₋₁ + (YDᵣ - C) + CG (5.4)
with:
CG = ΔPbL * BLₕ₋₁ (5.5)
"""
self.CG = (government.PbL - government.Last_PbL) * self.BLd
self.Vh = self.Vh + ((self.YD - total_consumption) + self.CG)
"""
G&L p142:
Portfolio Decision: Bills vs bonds vs central bank (money) deposits.
"... We have further assumed that it is the expected rate of returns on bonds, ERrbl,
rather than the yield on bonds, rbL, that enters into the determination of portfolio choice.
We note that indeed portfolio decisions of households are forward-looking."
"""
# 4
"""
Agent Bond Price Expectations:
G&L p148: ERrbL = rbL + χ * ((PebL - PbL) / PbL)
'self.PebL = government.PbL': This would freeze expectations:
A household would expect the current bond price to remain the same in the next period.
"""
self.Expected_Coupon_Rate = government.Coupon_Rate # Freeze bond price expectations.
# 5
"""
Liquidity Preference: Portfolio Allocation Decisions.
In every step an agent will decide on the proportion of its wealth to hold in both interest-bearing money and
cash money. If employed (in the current step), a further decision is made on the proportion of wealth held
in interest-bearing money types; that is, the split between interest-bearing bills and perpetuities (bonds).
The decision on whether to hold more or less bonds to interest-bearing bills rests with an agent's
expectation of the future; that is, the difference between the current price of a bond and the price it
expects to see in the next step (see # 4).
"""
class CentralBank(Agent):
def __init__(self, unique_id, model) -> None:
super().__init__(unique_id, model)
self.breed = "CentralBank"
def step(self) -> None:
"""
1 Set the rate of interest on bills.
2 Distribute profit on Government bills back to the Government. (t-1)
3 Purchase government bills surplus to household requirements. (t)
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment