Skip to content

Commit

Permalink
Merge pull request dedwar65#6 from econ-ark/main
Browse files Browse the repository at this point in the history
update reproduce.sh
  • Loading branch information
dedwar65 authored Feb 21, 2024
2 parents bae8fe8 + 8043abe commit b27c9b5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 36 deletions.
9 changes: 5 additions & 4 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- python=3.9
- ipywidgets
- jupyter
- jupyterlab
- matplotlib
- numpy
Expand All @@ -13,8 +14,8 @@ dependencies:
- lxml
- requests
- statsmodels
- pip
- pip:
- pandas-datareader
- fredpy
- statsmodels

- pandas-datareader
- fredpy
- statsmodels
7 changes: 1 addition & 6 deletions code/main/parse_GB_raw_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pandas as pd
import os

# Load the Excel file
excel_file = pd.ExcelFile('data/raw/GBweb_Row_Format.xlsx')
Expand Down Expand Up @@ -81,10 +80,6 @@
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)
7 changes: 1 addition & 6 deletions code/main/parse_SPF_raw_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pandas as pd
import os

# Load the Excel file with levels first
excel_file = pd.ExcelFile('data/raw/meanLevel.xlsx')
Expand Down Expand Up @@ -69,10 +68,6 @@
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)
14 changes: 7 additions & 7 deletions code/main/reproduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

# List all files in the current directory
files_to_run = [
"/parse_GB_raw_data.py",
"/parse_SPF_raw_data.py",
"/scrape_FRED_data.py",
"/annual_forecasts.py",
"/compute_abs_error.py",
"/abse_reg.py"
"./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"
]

# Measure the start time
Expand All @@ -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", current_directory + python_file])
subprocess.run(["python", python_file])

end_time = time.time()

Expand Down
7 changes: 1 addition & 6 deletions code/main/scrape_FRED_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
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']
Expand Down Expand Up @@ -30,10 +29,6 @@
for column in obs_df.columns[1:]:
obs_df[column] = obs_df[column].apply(lambda x: f"{x:.{decimal}f}")

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_csv('data/output/FRED.csv')

# obs_df.to_excel('data/output/FRED_scraped.xlsx', index=False)
2 changes: 1 addition & 1 deletion reproduce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
cd "$SCPT_DIR"

mamba env update -f binder/environment.yml
conda activate rs100_discussion
source activate rs100_discussion

ipython *.ipynb

Expand Down
12 changes: 6 additions & 6 deletions results/abse_reg_1983.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Dep. Variable: GB_error_unemp R-squared: 0.013
Model: OLS Adj. R-squared: 0.006
Method: Least Squares F-statistic: 1.760
Date: Wed, 21 Feb 2024 Prob (F-statistic): 0.187
Time: 08:35:09 Log-Likelihood: -118.32
Time: 10:04:35 Log-Likelihood: -118.32
No. Observations: 144 AIC: 240.6
Df Residuals: 142 BIC: 246.6
Df Model: 1
Expand All @@ -25,15 +25,15 @@ Kurtosis: 15.518 Cond. No. 10.4
Notes:
[1] Standard Errors are heteroscedasticity robust (HC3)
Mean Squared Error for GB_error_unemp: 0.3028
Durbin-Watson Statistic for GB_error_unemp: 0.4990387828073439
Durbin-Watson Statistic for GB_error_unemp: 0.4990387828073438
Regression Summary for SPF_error_unemp:
OLS Regression Results
==============================================================================
Dep. Variable: SPF_error_unemp R-squared: 0.005
Model: OLS Adj. R-squared: -0.002
Method: Least Squares F-statistic: 0.6700
Date: Wed, 21 Feb 2024 Prob (F-statistic): 0.414
Time: 08:35:09 Log-Likelihood: -125.71
Time: 10:04:35 Log-Likelihood: -125.71
No. Observations: 144 AIC: 255.4
Df Residuals: 142 BIC: 261.4
Df Model: 1
Expand All @@ -53,15 +53,15 @@ Kurtosis: 13.710 Cond. No. 10.4
Notes:
[1] Standard Errors are heteroscedasticity robust (HC3)
Mean Squared Error for SPF_error_unemp: 0.3356
Durbin-Watson Statistic for SPF_error_unemp: 0.380336402078763
Durbin-Watson Statistic for SPF_error_unemp: 0.3803364020787631
Regression Summary for GB_error_cons:
OLS Regression Results
==============================================================================
Dep. Variable: GB_error_cons R-squared: 0.219
Model: OLS Adj. R-squared: 0.214
Method: Least Squares F-statistic: 30.02
Date: Wed, 21 Feb 2024 Prob (F-statistic): 1.89e-07
Time: 08:35:10 Log-Likelihood: -166.53
Time: 10:04:35 Log-Likelihood: -166.53
No. Observations: 144 AIC: 337.1
Df Residuals: 142 BIC: 343.0
Df Model: 1
Expand Down Expand Up @@ -89,7 +89,7 @@ Dep. Variable: SPF_error_cons R-squared: 0.133
Model: OLS Adj. R-squared: 0.127
Method: Least Squares F-statistic: 26.15
Date: Wed, 21 Feb 2024 Prob (F-statistic): 1.01e-06
Time: 08:35:10 Log-Likelihood: -177.99
Time: 10:04:35 Log-Likelihood: -177.99
No. Observations: 144 AIC: 360.0
Df Residuals: 142 BIC: 365.9
Df Model: 1
Expand Down

0 comments on commit b27c9b5

Please sign in to comment.