Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Aug 2, 2024
1 parent 93724cf commit 022cb5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion examples/run_og_zaf_multiple_industry.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def main():

print("Percentage changes in aggregates:", ans)
# save percentage change output to csv file
ans.to_csv(os.path.join(save_dir, "OG-ZAF-MultipleIndustry-example_output.csv"))
ans.to_csv(
os.path.join(save_dir, "OG-ZAF-MultipleIndustry-example_output.csv")
)


if __name__ == "__main__":
Expand Down
27 changes: 13 additions & 14 deletions ogzaf/macro_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@


def get_macro_params(
data_start_date=datetime.datetime(1947, 1, 1),
data_end_date=datetime.date.today(),
country_iso="ZAF"
):
data_start_date=datetime.datetime(1947, 1, 1),
data_end_date=datetime.date.today(),
country_iso="ZAF",
):
"""
Compute values of parameters that are derived from macro data
Expand Down Expand Up @@ -84,9 +84,10 @@ def get_macro_params(

# Compute macro parameters from WB data
macro_parameters["initial_debt_ratio"] = (
pd.Series(
wb_data_q["Gross PSD Gen Gov - percentage of GDP"]).loc[
baseline_YYYYQ]) / 100
pd.Series(wb_data_q["Gross PSD Gen Gov - percentage of GDP"]).loc[
baseline_YYYYQ
]
) / 100
macro_parameters["initial_foreign_debt_ratio"] = pd.Series(
wb_data_q["Gross PSD USD - external creditors"]
/ (
Expand All @@ -106,7 +107,9 @@ def get_macro_params(
).loc[baseline_YYYYQ]
]
macro_parameters["g_y_annual"] = (
wb_data_a["GDP per capita (constant 2015 US$)"].pct_change(-1).mean()
wb_data_a["GDP per capita (constant 2015 US$)"]
.pct_change(-1)
.mean()
)
except:
print("Failed to retrieve data from World Bank")
Expand Down Expand Up @@ -184,11 +187,7 @@ 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)
]
macro_parameters["r_gov_scale"] = [
res.params[1]
]
macro_parameters["r_gov_shift"] = [(-res.params[0] / 100)]
macro_parameters["r_gov_scale"] = [res.params[1]]

return macro_parameters

0 comments on commit 022cb5d

Please sign in to comment.