aigroup-econ-mcp 1.4.3__py3-none-any.whl → 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PKG-INFO +344 -322
- README.md +335 -320
- __init__.py +1 -1
- aigroup_econ_mcp-2.0.1.dist-info/METADATA +732 -0
- aigroup_econ_mcp-2.0.1.dist-info/RECORD +170 -0
- cli.py +4 -0
- econometrics/advanced_methods/modern_computing_machine_learning/__init__.py +30 -0
- econometrics/advanced_methods/modern_computing_machine_learning/causal_forest.py +253 -0
- econometrics/advanced_methods/modern_computing_machine_learning/double_ml.py +268 -0
- econometrics/advanced_methods/modern_computing_machine_learning/gradient_boosting.py +249 -0
- econometrics/advanced_methods/modern_computing_machine_learning/hierarchical_clustering.py +243 -0
- econometrics/advanced_methods/modern_computing_machine_learning/kmeans_clustering.py +293 -0
- econometrics/advanced_methods/modern_computing_machine_learning/neural_network.py +264 -0
- econometrics/advanced_methods/modern_computing_machine_learning/random_forest.py +195 -0
- econometrics/advanced_methods/modern_computing_machine_learning/support_vector_machine.py +226 -0
- econometrics/advanced_methods/modern_computing_machine_learning/test_all_modules.py +329 -0
- econometrics/advanced_methods/modern_computing_machine_learning/test_report.md +107 -0
- econometrics/causal_inference/__init__.py +66 -0
- econometrics/causal_inference/causal_identification_strategy/__init__.py +104 -0
- econometrics/causal_inference/causal_identification_strategy/control_function.py +112 -0
- econometrics/causal_inference/causal_identification_strategy/difference_in_differences.py +107 -0
- econometrics/causal_inference/causal_identification_strategy/event_study.py +119 -0
- econometrics/causal_inference/causal_identification_strategy/first_difference.py +89 -0
- econometrics/causal_inference/causal_identification_strategy/fixed_effects.py +103 -0
- econometrics/causal_inference/causal_identification_strategy/hausman_test.py +69 -0
- econometrics/causal_inference/causal_identification_strategy/instrumental_variables.py +145 -0
- econometrics/causal_inference/causal_identification_strategy/mediation_analysis.py +121 -0
- econometrics/causal_inference/causal_identification_strategy/moderation_analysis.py +109 -0
- econometrics/causal_inference/causal_identification_strategy/propensity_score_matching.py +140 -0
- econometrics/causal_inference/causal_identification_strategy/random_effects.py +100 -0
- econometrics/causal_inference/causal_identification_strategy/regression_discontinuity.py +98 -0
- econometrics/causal_inference/causal_identification_strategy/synthetic_control.py +111 -0
- econometrics/causal_inference/causal_identification_strategy/triple_difference.py +86 -0
- econometrics/distribution_analysis/__init__.py +28 -0
- econometrics/distribution_analysis/oaxaca_blinder.py +184 -0
- econometrics/distribution_analysis/time_series_decomposition.py +152 -0
- econometrics/distribution_analysis/variance_decomposition.py +179 -0
- econometrics/missing_data/__init__.py +18 -0
- econometrics/missing_data/imputation_methods.py +219 -0
- econometrics/nonparametric/__init__.py +35 -0
- econometrics/nonparametric/gam_model.py +117 -0
- econometrics/nonparametric/kernel_regression.py +161 -0
- econometrics/nonparametric/quantile_regression.py +249 -0
- econometrics/nonparametric/spline_regression.py +100 -0
- econometrics/spatial_econometrics/__init__.py +68 -0
- econometrics/spatial_econometrics/geographically_weighted_regression.py +211 -0
- econometrics/spatial_econometrics/gwr_simple.py +154 -0
- econometrics/spatial_econometrics/spatial_autocorrelation.py +356 -0
- econometrics/spatial_econometrics/spatial_durbin_model.py +177 -0
- econometrics/spatial_econometrics/spatial_regression.py +315 -0
- econometrics/spatial_econometrics/spatial_weights.py +226 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/README.md +164 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/__init__.py +40 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/count_data_models.py +311 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/discrete_choice_models.py +294 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/limited_dependent_variable_models.py +282 -0
- econometrics/statistical_inference/__init__.py +21 -0
- econometrics/statistical_inference/bootstrap_methods.py +162 -0
- econometrics/statistical_inference/permutation_test.py +177 -0
- econometrics/survival_analysis/__init__.py +18 -0
- econometrics/survival_analysis/survival_models.py +259 -0
- econometrics/tests/causal_inference_tests/__init__.py +3 -0
- econometrics/tests/causal_inference_tests/detailed_test.py +441 -0
- econometrics/tests/causal_inference_tests/test_all_methods.py +418 -0
- econometrics/tests/causal_inference_tests/test_causal_identification_strategy.py +202 -0
- econometrics/tests/causal_inference_tests/test_difference_in_differences.py +53 -0
- econometrics/tests/causal_inference_tests/test_instrumental_variables.py +44 -0
- econometrics/tests/specific_data_modeling_tests/test_micro_discrete_limited_data.py +189 -0
- econometrics//321/206/320/254/320/272/321/205/342/225/235/320/220/321/205/320/237/320/241/321/205/320/264/320/267/321/207/342/226/222/342/225/227/321/204/342/225/235/320/250/321/205/320/225/320/230/321/207/342/225/221/320/267/321/205/320/230/320/226/321/206/320/256/320/240.md +544 -0
- pyproject.toml +9 -2
- server.py +15 -1
- tools/__init__.py +75 -1
- tools/causal_inference_adapter.py +658 -0
- tools/distribution_analysis_adapter.py +121 -0
- tools/gwr_simple_adapter.py +54 -0
- tools/machine_learning_adapter.py +567 -0
- tools/mcp_tool_groups/__init__.py +15 -1
- tools/mcp_tool_groups/causal_inference_tools.py +643 -0
- tools/mcp_tool_groups/distribution_analysis_tools.py +169 -0
- tools/mcp_tool_groups/machine_learning_tools.py +422 -0
- tools/mcp_tool_groups/microecon_tools.py +325 -0
- tools/mcp_tool_groups/missing_data_tools.py +117 -0
- tools/mcp_tool_groups/nonparametric_tools.py +225 -0
- tools/mcp_tool_groups/spatial_econometrics_tools.py +323 -0
- tools/mcp_tool_groups/statistical_inference_tools.py +131 -0
- tools/mcp_tools_registry.py +13 -3
- tools/microecon_adapter.py +412 -0
- tools/missing_data_adapter.py +73 -0
- tools/nonparametric_adapter.py +190 -0
- tools/spatial_econometrics_adapter.py +318 -0
- tools/statistical_inference_adapter.py +90 -0
- tools/survival_analysis_adapter.py +46 -0
- aigroup_econ_mcp-1.4.3.dist-info/METADATA +0 -710
- aigroup_econ_mcp-1.4.3.dist-info/RECORD +0 -92
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/WHEEL +0 -0
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/entry_points.txt +0 -0
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
./.gitignore,sha256=M67x66mQGPjpk5A6LO93G9R7cY9vWCQH9sdLFt6S53c,3284
|
|
2
|
+
./LICENSE,sha256=DoyCJUWlDzKbqc5KRbFpsGYLwLh-XJRHKQDoITjb1yc,1083
|
|
3
|
+
./PKG-INFO,sha256=gQ902Sju8YC3j9r70FnKd_d8v4K9ozzNI2uIKJa0OjE,28759
|
|
4
|
+
./README.md,sha256=fKp95G5hpoun6WGp5SjJ0BeiyKhH60KpX4wTWStnfpg,27591
|
|
5
|
+
./__init__.py,sha256=G_4YjKvO9KBXASCjbEqVj8QNlUSeDfeU3ki4bVhA1Ew,282
|
|
6
|
+
./cli.py,sha256=VylCwO9YMkMU36SEPzzrEEu7UaEw3IdqPdkfCE8DrzQ,788
|
|
7
|
+
./pyproject.toml,sha256=tbHsYWk5y6Rujhl4h6xVbs4-IkRMhzCSotqt0q9cI1s,2237
|
|
8
|
+
./server.py,sha256=U9eFmkrV9xnUh3OAzC99cukmpjw28TqU5PTI-5KX9Wk,2997
|
|
9
|
+
./econometrics/README.md,sha256=kbBTUhv_ZHluD6ultI0FqSGqBKNc95OmaghESyrT0ZM,5499
|
|
10
|
+
./econometrics/__init__.py,sha256=PXN3is7i4PU4YVX4ZcDqrAOWEiizjA13TPQb68i47OM,4328
|
|
11
|
+
./econometrics/未开发大类优先级分析.md,sha256=l5lWegUOxrpoB5b8co4AxhCuvjI9FY4CpyjvvcenlDo,17738
|
|
12
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/__init__.py,sha256=QoKR7cP_PpbckU0FZ74F-BDWc5J8JEcYdBCHLSXF-lM,1040
|
|
13
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/causal_forest.py,sha256=B-S7twKcXsUIPWpw4Ck7pSESft2gnrv70tmxQv3NTBw,8235
|
|
14
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/double_ml.py,sha256=0HraAKGuEDM1Su8oJUvnRnzqYzrrS4_NKPy-lZ2UchI,8954
|
|
15
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/gradient_boosting.py,sha256=-cA5ih65622j2YiRNrlK2lcSLQITyYG3vuUMglgQJxc,8386
|
|
16
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/hierarchical_clustering.py,sha256=_W1IFoPa3MN--Cnd2QIOjt9GffaGmIBIjGK-qtm0Emc,7706
|
|
17
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/kmeans_clustering.py,sha256=uWfSJB40F9RwYCgUpRjroWkf9PUA8uXA7w0R9OFDfOM,9602
|
|
18
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/neural_network.py,sha256=zT1tFaxgYxPYWw2uP17FnwjdwXnTabXuMLld1heCOmc,9162
|
|
19
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/random_forest.py,sha256=A5p7qZiQi7g626EYAdNAi4IWaC1P7TOUP05RjtesIso,5974
|
|
20
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/support_vector_machine.py,sha256=PFuSj09O9Wcia0TSD6-95QraXLRdB2Qrg-QcsmLwmbw,7093
|
|
21
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/test_all_modules.py,sha256=g9yI2jQ3njYkB3GriCU-Ci-Zce7yNzBiYepsICe3mZ8,11659
|
|
22
|
+
./econometrics/advanced_methods/modern_computing_machine_learning/test_report.md,sha256=XdNKjsxUFNX9bMSyWfKWQ9a-qCOmHy4AGt8PhQKbziE,3622
|
|
23
|
+
./econometrics/basic_parametric_estimation/__init__.py,sha256=IFgOw46qAzecWUha-uUlab0VptCh82Mhc1hsZIlNH8I,463
|
|
24
|
+
./econometrics/basic_parametric_estimation/gmm/__init__.py,sha256=H5KwHqEx-ALHNlI4DyOenj4XEJ5PI-vQ0kAXR9o_S1s,151
|
|
25
|
+
./econometrics/basic_parametric_estimation/gmm/gmm_model.py,sha256=uwBIxjmO58P41qx7lHSkECMh3WhQoZgYH4gyIDLnwQI,9410
|
|
26
|
+
./econometrics/basic_parametric_estimation/mle/__init__.py,sha256=w9eJFI5c-pcMqG7igIFedz5FOnQGIviZiXXc4Dso_-s,154
|
|
27
|
+
./econometrics/basic_parametric_estimation/mle/mle_model.py,sha256=sQcPlheEYD5Kpn0RDNKjy305AMwCP07kK2U6FN73u_Q,8526
|
|
28
|
+
./econometrics/basic_parametric_estimation/ols/__init__.py,sha256=NhFFi8COkCRrSJrcjvEVOlSJkQABa20PO9yFpykJ4X4,157
|
|
29
|
+
./econometrics/basic_parametric_estimation/ols/ols_model.py,sha256=vj98YSotw-7EbQMzGWG3CGRsgpI2C4axr-KgmmvmxcE,4655
|
|
30
|
+
./econometrics/causal_inference/__init__.py,sha256=zO7jncbywWu_ut3T5p47kG3U8YY8IEkMjT4u1faNQ4Y,1536
|
|
31
|
+
./econometrics/causal_inference/causal_identification_strategy/__init__.py,sha256=ea1aM-qvvPqR-fK1OjFJho_ccupnznIdwpTJh7abkF8,1959
|
|
32
|
+
./econometrics/causal_inference/causal_identification_strategy/control_function.py,sha256=-680JCgud-BkcgAsHkIDhlQ_A3btvdotrHGNQJlRXls,3802
|
|
33
|
+
./econometrics/causal_inference/causal_identification_strategy/difference_in_differences.py,sha256=IaTIzBYSZqBdC9TMN_eOplxgz7ZYNw6TRgm6I6Urqdk,3303
|
|
34
|
+
./econometrics/causal_inference/causal_identification_strategy/event_study.py,sha256=Z0EucEVJ7RWiCm47CXYSUjlCRfmEJzXKPGoMYaFw_RQ,3981
|
|
35
|
+
./econometrics/causal_inference/causal_identification_strategy/first_difference.py,sha256=FfcqNmyEgDYqNabh3ap25OhF5tcaXjebSj5Waqmsfis,2476
|
|
36
|
+
./econometrics/causal_inference/causal_identification_strategy/fixed_effects.py,sha256=Lj0D8oXup7T8DInONip0QfBJaCq_hkaIpyvk-LsxvZg,3243
|
|
37
|
+
./econometrics/causal_inference/causal_identification_strategy/hausman_test.py,sha256=G6-YXkI_ltKVjwtxPLU0ggPby2Jde_RJIxn_i7JMOjU,2153
|
|
38
|
+
./econometrics/causal_inference/causal_identification_strategy/instrumental_variables.py,sha256=uojAby4w5x81KdW49kMisjXOugPwJAfRbEUMkaGZsYE,4732
|
|
39
|
+
./econometrics/causal_inference/causal_identification_strategy/mediation_analysis.py,sha256=MKixdaxQh70TuTV5gc7SipYT5sbB0YKAoS3-GruP2HE,4160
|
|
40
|
+
./econometrics/causal_inference/causal_identification_strategy/moderation_analysis.py,sha256=w1f1A0l1BE7JuhLcfxwzO6qZlGq_siK_DcmN_NrsnWI,3860
|
|
41
|
+
./econometrics/causal_inference/causal_identification_strategy/propensity_score_matching.py,sha256=IerdC-nNU8l3ya-FnVqTDmm3kENFFW-GVDAFSq2Ib3c,5152
|
|
42
|
+
./econometrics/causal_inference/causal_identification_strategy/random_effects.py,sha256=zUh2k7cprB6vC7JUyiqkUa6FtaJc1LgdI1DdqLh0M7g,3147
|
|
43
|
+
./econometrics/causal_inference/causal_identification_strategy/regression_discontinuity.py,sha256=S-Ttm1jDU0oEvThNdzotRv5sv97PMZzuaW_zI4PTKYk,3325
|
|
44
|
+
./econometrics/causal_inference/causal_identification_strategy/synthetic_control.py,sha256=m0Ms4rgV96HPV4EP50flYgVCbj9li7B0M8Zd9FZEyIU,4246
|
|
45
|
+
./econometrics/causal_inference/causal_identification_strategy/triple_difference.py,sha256=0mhGsfrxndLHI4zOnWlpw996w7M1e52Dxa_vrxyymoc,2814
|
|
46
|
+
./econometrics/distribution_analysis/__init__.py,sha256=y1MxYke8P0kg7Ik_uRKDwmqDXJVYsxZrzKv7WNWbxDo,631
|
|
47
|
+
./econometrics/distribution_analysis/oaxaca_blinder.py,sha256=zvEPalLpuyu6ZR_F4wsLtxt58mnX7Ceaqw2X2HC_c2M,6693
|
|
48
|
+
./econometrics/distribution_analysis/time_series_decomposition.py,sha256=zYg29RSgx_PTexIYQDN7_ed-6MGTTa8DVyUVqNCO-9E,5410
|
|
49
|
+
./econometrics/distribution_analysis/variance_decomposition.py,sha256=OFLLa8vB4SUvraT1AZ4bBozglC8gdXooD343aEK5Kks,5764
|
|
50
|
+
./econometrics/missing_data/__init__.py,sha256=PPKqqN6meqkbhbVPY3IQcXxbMMVsocdqMtgIxm9yAGk,368
|
|
51
|
+
./econometrics/missing_data/imputation_methods.py,sha256=U-xQ8G0mWbHzI1AyufKaKRB_1krCq8bKR3TiqHhwBBQ,6891
|
|
52
|
+
./econometrics/missing_data/missing_data_measurement_error/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
+
./econometrics/model_specification_diagnostics_robust_inference/README.md,sha256=A6MQ3e_fBRcgUTGG-8PIZoak2mKxg8wvoOo_mF52guk,4681
|
|
54
|
+
./econometrics/model_specification_diagnostics_robust_inference/__init__.py,sha256=EmJt_7fLMK3d6MkNCWYhWLPsZgHjjIj0zs9xkM9nh38,1832
|
|
55
|
+
./econometrics/model_specification_diagnostics_robust_inference/diagnostic_tests/__init__.py,sha256=KRhdc5K-xATvNQPnSBRnLRr3Hhi2mtbm6GG2_dYdsBU,446
|
|
56
|
+
./econometrics/model_specification_diagnostics_robust_inference/diagnostic_tests/diagnostic_tests_model.py,sha256=xqagx4CcqLbyIwJXcmnnb33TWe_0tXSwtqCUCIVHtZo,5119
|
|
57
|
+
./econometrics/model_specification_diagnostics_robust_inference/generalized_least_squares/__init__.py,sha256=3ELQkgGtOLgWY6UOi_ZFL3g7KQxid1WCMdhhByoZHUg,196
|
|
58
|
+
./econometrics/model_specification_diagnostics_robust_inference/generalized_least_squares/gls_model.py,sha256=HupVc4WkpltRCkEZYYcrdJG_8cdY7p6SJS-_v6emKqk,4418
|
|
59
|
+
./econometrics/model_specification_diagnostics_robust_inference/model_selection/__init__.py,sha256=kDxpczAVXNaam7T_Ri0SDKl42eY4hzzu8M_XzVt-M-4,319
|
|
60
|
+
./econometrics/model_specification_diagnostics_robust_inference/model_selection/model_selection_model.py,sha256=V0gTaHjIl_xRWAfILLIn-Z0Qt12E8Q2UMQwBVvsihgY,9297
|
|
61
|
+
./econometrics/model_specification_diagnostics_robust_inference/regularization/__init__.py,sha256=48Y9Lhm77kMtGtH-K1hrpEf41cNf10dSQO5As3Mb2RU,311
|
|
62
|
+
./econometrics/model_specification_diagnostics_robust_inference/regularization/regularization_model.py,sha256=kzkhAEN6pGSk3US-o4_vh2CwhcBpBoNTbAaDBNCD9P8,6047
|
|
63
|
+
./econometrics/model_specification_diagnostics_robust_inference/robust_errors/__init__.py,sha256=J-PaSUus5_f3t9kSC9EGWZPYcxwwCU5KEzymDYQi7ZA,257
|
|
64
|
+
./econometrics/model_specification_diagnostics_robust_inference/robust_errors/robust_errors_model.py,sha256=ctOQGLSRXCdKbReUw6WyjlFhHsnrl7RfLkmI92U-2tk,4269
|
|
65
|
+
./econometrics/model_specification_diagnostics_robust_inference/simultaneous_equations/__init__.py,sha256=gQg1Hjt3QWuLu8nPqUDG3GbsEmL9U31LuRpLAb2CxLI,294
|
|
66
|
+
./econometrics/model_specification_diagnostics_robust_inference/simultaneous_equations/simultaneous_equations_model.py,sha256=LQbOf6o6iVtcrJBgpi6txznaxtn9REBQCIgzBAZnlxM,10309
|
|
67
|
+
./econometrics/model_specification_diagnostics_robust_inference/weighted_least_squares/__init__.py,sha256=uUcFyCn7Ny3jkAw7GsB2UYT_ucrsbM1P6wGx7MAWoRc,193
|
|
68
|
+
./econometrics/model_specification_diagnostics_robust_inference/weighted_least_squares/wls_model.py,sha256=Jzc5p3TI1elFuYQp0EgGvTpsgtBiqKmKAPo5ppZ7xq0,4196
|
|
69
|
+
./econometrics/nonparametric/__init__.py,sha256=6z00sY_giOJM_svIOuBWH7PngXmabqYDoZWqFRnQPMM,659
|
|
70
|
+
./econometrics/nonparametric/gam_model.py,sha256=FpkEj0dAaaC2eIGVrpTENxg0u_icV7AVCvWGSx0S124,3377
|
|
71
|
+
./econometrics/nonparametric/kernel_regression.py,sha256=mrg5gGoSy1kRmWW_L4QvLbd4yga_JA7Xq_EuihTdPMQ,5306
|
|
72
|
+
./econometrics/nonparametric/quantile_regression.py,sha256=9a8pg6TuTdJUkoepO8UfAp_uqfxSLM-G_17x_KJt4AU,7909
|
|
73
|
+
./econometrics/nonparametric/spline_regression.py,sha256=6LK3iMqkVq89kY1alE_Ru66fMxhP2an6I80E_xlTd_Q,2934
|
|
74
|
+
./econometrics/nonparametric/nonparametric_semiparametric_methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
75
|
+
./econometrics/spatial_econometrics/__init__.py,sha256=hzLnwzWMWHYfBQMMJAXMnxMmt0nCG32MbNJlbDNCgYM,1492
|
|
76
|
+
./econometrics/spatial_econometrics/geographically_weighted_regression.py,sha256=4-rMmThDMwp84sLwkDymEIUP80MokoYNdmyQBpp78ak,7664
|
|
77
|
+
./econometrics/spatial_econometrics/gwr_simple.py,sha256=QyPSpj1uzcVBZBUpzji64jwy_YxrDaF9vploSugf2AY,5163
|
|
78
|
+
./econometrics/spatial_econometrics/spatial_autocorrelation.py,sha256=1PDZKgZgQu8WXpS8LmR1xvO-HhfIQuT2ZR-Jh0N23ac,11029
|
|
79
|
+
./econometrics/spatial_econometrics/spatial_durbin_model.py,sha256=xF-OvBbeYqfoemuu1YtsSyCw7DzqTNQ6C9Rl9Db0twQ,5755
|
|
80
|
+
./econometrics/spatial_econometrics/spatial_regression.py,sha256=faPazLxEG2BkPU775l_Stl61WmIueIJq36Fc4IiQdDA,10162
|
|
81
|
+
./econometrics/spatial_econometrics/spatial_weights.py,sha256=DFNduCpex0xTrGTEAL2wj9MtaLr9z5a-FZK6h3FKRsw,7890
|
|
82
|
+
./econometrics/spatial_econometrics/spatial_econometrics_new/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
|
+
./econometrics/specific_data_modeling/micro_discrete_limited_data/README.md,sha256=p0-ClYEupOIjy7YMSjF_xP5MuoFn5pZM_UQ63I72OvM,4616
|
|
84
|
+
./econometrics/specific_data_modeling/micro_discrete_limited_data/__init__.py,sha256=iXU4kGgjB2FbpfV_FYUTeMaYRMw4uNW89N3lsHBsVms,761
|
|
85
|
+
./econometrics/specific_data_modeling/micro_discrete_limited_data/count_data_models.py,sha256=sOBe3vJgoF0lMBloOqd22Cq9uDuSgxjwRSgBAqwb0sg,9601
|
|
86
|
+
./econometrics/specific_data_modeling/micro_discrete_limited_data/discrete_choice_models.py,sha256=WsCs3VpiGvHTFktI03z41KCpkG2Z1t9ICdnIA59QlQE,8535
|
|
87
|
+
./econometrics/specific_data_modeling/micro_discrete_limited_data/limited_dependent_variable_models.py,sha256=6CQ8N_ymoFjWB7qqYGjhGhq6KWdAefaQRxosCuzV3bA,9900
|
|
88
|
+
./econometrics/specific_data_modeling/survival_duration_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
89
|
+
./econometrics/specific_data_modeling/time_series_panel_data/__init__.py,sha256=HGRg4teWO8cbzr4oS_Zx2iqNJppAxRPp7WsaAt6CqMY,2526
|
|
90
|
+
./econometrics/specific_data_modeling/time_series_panel_data/arima_model.py,sha256=F_uhdZ0UsKCfGrJ1WscLmiyF4OAFKtqz_OJw5My7OYU,4162
|
|
91
|
+
./econometrics/specific_data_modeling/time_series_panel_data/cointegration_vecm.py,sha256=hGxOlGOchQQIEkzds8sHWlUrnenObJKjC1DctJx9jLQ,14048
|
|
92
|
+
./econometrics/specific_data_modeling/time_series_panel_data/dynamic_panel_models.py,sha256=a_d-F5Vtv5XCpshOiduvICeBTzGbtx5f4wOqFLzM1Xo,28094
|
|
93
|
+
./econometrics/specific_data_modeling/time_series_panel_data/exponential_smoothing.py,sha256=_EMoy13MfgZl2xNIZOHVOisihAvSsQo9RCs6ob38mnE,7354
|
|
94
|
+
./econometrics/specific_data_modeling/time_series_panel_data/garch_model.py,sha256=1-cnQz8qV6kPHJgo61g0rmF8cTKArqaMJPX-1o24Y3Y,7033
|
|
95
|
+
./econometrics/specific_data_modeling/time_series_panel_data/panel_diagnostics.py,sha256=zo2mkWvL8e4lIuQ_UT25geMnZq_uUPuiIIyuoIyCtnI,3910
|
|
96
|
+
./econometrics/specific_data_modeling/time_series_panel_data/panel_var.py,sha256=fzHkwORKwrCFEY24aExTGTdYXdtaiv_fZUJ-anySS5g,2225
|
|
97
|
+
./econometrics/specific_data_modeling/time_series_panel_data/structural_break_tests.py,sha256=lBJMSzvMG8KFuKBqjOYM_lPD_P_LXEBqnBmYRiaNJjk,2362
|
|
98
|
+
./econometrics/specific_data_modeling/time_series_panel_data/time_varying_parameter_models.py,sha256=iXGMdhcfPouDYa9VUQrmmAcjwvZA4AatKPxpFapvEes,3546
|
|
99
|
+
./econometrics/specific_data_modeling/time_series_panel_data/unit_root_tests.py,sha256=K6aTAYTF73Mcg7pLBK3tDY2wWsfXSc1xphOWBm2EfQM,6854
|
|
100
|
+
./econometrics/specific_data_modeling/time_series_panel_data/var_svar_model.py,sha256=1IviPC5XkQBsEVI09poonRXq5RAVDmK6Lu5pvsrgPIM,14742
|
|
101
|
+
./econometrics/statistical_inference/__init__.py,sha256=4DtmbcTDPV2UCZhwjJ-rWCuGAvRCjLIJYwoaRjWsnuw,379
|
|
102
|
+
./econometrics/statistical_inference/bootstrap_methods.py,sha256=Srvt-ISxc4UTOChcqGTz1nGE8dMlbFzpFcHAV50p2j4,5595
|
|
103
|
+
./econometrics/statistical_inference/permutation_test.py,sha256=OTaL0TjrxWheRsbj7bUL2vje9k8Tsm-j0hgIOeQYdsY,5547
|
|
104
|
+
./econometrics/statistical_inference/statistical_inference_techniques/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
105
|
+
./econometrics/statistics/distribution_decomposition_methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
106
|
+
./econometrics/survival_analysis/__init__.py,sha256=hcOJhPd0_vzeqOoI7KwSueMbvfRemj0Cyo-X0E6R5Sg,351
|
|
107
|
+
./econometrics/survival_analysis/survival_models.py,sha256=t44fJ9N2pXmw1lA7T7timwr50SQk3deYqlDCBf74l3E,9232
|
|
108
|
+
./econometrics/tests/basic_parametric_estimation_tests/__init__.py,sha256=m4Nv29MZh4w-TekKYMdP5hLPxfIvw_X3s1a9fdnxjQk,53
|
|
109
|
+
./econometrics/tests/basic_parametric_estimation_tests/test_gmm.py,sha256=BA6KMQaYRLxnWJgw-LclCnJu_-npAiDtom5LsAAozNM,3760
|
|
110
|
+
./econometrics/tests/basic_parametric_estimation_tests/test_mle.py,sha256=kZa3sx7Cdu7s6hrx645AKXJNN7hnRJantw0VgBo_Mis,3735
|
|
111
|
+
./econometrics/tests/basic_parametric_estimation_tests/test_ols.py,sha256=dqsrYhmjKcwKVdRdhBHPaygukvsZ_mFsj4y7BoxJgCI,2835
|
|
112
|
+
./econometrics/tests/causal_inference_tests/__init__.py,sha256=gmtYsJNAuuV_J9X8ZwY8a8TG5FpNHAireV95kPGCb5c,32
|
|
113
|
+
./econometrics/tests/causal_inference_tests/detailed_test.py,sha256=d0z2TZkgeWwPkxnzc8ZjOJ3F3Guu1VZKr2EWr5IQxwM,14460
|
|
114
|
+
./econometrics/tests/causal_inference_tests/test_all_methods.py,sha256=g2qAeyXeZgeH22SKh-cIds-Uz0God7ODSmCWEsb1TX8,13790
|
|
115
|
+
./econometrics/tests/causal_inference_tests/test_causal_identification_strategy.py,sha256=e2nfMpuUp2d0rRiP-skuT9hhPEjcH4rL3XA0V9bxJmE,6719
|
|
116
|
+
./econometrics/tests/causal_inference_tests/test_difference_in_differences.py,sha256=5CYoYUILqsvBZeuDoljMRldlNx8PTgV2BFJ7Mkzn3mA,1825
|
|
117
|
+
./econometrics/tests/causal_inference_tests/test_instrumental_variables.py,sha256=whwrJo-e9t9_5JUOzZOiQQVrme5k-1V7qBqhzGyQRs0,1194
|
|
118
|
+
./econometrics/tests/model_specification_diagnostics_tests/__init__.py,sha256=r_fvo5IW5smEMykzU0LGdd8vtL3NOI2ZyL4WgVOoYak,71
|
|
119
|
+
./econometrics/tests/model_specification_diagnostics_tests/test_diagnostic_tests.py,sha256=7ICFo3rDo2yK9rGcWtYSNe1iIEZO6ywp4oYFHVL_z4o,2694
|
|
120
|
+
./econometrics/tests/model_specification_diagnostics_tests/test_robust_errors.py,sha256=c5C7VcsvNmegIAzsok4q5iJKb5Lstpa8qHdY7jdW0g4,2905
|
|
121
|
+
./econometrics/tests/specific_data_modeling_tests/__init__.py,sha256=pT2dhJ9FeaPzTY4xcwuMYCk6rtnYie_xTwk7LARuFg4,53
|
|
122
|
+
./econometrics/tests/specific_data_modeling_tests/test_arima.py,sha256=aQGhShPzDdoDjU5GociZDJk190OhLbD1A2JRXIjDv6A,2806
|
|
123
|
+
./econometrics/tests/specific_data_modeling_tests/test_dynamic_panel.py,sha256=99FEc_o437W59Mfj8jzlb2m7QDCCWANWwMN0aEL24IU,6372
|
|
124
|
+
./econometrics/tests/specific_data_modeling_tests/test_exponential_smoothing.py,sha256=D90bZhBfDAIcT1IBhjkRluv0xpxJsulzAEudI4FLjKI,3366
|
|
125
|
+
./econometrics/tests/specific_data_modeling_tests/test_garch.py,sha256=Fkaih4Lh5TVScCBKjtXI60pSxnobi2aaGcca8p04PM4,3271
|
|
126
|
+
./econometrics/tests/specific_data_modeling_tests/test_micro_discrete_limited_data.py,sha256=lbFGJIkibSuk3H8gbCQwDZzZrscGKNYQZhNsBkDAOW8,5006
|
|
127
|
+
./econometrics/tests/specific_data_modeling_tests/test_unit_root.py,sha256=87gEu8fDh7LS20xMJk_OrBryA2UYa-8KPUBaVaNFjNc,4539
|
|
128
|
+
./econometrics/tests/specific_data_modeling_tests/test_var.py,sha256=kbWZVftblOULYABBBCiIS5x6JpBdPv-ZgG5HfbtsI4U,3556
|
|
129
|
+
./prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
130
|
+
./prompts/analysis_guides.py,sha256=FCsEtRCETWJUuG8exmAL30NRpD0eT9dyqljlpxXU5u0,1545
|
|
131
|
+
./resources/MCP_MASTER_GUIDE.md,sha256=lZ2R2xV1ksCHSkSl4YorvW0ZmgCJM3Oq8UuM0kZaG6I,13407
|
|
132
|
+
./resources/MCP_TOOLS_DATA_FORMAT_GUIDE.md,sha256=LFY_VS_bwLu5LBi1vbPruFac4qwGzP-UwvDAk1s9ha0,5706
|
|
133
|
+
./resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
|
+
./tools/README.md,sha256=KkEUtBa3TBwz2HcVoW1Z9sGExb8BrElKzcgSlG0eoP0,2217
|
|
135
|
+
./tools/__init__.py,sha256=_bPYaImVZ7zgNPN2sW6KVfrZ-rasPGVuklmSz3Vu8Ic,2840
|
|
136
|
+
./tools/causal_inference_adapter.py,sha256=7h-PlNq5imdGa8hWsrbzZCo7JVrOdbZnrADrnxCWz1Y,21646
|
|
137
|
+
./tools/data_loader.py,sha256=-HFKORi03DejxCBD2i5HJJCiwEEdG5uSA4jJivhVT0Y,6886
|
|
138
|
+
./tools/decorators.py,sha256=ascsn0rNtzv1-RZWa4xQXArFD-43R3YuUbVIyxRtuOA,867
|
|
139
|
+
./tools/distribution_analysis_adapter.py,sha256=a3GwomSfGX0EqGqehhIYZYUYP89GwhRFVOtypUNZjMQ,3498
|
|
140
|
+
./tools/econometrics_adapter.py,sha256=MHXvzjBnULEgBGc5HRV5m93auzwPhSZyorl8dq3Mt_0,11429
|
|
141
|
+
./tools/gwr_simple_adapter.py,sha256=rCcoI3O0AxhwQtx5-bCL2UEYGtwm7iH4QkBk-XER4rQ,1581
|
|
142
|
+
./tools/machine_learning_adapter.py,sha256=zz9jIVGyJngewq11GdWzorgxPRHjacIC73XwAM2wu78,20991
|
|
143
|
+
./tools/mcp_tools_registry.py,sha256=4SRmT81KCpA605jDJM3_otoG_ejC3Ls0sk7vWJtbcdU,3914
|
|
144
|
+
./tools/microecon_adapter.py,sha256=Q1lXkNu5Cx8v76FQ_Qu5qslMN-50C6neAq-JitHJ6YY,15648
|
|
145
|
+
./tools/missing_data_adapter.py,sha256=ZGGNw-j0DIFxO9hFI7zNW0SxcfH9jjC_5BxEw8QWO8E,2194
|
|
146
|
+
./tools/model_specification_adapter.py,sha256=M1bdELqKJe7Mg91V7BNqdBXV2D5l3nqC_h91sQ4Ifno,14570
|
|
147
|
+
./tools/nonparametric_adapter.py,sha256=JPyvTo4KnoSPR5ZasxHtgiItIyVXOG2KTfaodxx8d9w,5969
|
|
148
|
+
./tools/output_formatter.py,sha256=l03L6QhsSKiOoDBSDeMkRjkxVHvfMAuBFcTdB7-m2CM,20751
|
|
149
|
+
./tools/spatial_econometrics_adapter.py,sha256=qkjpdjsplYb-6ETQ5aG4N2WyuJ19J6XdSyqz5yW9ofI,10325
|
|
150
|
+
./tools/statistical_inference_adapter.py,sha256=Tps2v3CyI1jrF6iOcXsMLQWzs1WZfYXo-2VyAryO4SM,2591
|
|
151
|
+
./tools/survival_analysis_adapter.py,sha256=z0vmooAh1lisgAn9SaamVzjKedkZW6a3fIxNJlFa5oQ,1451
|
|
152
|
+
./tools/time_series_panel_data_adapter.py,sha256=b9GsTzLIEQnUInC4jVUasOQbEmiEvhy60QxAWgznSWs,35746
|
|
153
|
+
./tools/time_series_panel_data_tools.py,sha256=W4R_CRBYnRjAd5s3_6_BfOPuIluxTkfj7iAfH-UWBgs,2098
|
|
154
|
+
./tools/mcp_tool_groups/__init__.py,sha256=MZ9WKfbB5LMdNns0P9j5P7tLPFjgHGu9YohspmuOp-8,469
|
|
155
|
+
./tools/mcp_tool_groups/basic_parametric_tools.py,sha256=9noEMDxQi7TfDlSXEl5RYEEd1RmQYT-FfzZtmjUUbIw,5827
|
|
156
|
+
./tools/mcp_tool_groups/causal_inference_tools.py,sha256=jdgs1LwPFPBDYUiHKe23Ue6IHriNkKEgfaZKRSQPU10,22529
|
|
157
|
+
./tools/mcp_tool_groups/distribution_analysis_tools.py,sha256=vC3o7ZrwzdNp5ZSmDbyiHXMEuY8FbsNfHH7k69GmUBU,5491
|
|
158
|
+
./tools/mcp_tool_groups/machine_learning_tools.py,sha256=wOwv6SGaXGjwIGdDbW4m3_Z-SOZGFE3YPqVo15YhCxo,15070
|
|
159
|
+
./tools/mcp_tool_groups/microecon_tools.py,sha256=rfFTR1C6GcQWJmsuih_423eIfGbxuez2ZYQ3FTDN91I,10805
|
|
160
|
+
./tools/mcp_tool_groups/missing_data_tools.py,sha256=UUceenEOxrKLW-1jD4j4zqWKrZmAhJh5yU552EhCAs4,3601
|
|
161
|
+
./tools/mcp_tool_groups/model_specification_tools.py,sha256=-IqFF7OjXKwKaFU-XruOFO62AkvEVJqSHHgh8ymSj8s,14834
|
|
162
|
+
./tools/mcp_tool_groups/nonparametric_tools.py,sha256=8LJkzb4ykyBA8XNGKiKlmEFEMBqLxWIRphYOwseXzTg,7383
|
|
163
|
+
./tools/mcp_tool_groups/spatial_econometrics_tools.py,sha256=qgVH-Q0Fysb9tAotZ5_vzoDMJ9nwz0x4OHzA3Ny5lnE,10637
|
|
164
|
+
./tools/mcp_tool_groups/statistical_inference_tools.py,sha256=_wTsGLLWsisvD6L5OXqVbX9_CznCXma1QS0AnISJzZQ,4126
|
|
165
|
+
./tools/mcp_tool_groups/time_series_tools.py,sha256=IytweixTmJ14uMuAFczZ80mV6eUBrF85AQrBUkmpcCA,18276
|
|
166
|
+
aigroup_econ_mcp-2.0.1.dist-info/METADATA,sha256=gQ902Sju8YC3j9r70FnKd_d8v4K9ozzNI2uIKJa0OjE,28759
|
|
167
|
+
aigroup_econ_mcp-2.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
168
|
+
aigroup_econ_mcp-2.0.1.dist-info/entry_points.txt,sha256=UbLsgggIXKYqolHc0xxLCKr0_aFxRek4_QOCAgzDHZk,45
|
|
169
|
+
aigroup_econ_mcp-2.0.1.dist-info/licenses/LICENSE,sha256=DoyCJUWlDzKbqc5KRbFpsGYLwLh-XJRHKQDoITjb1yc,1083
|
|
170
|
+
aigroup_econ_mcp-2.0.1.dist-info/RECORD,,
|
cli.py
CHANGED
|
@@ -5,20 +5,24 @@ AIGroup Econometrics MCP - CLI 入口
|
|
|
5
5
|
|
|
6
6
|
import sys
|
|
7
7
|
import os
|
|
8
|
+
import traceback
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
10
11
|
def main():
|
|
11
12
|
"""CLI 主函数"""
|
|
12
13
|
try:
|
|
14
|
+
print("正在启动 AIGroup Econometrics MCP 服务器...")
|
|
13
15
|
# 导入并运行服务器
|
|
14
16
|
from server import main as server_main
|
|
15
17
|
server_main()
|
|
16
18
|
except ImportError as e:
|
|
17
19
|
print(f"导入错误: {e}")
|
|
20
|
+
traceback.print_exc()
|
|
18
21
|
print("请确保所有依赖已正确安装")
|
|
19
22
|
sys.exit(1)
|
|
20
23
|
except Exception as e:
|
|
21
24
|
print(f"启动服务器时出错: {e}")
|
|
25
|
+
traceback.print_exc()
|
|
22
26
|
sys.exit(1)
|
|
23
27
|
|
|
24
28
|
# 添加cli函数以匹配pyproject.toml中的入口点定义
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Modern Computing and Machine Learning for Econometrics
|
|
3
|
+
"""
|
|
4
|
+
from .random_forest import EconRandomForest, random_forest_analysis
|
|
5
|
+
from .gradient_boosting import EconGradientBoosting, gradient_boosting_analysis
|
|
6
|
+
from .support_vector_machine import EconSVM, svm_analysis
|
|
7
|
+
from .neural_network import EconNeuralNetwork, neural_network_analysis
|
|
8
|
+
from .kmeans_clustering import EconKMeans, kmeans_analysis
|
|
9
|
+
from .hierarchical_clustering import EconHierarchicalClustering, hierarchical_clustering_analysis
|
|
10
|
+
from .double_ml import DoubleML, double_ml_analysis
|
|
11
|
+
from .causal_forest import CausalForest, causal_forest_analysis
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
'EconRandomForest',
|
|
15
|
+
'random_forest_analysis',
|
|
16
|
+
'EconGradientBoosting',
|
|
17
|
+
'gradient_boosting_analysis',
|
|
18
|
+
'EconSVM',
|
|
19
|
+
'svm_analysis',
|
|
20
|
+
'EconNeuralNetwork',
|
|
21
|
+
'neural_network_analysis',
|
|
22
|
+
'EconKMeans',
|
|
23
|
+
'kmeans_analysis',
|
|
24
|
+
'EconHierarchicalClustering',
|
|
25
|
+
'hierarchical_clustering_analysis',
|
|
26
|
+
'DoubleML',
|
|
27
|
+
'double_ml_analysis',
|
|
28
|
+
'CausalForest',
|
|
29
|
+
'causal_forest_analysis'
|
|
30
|
+
]
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Causal Forest implementation for heterogeneous treatment effect estimation
|
|
3
|
+
"""
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
7
|
+
from sklearn.model_selection import train_test_split
|
|
8
|
+
from typing import Union, Optional, Dict, Any
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CausalForest:
|
|
12
|
+
"""
|
|
13
|
+
Causal Forest for estimating heterogeneous treatment effects
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, n_estimators: int = 100, min_samples_leaf: int = 5,
|
|
17
|
+
max_depth: Optional[int] = None, random_state: int = 42,
|
|
18
|
+
honest: bool = True, n_jobs: int = -1):
|
|
19
|
+
"""
|
|
20
|
+
Initialize Causal Forest model
|
|
21
|
+
|
|
22
|
+
Parameters:
|
|
23
|
+
-----------
|
|
24
|
+
n_estimators : int
|
|
25
|
+
Number of trees in the forest
|
|
26
|
+
min_samples_leaf : int
|
|
27
|
+
Minimum number of samples required to be at a leaf node
|
|
28
|
+
max_depth : int, optional
|
|
29
|
+
Maximum depth of the tree
|
|
30
|
+
random_state : int
|
|
31
|
+
Random state for reproducibility
|
|
32
|
+
honest : bool
|
|
33
|
+
Whether to use honest splitting (separate samples for splitting and estimation)
|
|
34
|
+
n_jobs : int
|
|
35
|
+
Number of jobs to run in parallel
|
|
36
|
+
"""
|
|
37
|
+
self.n_estimators = n_estimators
|
|
38
|
+
self.min_samples_leaf = min_samples_leaf
|
|
39
|
+
self.max_depth = max_depth
|
|
40
|
+
self.random_state = random_state
|
|
41
|
+
self.honest = honest
|
|
42
|
+
self.n_jobs = n_jobs
|
|
43
|
+
|
|
44
|
+
# We'll implement a simplified version using two random forests
|
|
45
|
+
# One for the outcome regression and one for the treatment regression
|
|
46
|
+
self.mu_model = RandomForestRegressor(
|
|
47
|
+
n_estimators=n_estimators,
|
|
48
|
+
min_samples_leaf=min_samples_leaf,
|
|
49
|
+
max_depth=max_depth,
|
|
50
|
+
random_state=random_state,
|
|
51
|
+
n_jobs=n_jobs
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
self.pi_model = RandomForestRegressor(
|
|
55
|
+
n_estimators=n_estimators,
|
|
56
|
+
min_samples_leaf=min_samples_leaf,
|
|
57
|
+
max_depth=max_depth,
|
|
58
|
+
random_state=random_state,
|
|
59
|
+
n_jobs=n_jobs
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Store results
|
|
63
|
+
self.fitted = False
|
|
64
|
+
|
|
65
|
+
def fit(self, X: Union[np.ndarray, pd.DataFrame],
|
|
66
|
+
y: Union[np.ndarray, pd.Series],
|
|
67
|
+
w: Union[np.ndarray, pd.Series]) -> 'CausalForest':
|
|
68
|
+
"""
|
|
69
|
+
Fit the Causal Forest model
|
|
70
|
+
|
|
71
|
+
Parameters:
|
|
72
|
+
-----------
|
|
73
|
+
X : array-like of shape (n_samples, n_features)
|
|
74
|
+
Covariates
|
|
75
|
+
y : array-like of shape (n_samples,)
|
|
76
|
+
Outcome variable
|
|
77
|
+
w : array-like of shape (n_samples,)
|
|
78
|
+
Treatment assignment (binary)
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
--------
|
|
82
|
+
self : CausalForest
|
|
83
|
+
"""
|
|
84
|
+
# Convert to numpy arrays
|
|
85
|
+
X = np.asarray(X)
|
|
86
|
+
y = np.asarray(y)
|
|
87
|
+
w = np.asarray(w)
|
|
88
|
+
|
|
89
|
+
# Fit outcome regression E[Y|X]
|
|
90
|
+
self.mu_model.fit(X, y)
|
|
91
|
+
|
|
92
|
+
# Fit treatment regression E[W|X]
|
|
93
|
+
self.pi_model.fit(X, w)
|
|
94
|
+
|
|
95
|
+
self.fitted = True
|
|
96
|
+
return self
|
|
97
|
+
|
|
98
|
+
def predict(self, X: Union[np.ndarray, pd.DataFrame]) -> Dict[str, np.ndarray]:
|
|
99
|
+
"""
|
|
100
|
+
Predict treatment effects for new samples
|
|
101
|
+
|
|
102
|
+
Parameters:
|
|
103
|
+
-----------
|
|
104
|
+
X : array-like of shape (n_samples, n_features)
|
|
105
|
+
Samples
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
--------
|
|
109
|
+
results : dict
|
|
110
|
+
Dictionary with treatment effect estimates and related statistics
|
|
111
|
+
"""
|
|
112
|
+
if not self.fitted:
|
|
113
|
+
raise ValueError("Model must be fitted before making predictions")
|
|
114
|
+
|
|
115
|
+
# Convert to numpy array
|
|
116
|
+
X = np.asarray(X)
|
|
117
|
+
|
|
118
|
+
# Get base predictions
|
|
119
|
+
mu_pred = self.mu_model.predict(X)
|
|
120
|
+
pi_pred = self.pi_model.predict(X)
|
|
121
|
+
|
|
122
|
+
# In a full implementation, we would compute heterogeneous treatment effects
|
|
123
|
+
# For this simplified version, we return the predicted values
|
|
124
|
+
# A full implementation would involve:
|
|
125
|
+
# 1. Using honest splitting
|
|
126
|
+
# 2. Computing R-learner or similar estimates in the leaves
|
|
127
|
+
# 3. Aggregating across trees
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
'outcome_prediction': mu_pred,
|
|
131
|
+
'treatment_propensity': pi_pred,
|
|
132
|
+
'treatment_effect': mu_pred # Placeholder - in practice would be different
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
def estimate_treatment_effect(self, X: Union[np.ndarray, pd.DataFrame],
|
|
136
|
+
y: Union[np.ndarray, pd.Series],
|
|
137
|
+
w: Union[np.ndarray, pd.Series]) -> Dict[str, Any]:
|
|
138
|
+
"""
|
|
139
|
+
Estimate treatment effects using the fitted model
|
|
140
|
+
|
|
141
|
+
Parameters:
|
|
142
|
+
-----------
|
|
143
|
+
X : array-like of shape (n_samples, n_features)
|
|
144
|
+
Covariates
|
|
145
|
+
y : array-like of shape (n_samples,)
|
|
146
|
+
Outcome variable
|
|
147
|
+
w : array-like of shape (n_samples,)
|
|
148
|
+
Treatment assignment (binary)
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
--------
|
|
152
|
+
results : dict
|
|
153
|
+
Dictionary with treatment effect estimates
|
|
154
|
+
"""
|
|
155
|
+
if not self.fitted:
|
|
156
|
+
raise ValueError("Model must be fitted first")
|
|
157
|
+
|
|
158
|
+
# Convert to numpy arrays
|
|
159
|
+
X = np.asarray(X)
|
|
160
|
+
y = np.asarray(y)
|
|
161
|
+
w = np.asarray(w)
|
|
162
|
+
|
|
163
|
+
# Get predictions
|
|
164
|
+
mu_pred = self.mu_model.predict(X)
|
|
165
|
+
pi_pred = self.pi_model.predict(X)
|
|
166
|
+
|
|
167
|
+
# Compute doubly robust scores for treatment effect estimation
|
|
168
|
+
# psi = (w - pi_pred) * (y - mu_pred) / (pi_pred * (1 - pi_pred)) + mu_pred
|
|
169
|
+
|
|
170
|
+
# Handle edge cases for propensity scores
|
|
171
|
+
pi_pred = np.clip(pi_pred, 1e-5, 1 - 1e-5)
|
|
172
|
+
|
|
173
|
+
# Compute AIPW (Augmented Inverse Probability Weighting) scores
|
|
174
|
+
w1 = w / pi_pred
|
|
175
|
+
w0 = (1 - w) / (1 - pi_pred)
|
|
176
|
+
|
|
177
|
+
# Estimate treatment effects
|
|
178
|
+
y1_est = w1 * y + (1 - w1) * mu_pred
|
|
179
|
+
y0_est = w0 * y + (1 - w0) * mu_pred
|
|
180
|
+
|
|
181
|
+
# Individual treatment effects (CATE - Conditional Average Treatment Effect)
|
|
182
|
+
cate = y1_est - y0_est
|
|
183
|
+
|
|
184
|
+
# Average treatment effect
|
|
185
|
+
ate = np.mean(cate)
|
|
186
|
+
|
|
187
|
+
# Standard error (naive)
|
|
188
|
+
cate_se = np.std(cate) / np.sqrt(len(cate))
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
'cate': cate, # Conditional Average Treatment Effects
|
|
192
|
+
'ate': ate, # Average Treatment Effect
|
|
193
|
+
'cate_se': cate_se,
|
|
194
|
+
'outcome_prediction': mu_pred,
|
|
195
|
+
'treatment_propensity': pi_pred
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def causal_forest_analysis(X: Union[np.ndarray, pd.DataFrame],
|
|
200
|
+
y: Union[np.ndarray, pd.Series],
|
|
201
|
+
w: Union[np.ndarray, pd.Series],
|
|
202
|
+
n_estimators: int = 100,
|
|
203
|
+
min_samples_leaf: int = 5,
|
|
204
|
+
max_depth: Optional[int] = None,
|
|
205
|
+
random_state: int = 42,
|
|
206
|
+
honest: bool = True) -> dict:
|
|
207
|
+
"""
|
|
208
|
+
Perform complete Causal Forest analysis
|
|
209
|
+
|
|
210
|
+
Parameters:
|
|
211
|
+
-----------
|
|
212
|
+
X : array-like of shape (n_samples, n_features)
|
|
213
|
+
Covariates
|
|
214
|
+
y : array-like of shape (n_samples,)
|
|
215
|
+
Outcome variable
|
|
216
|
+
w : array-like of shape (n_samples,)
|
|
217
|
+
Treatment assignment (binary)
|
|
218
|
+
n_estimators : int
|
|
219
|
+
Number of trees in the forest
|
|
220
|
+
min_samples_leaf : int
|
|
221
|
+
Minimum number of samples required to be at a leaf node
|
|
222
|
+
max_depth : int, optional
|
|
223
|
+
Maximum depth of the tree
|
|
224
|
+
random_state : int
|
|
225
|
+
Random state for reproducibility
|
|
226
|
+
honest : bool
|
|
227
|
+
Whether to use honest splitting
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
--------
|
|
231
|
+
results : dict
|
|
232
|
+
Dictionary with model and estimation results
|
|
233
|
+
"""
|
|
234
|
+
# Initialize and fit model
|
|
235
|
+
cf_model = CausalForest(
|
|
236
|
+
n_estimators=n_estimators,
|
|
237
|
+
min_samples_leaf=min_samples_leaf,
|
|
238
|
+
max_depth=max_depth,
|
|
239
|
+
random_state=random_state,
|
|
240
|
+
honest=honest
|
|
241
|
+
)
|
|
242
|
+
cf_model.fit(X, y, w)
|
|
243
|
+
|
|
244
|
+
# Estimate treatment effects
|
|
245
|
+
te_results = cf_model.estimate_treatment_effect(X, y, w)
|
|
246
|
+
|
|
247
|
+
return {
|
|
248
|
+
'model': cf_model,
|
|
249
|
+
'treatment_effects': te_results,
|
|
250
|
+
'X': X,
|
|
251
|
+
'y': y,
|
|
252
|
+
'w': w
|
|
253
|
+
}
|