def get_comparison(regressions, export: str = ""): """Compare regression results between Panel Data regressions. Parameters ---------- regressions : Dict Dictionary with regression results. export : str Format to export data Returns ------- Returns a PanelModelComparison which shows an overview of the different regression results. """ comparison = {} for regression_type, data in regressions.items(): if regression_type == "OLS": continue if data["model"]: comparison[regression_type] = data["model"] if not comparison: # When the dictionary is empty, it means no Panel regression # estimates are available and thus the function will have no output return console.print( "No Panel regression estimates available. Please use the " "command 'panel' before using this command.") comparison_result = compare(comparison) console.print(comparison_result) if export: results_as_html = comparison_result.summary.tables[0].as_html() df = pd.read_html(results_as_html, header=0, index_col=0)[0] export_data( export, os.path.dirname(os.path.abspath(__file__)), "regressions_compare", df, ) return comparison_result
def balancing_tests_cohort_results(df, exog): post_exposure1 = PanelOLS(df.adult, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton1 = post_exposure1.fit(cov_type='clustered', clusters=df.id_e, singletons=False) post_exposure2 = PanelOLS(df.below_median_age_restr, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton2 = post_exposure2.fit(cov_type='clustered', clusters=df.id_e, singletons=False) post_exposure3 = PanelOLS(df.sex_ratio, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton3 = post_exposure3.fit(cov_type='clustered', clusters=df.id_e, singletons=False) post_exposure4 = PanelOLS(df.have_adults_patch, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton4 = post_exposure4.fit(cov_type='clustered', clusters=df.id_e, singletons=False) return (compare( { 'Size of cohort': result_balancing_canton1, 'Below median age': result_balancing_canton2, 'Sex ratio': result_balancing_canton3, 'Have families': result_balancing_canton4 }, stars=True))
def balancing_tests_cantonal_results(df, exog): ##These are the conditional results ##between countries as= asylum seekers mod_balancing = PanelOLS(df.share_AS_between * 100, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton = mod_balancing.fit(cov_type='clustered', clusters=df.id_e, singletons=False) mod_balancing2 = PanelOLS(df.share_AS_within * 100, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton2 = mod_balancing2.fit(cov_type='clustered', clusters=df.id_e, singletons=False) mod_balancing3 = PanelOLS(df.sex_ratio_AS_ntc * 100, exog, entity_effects=True, time_effects=True, singletons=False) result_balancing_canton3 = mod_balancing3.fit(cov_type='clustered', clusters=df.id_e, singletons=False) return (compare( { 'Between countries': result_balancing_canton, 'Within countries': result_balancing_canton2, 'Sex ratio': result_balancing_canton3 }, stars=True))
# fix assetclasslevel3, cluster time + ticker mod = PanelOLS.from_formula( 'cd ~ 1 + cdlag1 + volume + pd + age + assetclasslevel3', data=test0) fit03 = mod.fit(cov_type='clustered', cluster_time=True, cluster_entity=True) # fix year, cluster time + ticker mod = PanelOLS.from_formula('cd ~ 1 + cdlag1 + volume + pd + TimeEffects', data=test0) fit04 = mod.fit(cov_type='clustered', cluster_time=True, cluster_entity=True) # Compare print( compare({ 'fixclass1': fit01, 'fixclass2': fit02, 'fixclass3': fit03, 'fixyear': fit04 })) # In[13]: # fix time, cluster time + ticker test1 = test.set_index(['ticker', 'year']) #entity and time multi-index mod = PanelOLS.from_formula('cd ~ 1 + cdlag1 + volume + pd + TimeEffects', data=test1) fit1 = mod.fit(cov_type='clustered', cluster_time=True, cluster_entity=True) # fix time + ticker, cluster time + ticker test2 = test.set_index(['ticker', 'year']) mod = PanelOLS.from_formula( 'cd ~ 1 + cdlag1 + volume + pd + EntityEffects + TimeEffects', data=test2)
# print(data1) d = pd.Categorical(data1['Date']) data1 = data1.set_index(['ID', 'Date']) data1['Date'] = d # print(data1) exog_vars = [ 'Kilo', 'Brakes', 'Range', 'Speed', 'RPM', 'Engine fuel rate', 'Date' ] a = ['Kilo', 'Brakes', 'Range', 'Speed', 'RPM', 'Engine fuel rate'] print(data1[a]) exog = sm.add_constant(data1[exog_vars]) exog1 = sm.add_constant(data1[a]) mod = PanelOLS(data1['Accelerator pedal position'], exog, entity_effects=True, time_effects=False) mod1 = PooledOLS(data1['Accelerator pedal position'], exog1) mod2 = RandomEffects(data1['Accelerator pedal position'], exog1) mod3 = BetweenOLS(data1['Accelerator pedal position'], exog1) res = mod.fit() pooled_res = mod1.fit() re_res = mod2.fit() be_res = mod3.fit() print(res) print(compare({'Pooled': pooled_res, 'RE': re_res, 'BE': be_res})) if __name__ == '__main__': pass
def baseline_results_women(df): CPRT_baseline_female = df.groupby(by=['sex']) CPRT_baseline_women = CPRT_baseline_female.get_group("F") CPRT_baseline_womenage = CPRT_baseline_women[~( CPRT_baseline_women['age'] <= 18)] mi_data_women = CPRT_baseline_womenage.set_index(["id_e_t", "id_a"]) exog_vars = [ "kid012_all", "all_exp_13", "all_exp_14", "all_exp_15", "all_exp_16", "all_exp_17", "all_exp_18", "all_exp_19", "all_exp_20", "all_exp_21", "all_exp_22", "all_exp_23", "all_exp_24", "all_exp_25", "all_exp_26", "all_exp_27", "all_exp_28", "all_exp_29", "all_exp_30", "all_exp_31", "all_exp_32", "all_exp_33", "all_exp_34", "all_exp_35", "all_exp_36", "all_exp_37", "all_exp_38", "all_exp_39", "all_exp_40", "all_exp_41", "all_exp_42", "all_exp_43", "all_exp_44", "all_exp_45", "all_exp_46", "all_exp_47", "all_exp_48", "all_exp_49", "all_exp_50", "all_exp_51", "all_exp_52", "all_exp_53", "all_exp_54", "all_exp_55", "all_exp_56", "all_exp_57", "all_exp_58", "all_exp_59", "all_exp_60", "all_exp_61", "all_exp_62", "all_exp_63", "all_exp_64", "all_exp_65", "all_exp_66", "all_exp_67", "all_exp_68", "all_exp_69", "all_exp_70" ] exog_women = sm.add_constant(mi_data_women[exog_vars]) CPRT_baseline_womenage.head() mod_women = PanelOLS(mi_data_women.crime_rate_all_violent_p30, exog_women, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=False) res_women = mod_women.fit(cov_type='clustered', cluster=mi_data_women.id_e, singletons=False) CPRT_baseline_womenage_sub = CPRT_baseline_womenage[( CPRT_baseline_womenage['allmk_periode'] == 1)] mi_data2_women = CPRT_baseline_womenage_sub.set_index(["id_a", "id_e_t"]) exog_vars2 = [ "kid012_all", "all_exp_13", "all_exp_14", "all_exp_15", "all_exp_16", "all_exp_17", "all_exp_18", "all_exp_19", "all_exp_20", "all_exp_21", "all_exp_22", "all_exp_23", "all_exp_24", "all_exp_25", "all_exp_26", "all_exp_27", "all_exp_28", "all_exp_29", "all_exp_30", "all_exp_31", "all_exp_32", "all_exp_33", "all_exp_34", "all_exp_35", "all_exp_36", "all_exp_37", "all_exp_38", "all_exp_39", "all_exp_40", "all_exp_41", "all_exp_42", "all_exp_43", "all_exp_44", "all_exp_45", "all_exp_46", "all_exp_47", "all_exp_48", "all_exp_49", "all_exp_50", "all_exp_51", "all_exp_52", "all_exp_53", "all_exp_54", "all_exp_55", "all_exp_56", "all_exp_57", "all_exp_58", "all_exp_59", "all_exp_60", "all_exp_61", "all_exp_62", "all_exp_63", "all_exp_64", "all_exp_65", "all_exp_66", "all_exp_67", "all_exp_68", "all_exp_69", "all_exp_70", "all_exp_71" ] exog2_women = sm.add_constant(mi_data2_women[exog_vars2]) mod2_women = PanelOLS(mi_data2_women.crime_rate_all_violent_p30, exog2_women, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=False) res2_women = mod2_women.fit(cov_type='clustered', cluster=mi_data2_women["id_e"], singletons=False) CPRT_baseline_womenage_sub_sub = CPRT_baseline_womenage[( CPRT_baseline_womenage['all_periode'] == 1)] mi_data3_women = CPRT_baseline_womenage_sub_sub.set_index( ["id_a", "id_e_t"]) exog_vars3 = [ "kid012", "exp_all_13", "exp_all_14", "exp_all_15", "exp_all_16", "exp_all_17", "exp_all_18", "exp_all_19", "exp_all_20", "exp_all_21", "exp_all_22", "exp_all_23", "exp_all_24", "exp_all_25", "exp_all_26", "exp_all_27", "exp_all_28", "exp_all_29", "exp_all_30", "exp_all_31", "exp_all_32", "exp_all_33", "exp_all_34", "exp_all_35", "exp_all_36", "exp_all_37", "exp_all_38", "exp_all_39", "exp_all_40", "exp_all_41", "exp_all_42", "exp_all_43", "exp_all_44", "exp_all_45", "exp_all_46", "exp_all_47", "exp_all_48", "exp_all_49", "exp_all_50", "exp_all_51", "exp_all_52", "exp_all_53", "exp_all_54", "exp_all_55", "exp_all_56", "exp_all_57", "exp_all_58", "exp_all_59", "exp_all_60", "exp_all_61", "exp_all_62", "exp_all_63", "exp_all_64", "exp_all_65", "exp_all_66", "exp_all_67", "exp_all_68", "exp_all_69", "exp_all_70", "exp_all_71" ] exog3_women = sm.add_constant(mi_data3_women[exog_vars3]) mod3_women = PanelOLS(mi_data3_women.crime_rate_all_violent_p30, exog3_women, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=False) res3_women = mod3_women.fit(cov_type='clustered', cluster=mi_data3_women["id_e"], singletons=False) ##Table 5 column 4 women CPRT_baseline_womenage_sub4 = CPRT_baseline_womenage[( CPRT_baseline_womenage['mk_periode'] == 1)] mi_data4_women = CPRT_baseline_womenage_sub4.set_index(["id_a", "id_e_t"]) ##had to delete nr. 71-86 exog_vars4 = [ "MK_kid012", "exp_mk_13", "exp_mk_14", "exp_mk_15", "exp_mk_16", "exp_mk_17", "exp_mk_18", "exp_mk_19", "exp_mk_20", "exp_mk_21", "exp_mk_22", "exp_mk_23", "exp_mk_24", "exp_mk_25", "exp_mk_26", "exp_mk_27", "exp_mk_28", "exp_mk_29", "exp_mk_30", "exp_mk_31", "exp_mk_32", "exp_mk_33", "exp_mk_34", "exp_mk_35", "exp_mk_36", "exp_mk_37", "exp_mk_38", "exp_mk_39", "exp_mk_40", "exp_mk_41", "exp_mk_42", "exp_mk_43", "exp_mk_44", "exp_mk_45", "exp_mk_46", "exp_mk_47", "exp_mk_48", "exp_mk_49", "exp_mk_50", "exp_mk_51", "exp_mk_52", "exp_mk_53", "exp_mk_54", "exp_mk_55", "exp_mk_56", "exp_mk_57", "exp_mk_58", "exp_mk_59", "exp_mk_60", "exp_mk_61", "exp_mk_62", "exp_mk_63", "exp_mk_64", "exp_mk_65", "exp_mk_66", "exp_mk_67", "exp_mk_68", "exp_mk_69", "exp_mk_70" ] exog4_women = sm.add_constant(mi_data4_women[exog_vars4]) mod4_women = PanelOLS(mi_data4_women.crime_rate_all_violent_p30, exog4_women, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=False) res4_women = mod4_women.fit(cov_type='clustered', cluster=CPRT_baseline_womenage_sub["id_e"], singletons=False) return (compare( { 'Full': res_women, 'CC and MK': res2_women, 'CC': res3_women, 'MK': res4_women }, stars=True))
def crime_by_type(df): mi_data = df.set_index(["id_e_t", "id_a"]) exog_vars = [ "kid012_all", "all_exp_13", "all_exp_14", "all_exp_15", "all_exp_16", "all_exp_17", "all_exp_18", "all_exp_19", "all_exp_20", "all_exp_21", "all_exp_22", "all_exp_23", "all_exp_24", "all_exp_25", "all_exp_26", "all_exp_27", "all_exp_28", "all_exp_29", "all_exp_30", "all_exp_31", "all_exp_32", "all_exp_33", "all_exp_34", "all_exp_35", "all_exp_36", "all_exp_37", "all_exp_38", "all_exp_39", "all_exp_40", "all_exp_41", "all_exp_42", "all_exp_43", "all_exp_44", "all_exp_45", "all_exp_46", "all_exp_47", "all_exp_48", "all_exp_49", "all_exp_50", "all_exp_51", "all_exp_52", "all_exp_53", "all_exp_54", "all_exp_55", "all_exp_56", "all_exp_57", "all_exp_58", "all_exp_59", "all_exp_60", "all_exp_61", "all_exp_62", "all_exp_63", "all_exp_64", "all_exp_65", "all_exp_66", "all_exp_67", "all_exp_68", "all_exp_69", "all_exp_70", "all_exp_71", "all_exp_72", "all_exp_73", "all_exp_74", "all_exp_75", "all_exp_76", "all_exp_77", "all_exp_78", "all_exp_79", "all_exp_80", "all_exp_81", "all_exp_82", "all_exp_83", "all_exp_84", "all_exp_85", "all_exp_86" ] exog_baseline_type = sm.add_constant(mi_data[exog_vars]) result_6_1 = PanelOLS(mi_data.crime_rate_violent_p30, exog_baseline_type, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=True) res_6_violent = result_6_1.fit(cov_type='clustered', cluster=mi_data["id_e"]) result_6_2 = PanelOLS(mi_data.crime_rate_freedom_p30, exog_baseline_type, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=True) res_6_freedom = result_6_2.fit(cov_type='clustered', cluster=mi_data["id_e"]) result_6_3 = PanelOLS(mi_data.crime_rate_sexual_p30, exog_baseline_type, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=True) res_6_sexual = result_6_3.fit(cov_type='clustered', cluster=mi_data["id_e"]) result_6_4 = PanelOLS(mi_data.crime_rate_property_p30, exog_baseline_type, entity_effects=True, time_effects=True, drop_absorbed=True, singletons=True) res_6_property = result_6_4.fit(cov_type='clustered', cluster=mi_data["id_e"]) return (compare( { 'violent': res_6_violent, 'freedom': res_6_freedom, 'sexual': res_6_sexual, 'property': res_6_property }, stars=True))
def baseline_results(df): ##first column of baseline mi_data = df.set_index(["id_e_t", "id_a"]) exog_vars = [ "kid012_all", "all_exp_13", "all_exp_14", "all_exp_15", "all_exp_16", "all_exp_17", "all_exp_18", "all_exp_19", "all_exp_20", "all_exp_21", "all_exp_22", "all_exp_23", "all_exp_24", "all_exp_25", "all_exp_26", "all_exp_27", "all_exp_28", "all_exp_29", "all_exp_30", "all_exp_31", "all_exp_32", "all_exp_33", "all_exp_34", "all_exp_35", "all_exp_36", "all_exp_37", "all_exp_38", "all_exp_39", "all_exp_40", "all_exp_41", "all_exp_42", "all_exp_43", "all_exp_44", "all_exp_45", "all_exp_46", "all_exp_47", "all_exp_48", "all_exp_49", "all_exp_50", "all_exp_51", "all_exp_52", "all_exp_53", "all_exp_54", "all_exp_55", "all_exp_56", "all_exp_57", "all_exp_58", "all_exp_59", "all_exp_60", "all_exp_61", "all_exp_62", "all_exp_63", "all_exp_64", "all_exp_65", "all_exp_66", "all_exp_67", "all_exp_68", "all_exp_69", "all_exp_70", "all_exp_71", "all_exp_72", "all_exp_73", "all_exp_74", "all_exp_75", "all_exp_76", "all_exp_77", "all_exp_78", "all_exp_79", "all_exp_80", "all_exp_81", "all_exp_82", "all_exp_83", "all_exp_84", "all_exp_85", "all_exp_86" ] exog_baseline = sm.add_constant(mi_data[exog_vars]) mod = PanelOLS(mi_data.crime_rate_all_violent_p30, exog_baseline, entity_effects=True, time_effects=True, singletons=False) res = mod.fit(cov_type='clustered', clusters=mi_data.id_e, singletons=False) ##second column of baseline results CPRT_baseline_maleage_sub = df[(df['allmk_periode'] == 1)] mi_data2 = CPRT_baseline_maleage_sub.set_index(["id_a", "id_e_t"]) exog_vars2 = [ "kid012_all", "all_exp_13", "all_exp_14", "all_exp_15", "all_exp_16", "all_exp_17", "all_exp_18", "all_exp_19", "all_exp_20", "all_exp_21", "all_exp_22", "all_exp_23", "all_exp_24", "all_exp_25", "all_exp_26", "all_exp_27", "all_exp_28", "all_exp_29", "all_exp_30", "all_exp_31", "all_exp_32", "all_exp_33", "all_exp_34", "all_exp_35", "all_exp_36", "all_exp_37", "all_exp_38", "all_exp_39", "all_exp_40", "all_exp_41", "all_exp_42", "all_exp_43", "all_exp_44", "all_exp_45", "all_exp_46", "all_exp_47", "all_exp_48", "all_exp_49", "all_exp_50", "all_exp_51", "all_exp_52", "all_exp_53", "all_exp_54", "all_exp_55", "all_exp_56", "all_exp_57", "all_exp_58", "all_exp_59", "all_exp_60", "all_exp_61", "all_exp_62", "all_exp_63", "all_exp_64", "all_exp_65", "all_exp_66", "all_exp_67", "all_exp_68", "all_exp_69", "all_exp_70", "all_exp_71", "all_exp_72", "all_exp_73", "all_exp_74", "all_exp_75", "all_exp_76", "all_exp_77", "all_exp_78", "all_exp_79", "all_exp_80", "all_exp_81", "all_exp_82", "all_exp_83", "all_exp_84", "all_exp_85", "all_exp_86" ] exog2 = sm.add_constant(mi_data2[exog_vars2]) mod2 = PanelOLS(mi_data2.crime_rate_all_violent_p30, exog2, entity_effects=True, time_effects=True, singletons=False) res2 = mod2.fit(cov_type='clustered', clusters=mi_data2.id_e, singletons=False) ##third column of baseline results CPRT_baseline_maleage_sub_sub = df[(df['all_periode'] == 1)] CPRT_baseline_maleage_sub_sub = CPRT_baseline_maleage_sub_sub.drop( ['kid012_all'], axis=1) CPRT_baseline_maleage_sub_sub = CPRT_baseline_maleage_sub_sub.rename( columns={"kid012": "kid012_all"}) mi_data3 = CPRT_baseline_maleage_sub_sub.set_index(["id_a", "id_e_t"]) exog_vars3 = [ "kid012_all", "exp_all_13", "exp_all_14", "exp_all_15", "exp_all_16", "exp_all_17", "exp_all_18", "exp_all_19", "exp_all_20", "exp_all_21", "exp_all_22", "exp_all_23", "exp_all_24", "exp_all_25", "exp_all_26", "exp_all_27", "exp_all_28", "exp_all_29", "exp_all_30", "exp_all_31", "exp_all_32", "exp_all_33", "exp_all_34", "exp_all_35", "exp_all_36", "exp_all_37", "exp_all_38", "exp_all_39", "exp_all_40", "exp_all_41", "exp_all_42", "exp_all_43", "exp_all_44", "exp_all_45", "exp_all_46", "exp_all_47", "exp_all_48", "exp_all_49", "exp_all_50", "exp_all_51", "exp_all_52", "exp_all_53", "exp_all_54", "exp_all_55", "exp_all_56", "exp_all_57", "exp_all_58", "exp_all_59", "exp_all_60", "exp_all_61", "exp_all_62", "exp_all_63", "exp_all_64", "exp_all_65", "exp_all_66", "exp_all_67", "exp_all_68", "exp_all_69", "exp_all_70", "exp_all_71", "exp_all_72", "exp_all_73", "exp_all_74", "exp_all_75", "exp_all_76", "exp_all_77", "exp_all_78", "exp_all_79", "exp_all_80", "exp_all_81", "exp_all_82", "exp_all_83", "exp_all_84", "exp_all_85", "exp_all_86" ] exog3 = sm.add_constant(mi_data3[exog_vars3]) mod3 = PanelOLS(mi_data3.crime_rate_all_violent_p30, exog3, entity_effects=True, time_effects=True, singletons=False) res3 = mod3.fit(cov_type='clustered', clusters=mi_data3.id_e, singletons=False) ##4th column CPRT_baseline_maleage_sub4 = df[(df['mk_periode'] == 1)] mi_data4 = CPRT_baseline_maleage_sub4.set_index(["id_a", "id_e_t"]) exog_vars4 = [ "MK_kid012", "exp_mk_13", "exp_mk_14", "exp_mk_15", "exp_mk_16", "exp_mk_17", "exp_mk_18", "exp_mk_19", "exp_mk_20", "exp_mk_21", "exp_mk_22", "exp_mk_23", "exp_mk_24", "exp_mk_25", "exp_mk_26", "exp_mk_27", "exp_mk_28", "exp_mk_29", "exp_mk_30", "exp_mk_31", "exp_mk_32", "exp_mk_33", "exp_mk_34", "exp_mk_35", "exp_mk_36", "exp_mk_37", "exp_mk_38", "exp_mk_39", "exp_mk_40", "exp_mk_41", "exp_mk_42", "exp_mk_43", "exp_mk_44", "exp_mk_45", "exp_mk_46", "exp_mk_47", "exp_mk_48", "exp_mk_49", "exp_mk_50", "exp_mk_51", "exp_mk_52", "exp_mk_53", "exp_mk_54", "exp_mk_55", "exp_mk_56", "exp_mk_57", "exp_mk_58", "exp_mk_59", "exp_mk_60", "exp_mk_61", "exp_mk_62", "exp_mk_63", "exp_mk_64", "exp_mk_65", "exp_mk_66", "exp_mk_67", "exp_mk_68", "exp_mk_69", "exp_mk_70", "exp_mk_71", "exp_mk_72", "exp_mk_73", "exp_mk_74", "exp_mk_75", "exp_mk_76", "exp_mk_77", "exp_mk_78", "exp_mk_79", "exp_mk_80", "exp_mk_81", "exp_mk_82", "exp_mk_83" ] exp_mk4 = [ "exp_mk_13", "exp_mk_14", "exp_mk_15", "exp_mk_16", "exp_mk_17", "exp_mk_18", "exp_mk_19", "exp_mk_20", "exp_mk_21", "exp_mk_22", "exp_mk_23", "exp_mk_24", "exp_mk_25", "exp_mk_26", "exp_mk_27", "exp_mk_28", "exp_mk_29", "exp_mk_30", "exp_mk_31", "exp_mk_32", "exp_mk_33", "exp_mk_34", "exp_mk_35", "exp_mk_36", "exp_mk_37", "exp_mk_38", "exp_mk_39", "exp_mk_40", "exp_mk_41", "exp_mk_42", "exp_mk_43", "exp_mk_44", "exp_mk_45", "exp_mk_46", "exp_mk_47", "exp_mk_48", "exp_mk_49", "exp_mk_50", "exp_mk_51", "exp_mk_52", "exp_mk_53", "exp_mk_54", "exp_mk_55", "exp_mk_56", "exp_mk_57", "exp_mk_58", "exp_mk_59", "exp_mk_60", "exp_mk_61", "exp_mk_62", "exp_mk_63", "exp_mk_64", "exp_mk_65", "exp_mk_66", "exp_mk_67", "exp_mk_68", "exp_mk_69", "exp_mk_70", "exp_mk_71", "exp_mk_72", "exp_mk_73", "exp_mk_74", "exp_mk_75", "exp_mk_76", "exp_mk_77", "exp_mk_78", "exp_mk_79", "exp_mk_80", "exp_mk_81", "exp_mk_82", "exp_mk_83", "exp_mk_84", "exp_mk_85", "exp_mk_86", "exp_mk_87", "exp_mk_88", "exp_mk_89", "exp_mk_90", "exp_mk_91", "exp_mk_92", "exp_mk_93", "exp_mk_94", "exp_mk_95", "exp_mk_96", "exp_mk_97", "exp_mk_98", "exp_mk_99" ] exog4 = sm.add_constant(mi_data4[exog_vars4]) mod4 = PanelOLS(mi_data4.crime_rate_all_violent_p30, exog4, entity_effects=True, time_effects=True, singletons=False) res4 = mod4.fit(cov_type='clustered', clusters=mi_data4.id_e, singletons=False) ##presentation return (compare({ 'Full': res, 'CC and MK': res2, 'CC': res3, 'MK': res4 }, stars=True))