diff --git a/code/main/parse_GB_raw_data.py b/code/main/parse_GB_raw_data.py index 43d74ef..05481c0 100644 --- a/code/main/parse_GB_raw_data.py +++ b/code/main/parse_GB_raw_data.py @@ -1,4 +1,5 @@ import pandas as pd +import os # Load the Excel file excel_file = pd.ExcelFile('data/raw/GBweb_Row_Format.xlsx') @@ -80,6 +81,10 @@ for column in GB_df.columns[1:]: GB_df[column] = GB_df[column].apply(lambda x: f"{x:.{decimal}f}") +current_directory = os.path.dirname(os.path.abspath(__file__)) +file_path = "/../data/output/FRED.csv" +GB_df.to_csv(current_directory + file_path) + # Uncomment these final lines to get the output of your choice -GB_df.to_csv('data/output/GB.csv') +#GB_df.to_csv('data/output/GB.csv') # GB_df.to_excel('data/output/GB_parsed.xlsx', index=False) diff --git a/code/main/parse_SPF_raw_data.py b/code/main/parse_SPF_raw_data.py index 53a96aa..dd2ed9d 100644 --- a/code/main/parse_SPF_raw_data.py +++ b/code/main/parse_SPF_raw_data.py @@ -1,4 +1,5 @@ import pandas as pd +import os # Load the Excel file with levels first excel_file = pd.ExcelFile('data/raw/meanLevel.xlsx') @@ -68,6 +69,10 @@ for column in results_df.columns[1:]: results_df[column] = results_df[column].apply(lambda x: f"{x:.{decimal}f}") +current_directory = os.path.dirname(os.path.abspath(__file__)) +file_path = "/../data/output/FRED.csv" +results_df.to_csv(current_directory + file_path) + # Uncomment these final lines to get the output of your choice -results_df.to_csv('data/output/SPF.csv') +# results_df.to_csv('data/output/SPF.csv') # SPF_df.to_excel('data/output/SPF_parsed.xlsx', index=False) \ No newline at end of file diff --git a/code/main/reproduce.py b/code/main/reproduce.py index 282b2e9..dd4fb62 100755 --- a/code/main/reproduce.py +++ b/code/main/reproduce.py @@ -8,12 +8,12 @@ # List all files in the current directory files_to_run = [ - "./code/main/parse_GB_raw_data.py", - "./code/main/parse_SPF_raw_data.py", - "./code/main/scrape_FRED_data.py", - "./code/main/annual_forecasts.py", - "./code/main/compute_abs_error.py", - "./code/main/abse_reg.py" + "/parse_GB_raw_data.py", + "/parse_SPF_raw_data.py", + "/scrape_FRED_data.py", + "/annual_forecasts.py", + "/compute_abs_error.py", + "/abse_reg.py" ] # Measure the start time @@ -22,7 +22,7 @@ # Run each Python script in the directory for python_file in files_to_run: if python_file != "reproduce.py": # Exclude the launcher script itself - subprocess.run(["python", python_file]) + subprocess.run(["python", current_directory + python_file]) end_time = time.time() diff --git a/code/main/scrape_FRED_data.py b/code/main/scrape_FRED_data.py index 59e41fa..f5ae697 100644 --- a/code/main/scrape_FRED_data.py +++ b/code/main/scrape_FRED_data.py @@ -2,6 +2,7 @@ import numpy as np import fredpy as fp import matplotlib.pyplot as plt +import os fp.api_key = "c735c085b4e162a17326871bc1d5c625" win = ['01-01-1982','12-01-2017'] @@ -29,6 +30,10 @@ for column in obs_df.columns[1:]: obs_df[column] = obs_df[column].apply(lambda x: f"{x:.{decimal}f}") -obs_df.to_csv('data/output/FRED.csv') +current_directory = os.path.dirname(os.path.abspath(__file__)) +file_path = "/../data/output/FRED.csv" +obs_df.to_csv(current_directory + file_path) + +#obs_df.to_csv('data/output/FRED.csv') # obs_df.to_excel('data/output/FRED_scraped.xlsx', index=False) \ No newline at end of file diff --git a/results/abse_reg_1983.txt b/results/abse_reg_1983.txt index 678b87c..949b4ff 100644 --- a/results/abse_reg_1983.txt +++ b/results/abse_reg_1983.txt @@ -4,8 +4,8 @@ Regression Summary for GB_error_unemp: Dep. Variable: GB_error_unemp R-squared: 0.013 Model: OLS Adj. R-squared: 0.006 Method: Least Squares F-statistic: 1.760 -Date: Tue, 07 Nov 2023 Prob (F-statistic): 0.187 -Time: 09:53:44 Log-Likelihood: -118.32 +Date: Wed, 21 Feb 2024 Prob (F-statistic): 0.187 +Time: 08:35:09 Log-Likelihood: -118.32 No. Observations: 144 AIC: 240.6 Df Residuals: 142 BIC: 246.6 Df Model: 1 @@ -32,8 +32,8 @@ Regression Summary for SPF_error_unemp: Dep. Variable: SPF_error_unemp R-squared: 0.005 Model: OLS Adj. R-squared: -0.002 Method: Least Squares F-statistic: 0.6700 -Date: Tue, 07 Nov 2023 Prob (F-statistic): 0.414 -Time: 09:53:44 Log-Likelihood: -125.71 +Date: Wed, 21 Feb 2024 Prob (F-statistic): 0.414 +Time: 08:35:09 Log-Likelihood: -125.71 No. Observations: 144 AIC: 255.4 Df Residuals: 142 BIC: 261.4 Df Model: 1 @@ -60,8 +60,8 @@ Regression Summary for GB_error_cons: Dep. Variable: GB_error_cons R-squared: 0.219 Model: OLS Adj. R-squared: 0.214 Method: Least Squares F-statistic: 30.02 -Date: Tue, 07 Nov 2023 Prob (F-statistic): 1.89e-07 -Time: 09:53:44 Log-Likelihood: -166.53 +Date: Wed, 21 Feb 2024 Prob (F-statistic): 1.89e-07 +Time: 08:35:10 Log-Likelihood: -166.53 No. Observations: 144 AIC: 337.1 Df Residuals: 142 BIC: 343.0 Df Model: 1 @@ -88,8 +88,8 @@ Regression Summary for SPF_error_cons: Dep. Variable: SPF_error_cons R-squared: 0.133 Model: OLS Adj. R-squared: 0.127 Method: Least Squares F-statistic: 26.15 -Date: Tue, 07 Nov 2023 Prob (F-statistic): 1.01e-06 -Time: 09:53:44 Log-Likelihood: -177.99 +Date: Wed, 21 Feb 2024 Prob (F-statistic): 1.01e-06 +Time: 08:35:10 Log-Likelihood: -177.99 No. Observations: 144 AIC: 360.0 Df Residuals: 142 BIC: 365.9 Df Model: 1