From bb90913780849656c508ce834ca275a3410f69d6 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sat, 4 May 2024 23:47:15 -0400 Subject: [PATCH] get capital share of income from FRED --- ogzaf/calibrate.py | 2 +- ogzaf/macro_params.py | 68 +++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/ogzaf/calibrate.py b/ogzaf/calibrate.py index 1589ae7..1956065 100644 --- a/ogzaf/calibrate.py +++ b/ogzaf/calibrate.py @@ -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 diff --git a/ogzaf/macro_params.py b/ogzaf/macro_params.py index f000e61..dec1a50 100644 --- a/ogzaf/macro_params.py +++ b/ogzaf/macro_params.py @@ -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