Skip to content

Commit

Permalink
Merge pull request #57 from jdebacker/macro_params
Browse files Browse the repository at this point in the history
Update macro parameters
  • Loading branch information
jdebacker authored Jul 28, 2024
2 parents 58aead0 + 8060f56 commit 4d5e890
Show file tree
Hide file tree
Showing 3 changed files with 101,426 additions and 1,764 deletions.
12 changes: 7 additions & 5 deletions examples/run_og_zaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ def main():
# Update parameters from calibrate.py Calibration class
c = Calibration(p)
updated_params = c.get_dict()
p.tax_func_type = "linear"
p.age_specific = False
p.update_specifications(updated_params)
# set underlying growth rate to zero, as value from data is negative
p.g_y = 0.0
# set tax rates
p.update_specifications(
{
"cit_rate": [[0.27]],
"tax_func_type": "linear",
"age_specific": False,
# "etr_params": [[[0.22]]],
# "mtrx_params": [[[0.31]]],
# "mtry_params": [[[0.25]]],
"etr_params": [[[0.22]]],
"mtrx_params": [[[0.31]]],
"mtry_params": [[[0.25]]],
"tau_c": [[0.15]],
}
)
Expand Down
86 changes: 18 additions & 68 deletions ogzaf/macro_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

# imports
import pandas_datareader.data as web
from pandas_datareader import wb
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -111,35 +110,6 @@ def get_macro_params():

ilo_data = df_temp[["time", "obs_value"]]

"""
This retrieves data from FRED.
"""

fred_variable_dict = {
# "Labor share": "LABSHPINA156NRUG",
# "BAA Corp Bond Rates": "DBAA",
# "10 year govt bond rate": "IRLTLT01ZAM156N",
# "Nominal GDP": "MKTGDPZAA646NWDB",
"Total Expenditure to GDP": "ZAFGGXG01GDPPT",
"Total gov transfer payments": "B087RC1Q027SBEA",
"Social Security payments": "W823RC1",
"Gov interest payments": "A091RC1Q027SBEA",
"Labor share of income": "LABSHPZAA156NRUG",
}

# pull series of interest using pandas_datareader
fred_data = web.DataReader(fred_variable_dict.values(), "fred", start, end)
fred_data.rename(
columns=dict((y, x) for x, y in fred_variable_dict.items()),
inplace=True,
)
# make data quarterly
fred_data_q = fred_data.resample("Q").mean()

# Separate quartely, monthly, and annual FRED dataseries

# fred_data_d = fred_data[["BAA Corp Bond Rates", "10 year govt bond rate"]]

# initialize a dictionary of parameters
macro_parameters = {}

Expand Down Expand Up @@ -171,32 +141,14 @@ def get_macro_params():
).loc[baseline_yearquarter]
]

# find alpha_T
macro_parameters["alpha_T"] = [0.04]
# macro_parameters["alpha_T"] = [
# pd.Series(
# (
# fred_data_q["Total gov transfer payments"]
# - fred_data_q["Social Security payments"]
# )
# / fred_data_q["Nominal GDP"]
# ).loc[baseline_date]
# ]

# find alpha_G
# macro_parameters["alpha_G"] = [0.27]
# macro_parameters["alpha_G"] = [
# pd.Series(
# (
# fred_data_q["Gov expenditures"]
# - fred_data_q["Total gov transfer payments"]
# - fred_data_q["Gov interest payments"]
# )
# / fred_data_q["Nominal GDP"]
# ).loc[baseline_date]
# ]

# find gamma
# alpha_T, non-social security benefits as a fraction of GDP
# source: https://data.imf.org/?sk=b052f0f0-c166-43b6-84fa-47cccae3e219&hide_uv=1
macro_parameters["alpha_T"] = [0.041 - 0.0]
# alpha_G, gov't consumption expenditures as a fraction of GDP
# source: https://data.imf.org/?sk=edb0cd70-0af3-40e1-a9c3-bdef83ee4d1e&hide_uv=1
macro_parameters["alpha_G"] = [0.351 - 0.043 - 0.041]

# find gamma, capital's share of income
macro_parameters["gamma"] = [
1
- (
Expand All @@ -207,10 +159,6 @@ def get_macro_params():
)
/ 100
)
# 1
# - pd.Series(
# (fred_data["Labor share of income"]).loc[baseline_yearquarter]
# ).mean()
]

# find g_y
Expand All @@ -219,11 +167,15 @@ def get_macro_params():
)

""""
We want to use the non linear relationship estimated by Li, Magud, Werner, Witte (2021), available here: https://www.imf.org/en/Publications/WP/Issues/2021/06/04/The-Long-Run-Impact-of-Sovereign-Yields-on-Corporate-Yields-in-Emerging-Markets-50224
We want to use the non linear relationship estimated by
Li, Magud, Werner, Witte (2021), available here:
https://www.imf.org/en/Publications/WP/Issues/2021/06/04/The-Long-Run-Impact-of-Sovereign-Yields-on-Corporate-Yields-in-Emerging-Markets-50224
Steps:
1) Generate modelled corporate yields (corp_yhat) for a range of sovereign yields (sov_y) using the estimated equation in col 2 of table 8 (and figure 3).
2) Estimate the OLS using sovereign yields as the dependent variable
1) Generate modelled corporate yields (corp_yhat) for a range of
sovereign yields (sov_y) using the estimated equation in col 2 of
table 8 (and figure 3). 2) Estimate the OLS using sovereign yields
as the dependent variable
"""

# # estimate r_gov_shift and r_gov_scale
Expand All @@ -235,15 +187,13 @@ def get_macro_params():
corp_yhat,
)
res = mod.fit()
# first term is the constant and needs to be divided by 100 to have the correct unit. Second term is the coefficient
# first term is the constant and needs to be divided by 100 to have
# the correct unit. Second term is the coefficient
macro_parameters["r_gov_shift"] = [
(-res.params[0] / 100)
] # constant = 0.0337662504
] # constant = -0.0337662504
macro_parameters["r_gov_scale"] = [
res.params[1]
] # coefficient = 0.24484764

# macro_parameters["r_gov_shift"] = [-0.0337662504]
# macro_parameters["r_gov_scale"] = [0.24484764]

return macro_parameters
Loading

0 comments on commit 4d5e890

Please sign in to comment.