Skip to content

Commit

Permalink
get capital share of income from FRED
Browse files Browse the repository at this point in the history
jdebacker committed May 5, 2024
1 parent 34dd7db commit bb90913
Showing 2 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ogzaf/calibrate.py
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ def __init__(
# chi_n = self.get_chi_n()

# Macro estimation
# self.macro_params = macro_params.get_macro_params()
self.macro_params = macro_params.get_macro_params()

# io matrix and alpha_c
if p.I > 1: # no need if just one consumption good
68 changes: 37 additions & 31 deletions ogzaf/macro_params.py
Original file line number Diff line number Diff line change
@@ -87,29 +87,30 @@ def get_macro_params():
(see https://data.un.org)
"""

target = (
"https://data.un.org/ws/rest/data/IAEG-SDGs,DF_SDG_GLH/"
+ "..SL_EMP_GTOTL.710..........."
+ "?startPeriod="
+ str(start.year)
+ "&"
+ "endPeriod="
+ str(end.year)
+ "&format=csv"
)

response = get_legacy_session().get(target)

# Check if the request was successful before processing
if response.status_code == 200:
csv_content = StringIO(response.text)
df_temp = pd.read_csv(csv_content)
else:
print(
f"Failed to retrieve data. HTTP status code: {response.status_code}"
)

un_data_a = df_temp[["TIME_PERIOD", "OBS_VALUE"]]
# target = (
# "https://data.un.org/ws/rest/data/IAEG-SDGs,DF_SDG_GLH/"
# + "..SL_EMP_GTOTL.710..........."
# + "?startPeriod="
# + str(start.year)
# + "&"
# + "endPeriod="
# + str(end.year)
# + "&format=csv"
# )

# response = get_legacy_session().get(target)
# print("TaRGET = ", target)

# # Check if the request was successful before processing
# if response.status_code == 200:
# csv_content = StringIO(response.text)
# df_temp = pd.read_csv(csv_content)
# else:
# print(
# f"Failed to retrieve data. HTTP status code: {response.status_code}"
# )

# un_data_a = df_temp[["TIME_PERIOD", "OBS_VALUE"]]

"""
This retrieves data from FRED.
@@ -122,6 +123,7 @@ def get_macro_params():
"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
@@ -193,15 +195,19 @@ def get_macro_params():

# find gamma
macro_parameters["gamma"] = [
# 1
# - (
# (
# un_data_a.loc[
# un_data_a["TIME_PERIOD"] == baseline_date.year, "OBS_VALUE"
# ].squeeze()
# )
# / 100
# )
1
- (
(
un_data_a.loc[
un_data_a["TIME_PERIOD"] == baseline_date.year, "OBS_VALUE"
].squeeze()
)
/ 100
)
- pd.Series(
(fred_data["Labor share of income"]).loc[baseline_yearquarter]
).mean()
]

# find g_y

0 comments on commit bb90913

Please sign in to comment.