Skip to content

Commit

Permalink
remove unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Jun 14, 2024
1 parent ac1f068 commit 7a54015
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions ogzaf/macro_params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This module uses data from World Bank WDI, World Bank Quarterly Public Sector Debt (QPSD) database,
UN Data Portal, and FRED to find values for parameters for the
OG-ZAF model that rely on macro data for calibration.
This module uses data from World Bank WDI, World Bank Quarterly Public
Sector Debt (QPSD) database, UN Data Portal, and FRED to find values for
parameters for the OG-ZAF model that rely on macro data for calibration.
"""

# imports
Expand All @@ -12,7 +12,6 @@
import requests
import datetime
import statsmodels.api as sm
from ogzaf.utils import get_legacy_session
from io import StringIO


Expand All @@ -39,6 +38,7 @@ def get_macro_params():
"GDP per capita (constant 2015 US$)": "NY.GDP.PCAP.KD",
"Real GDP (constant 2015 US$)": "NY.GDP.MKTP.KD",
"Nominal GDP (current US$)": "NY.GDP.MKTP.CD",
"General government final consumption expenditure (current US$)": "NE.CON.GOVT.CD",
# "General government debt (percentage of GDP)": "GC.DOD.TOTL.GD.ZS",
# "GDP per capita (current US$)": "NY.GDP.PCAP.CD",
# "GDP per person employed (constant 2017 PPP$)": "SL.GDP.PCAP.EM.KD",
Expand Down Expand Up @@ -119,18 +119,22 @@ def get_macro_params():
# "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,
# )
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

Expand Down Expand Up @@ -180,7 +184,7 @@ def get_macro_params():
# ]

# find alpha_G
macro_parameters["alpha_G"] = [0.27]
# macro_parameters["alpha_G"] = [0.27]
# macro_parameters["alpha_G"] = [
# pd.Series(
# (
Expand Down Expand Up @@ -221,7 +225,7 @@ def get_macro_params():
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
sov_y = np.arange(20, 120) / 10
corp_yhat = 8.199 - (2.975 * sov_y) + (0.478 * sov_y**2)
Expand All @@ -232,10 +236,14 @@ def get_macro_params():
)
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
macro_parameters["r_gov_shift"] = (-res.params[0] / 100) # 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]
macro_parameters["r_gov_shift"] = [
(-res.params[0] / 100)
] # 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

0 comments on commit 7a54015

Please sign in to comment.