Skip to content

Commit

Permalink
Push fix for adjust_pandemic_response
Browse files Browse the repository at this point in the history
Add poetry dependency for SCM and move SCM to root
  • Loading branch information
jvivian committed Dec 3, 2023
1 parent d6cb8c5 commit 019f787
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 9 deletions.
5 changes: 3 additions & 2 deletions covid19_drdfm/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This model input DataFrame can be generated with a single function:
- `df = run()`
"""
import json

from fractions import Fraction
from functools import reduce
from pathlib import Path
Expand Down Expand Up @@ -105,7 +105,8 @@ def adjust_pandemic_response(df: pd.DataFrame) -> pd.DataFrame:
pd.DataFrame: Adjusted DataFrame
"""
govt_fund_dist = get_govt_fund_dist()
responses = [f"Pandemic_Response_{x}" for x in [13, 14, 15]]
# responses = [f"Pandemic_Response_{x}" for x in [13, 14, 15]]
responses = ["ARP", "PPP", "CARES"]
for r in responses:
df[r] = df[r].astype(float)
i = df.index[df[r] > 0][0]
Expand Down
17 changes: 11 additions & 6 deletions scm.py → covid19_drdfm/scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@

from SyntheticControlMethods import Synth, DiffSynth

#Import data
# Import data
data_dir = "https://raw.githubusercontent.com/OscarEngelbrektson/SyntheticControlMethods/master/examples/datasets/"
df = pd.read_csv(data_dir + "smoking_data" + ".csv")

from os import rename
#Fit Differenced Synthetic Control
df = df.rename(columns={'cigsale': 'Pandemic'})

# Fit Differenced Synthetic Control
df = df.rename(columns={"cigsale": "Pandemic"})
sc = Synth(df, "Pandemic", "state", "year", 1989, "California", n_optim=10, pen="auto")

print(sc.original_data.weight_df)
print(sc.original_data.comparison_df)
print(sc.original_data.pen)

#Visualize
sc.plot(["original", "pointwise", "cumulative"], treated_label="California",
synth_label="Synthetic California", treatment_label="Pandemic Response")
# Visualize
sc.plot(
["original", "pointwise", "cumulative"],
treated_label="California",
synth_label="Synthetic California",
treatment_label="Pandemic Response",
)
Loading

0 comments on commit 019f787

Please sign in to comment.