13
13
from causal_testing .testing .estimators import LinearRegressionEstimator
14
14
from matplotlib .pyplot import rcParams
15
15
16
- # Make all graphs publication quality
17
- plt .rcParams ["figure.figsize" ] = (8 , 8 )
18
- rc_fonts = {
19
- "font.size" : 8 ,
20
- "figure.figsize" : (10 , 6 ),
21
- "text.usetex" : True ,
22
- "font.family" : "serif" ,
23
- "text.latex.preamble" : r"\usepackage{libertine}" ,
24
- }
25
- rcParams .update (rc_fonts )
16
+ # Uncommenting the code below will make all graphs publication quality but requires a suitable latex installation
26
17
27
- OBSERVATIONAL_DATA_PATH = "./data/10k_observational_data.csv"
18
+ # plt.rcParams["figure.figsize"] = (8, 8)
19
+ # rc_fonts = {
20
+ # "font.size": 8,
21
+ # "figure.figsize": (10, 6),
22
+ # "text.usetex": True,
23
+ # "font.family": "serif",
24
+ # "text.latex.preamble": r"\usepackage{libertine}",
25
+ # }
26
+ # rcParams.update(rc_fonts)
27
+
28
+ OBSERVATIONAL_DATA_PATH = "data/10k_observational_data.csv"
28
29
29
30
30
31
def doubling_beta_CATE_on_csv (observational_data_path : str , simulate_counterfactuals : bool = False ,
@@ -121,13 +122,13 @@ def doubling_beta_CATEs(observational_data_path: str, simulate_counterfactual: b
121
122
122
123
# Split df into two age ranges
123
124
younger_population_df = past_execution_df .loc [past_execution_df ['avg_age' ] <= mid_age ]
124
- younger_population_df .to_csv ("./data/bessemer/ younger_population.csv" )
125
+ younger_population_df .to_csv ("./data/younger_population.csv" )
125
126
older_population_df = past_execution_df .loc [past_execution_df ['avg_age' ] > mid_age ]
126
- older_population_df .to_csv ("./data/bessemer/ older_population.csv" )
127
+ older_population_df .to_csv ("./data/older_population.csv" )
127
128
128
129
# Repeat analysis on age-specific strata
129
- separated_observational_data_paths = ["./data/bessemer/ younger_population.csv" ,
130
- "./data/bessemer/ older_population.csv" ]
130
+ separated_observational_data_paths = ["./data/younger_population.csv" ,
131
+ "./data/older_population.csv" ]
131
132
132
133
for col , separated_observational_data_path in enumerate (separated_observational_data_paths ):
133
134
age_data_results_dict = doubling_beta_CATE_on_csv (separated_observational_data_path , simulate_counterfactual ,
@@ -146,13 +147,13 @@ def doubling_beta_CATEs(observational_data_path: str, simulate_counterfactual: b
146
147
147
148
# Save dfs to csv
148
149
low_contacts_df = age_stratified_df .loc [age_stratified_df ['contacts' ] <= mid_contacts ]
149
- low_contacts_df .to_csv (f"./data/bessemer/ low_contacts_avg_age_{ age_stratified_df_avg_age } .csv" )
150
+ low_contacts_df .to_csv (f"./data/low_contacts_avg_age_{ age_stratified_df_avg_age } .csv" )
150
151
high_contacts_df = age_stratified_df .loc [age_stratified_df ['contacts' ] > mid_contacts ]
151
- high_contacts_df .to_csv (f"./data/bessemer/ high_contacts_avg_age_{ age_stratified_df_avg_age } .csv" )
152
+ high_contacts_df .to_csv (f"./data/high_contacts_avg_age_{ age_stratified_df_avg_age } .csv" )
152
153
153
- contact_observational_data_paths = [f"./data/bessemer/ low_contacts_avg_age_"
154
+ contact_observational_data_paths = [f"./data/low_contacts_avg_age_"
154
155
f"{ age_stratified_df_avg_age } .csv" ,
155
- f"./data/bessemer/ high_contacts_avg_age_"
156
+ f"./data/high_contacts_avg_age_"
156
157
f"{ age_stratified_df_avg_age } .csv" ]
157
158
158
159
# Compute the CATE for each age-contact group
@@ -181,7 +182,7 @@ def doubling_beta_CATEs(observational_data_path: str, simulate_counterfactual: b
181
182
182
183
def identification (observational_data_path ):
183
184
# 1. Read in the Causal DAG
184
- causal_dag = CausalDAG ('./ dag.dot' )
185
+ causal_dag = CausalDAG ('dag.dot' )
185
186
186
187
# 2. Create variables
187
188
pop_size = Input ('pop_size' , int )
0 commit comments