aigroup-econ-mcp 0.4.2__py3-none-any.whl → 1.4.3__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.
Files changed (119) hide show
  1. .gitignore +253 -0
  2. PKG-INFO +710 -0
  3. README.md +672 -0
  4. __init__.py +14 -0
  5. aigroup_econ_mcp-1.4.3.dist-info/METADATA +710 -0
  6. aigroup_econ_mcp-1.4.3.dist-info/RECORD +92 -0
  7. aigroup_econ_mcp-1.4.3.dist-info/entry_points.txt +2 -0
  8. aigroup_econ_mcp-1.4.3.dist-info/licenses/LICENSE +21 -0
  9. cli.py +28 -0
  10. econometrics/README.md +18 -0
  11. econometrics/__init__.py +191 -0
  12. econometrics/advanced_methods/modern_computing_machine_learning/__init__.py +0 -0
  13. econometrics/basic_parametric_estimation/__init__.py +31 -0
  14. econometrics/basic_parametric_estimation/gmm/__init__.py +13 -0
  15. econometrics/basic_parametric_estimation/gmm/gmm_model.py +256 -0
  16. econometrics/basic_parametric_estimation/mle/__init__.py +13 -0
  17. econometrics/basic_parametric_estimation/mle/mle_model.py +241 -0
  18. econometrics/basic_parametric_estimation/ols/__init__.py +13 -0
  19. econometrics/basic_parametric_estimation/ols/ols_model.py +141 -0
  20. econometrics/causal_inference/causal_identification_strategy/__init__.py +0 -0
  21. econometrics/missing_data/missing_data_measurement_error/__init__.py +0 -0
  22. econometrics/model_specification_diagnostics_robust_inference/README.md +173 -0
  23. econometrics/model_specification_diagnostics_robust_inference/__init__.py +78 -0
  24. econometrics/model_specification_diagnostics_robust_inference/diagnostic_tests/__init__.py +20 -0
  25. econometrics/model_specification_diagnostics_robust_inference/diagnostic_tests/diagnostic_tests_model.py +149 -0
  26. econometrics/model_specification_diagnostics_robust_inference/generalized_least_squares/__init__.py +15 -0
  27. econometrics/model_specification_diagnostics_robust_inference/generalized_least_squares/gls_model.py +130 -0
  28. econometrics/model_specification_diagnostics_robust_inference/model_selection/__init__.py +18 -0
  29. econometrics/model_specification_diagnostics_robust_inference/model_selection/model_selection_model.py +286 -0
  30. econometrics/model_specification_diagnostics_robust_inference/regularization/__init__.py +15 -0
  31. econometrics/model_specification_diagnostics_robust_inference/regularization/regularization_model.py +177 -0
  32. econometrics/model_specification_diagnostics_robust_inference/robust_errors/__init__.py +15 -0
  33. econometrics/model_specification_diagnostics_robust_inference/robust_errors/robust_errors_model.py +122 -0
  34. econometrics/model_specification_diagnostics_robust_inference/simultaneous_equations/__init__.py +15 -0
  35. econometrics/model_specification_diagnostics_robust_inference/simultaneous_equations/simultaneous_equations_model.py +246 -0
  36. econometrics/model_specification_diagnostics_robust_inference/weighted_least_squares/__init__.py +15 -0
  37. econometrics/model_specification_diagnostics_robust_inference/weighted_least_squares/wls_model.py +127 -0
  38. econometrics/nonparametric/nonparametric_semiparametric_methods/__init__.py +0 -0
  39. econometrics/spatial_econometrics/spatial_econometrics_new/__init__.py +0 -0
  40. econometrics/specific_data_modeling/micro_discrete_limited_data/__init__.py +0 -0
  41. econometrics/specific_data_modeling/survival_duration_data/__init__.py +0 -0
  42. econometrics/specific_data_modeling/time_series_panel_data/__init__.py +143 -0
  43. econometrics/specific_data_modeling/time_series_panel_data/arima_model.py +104 -0
  44. econometrics/specific_data_modeling/time_series_panel_data/cointegration_vecm.py +334 -0
  45. econometrics/specific_data_modeling/time_series_panel_data/dynamic_panel_models.py +653 -0
  46. econometrics/specific_data_modeling/time_series_panel_data/exponential_smoothing.py +176 -0
  47. econometrics/specific_data_modeling/time_series_panel_data/garch_model.py +198 -0
  48. econometrics/specific_data_modeling/time_series_panel_data/panel_diagnostics.py +125 -0
  49. econometrics/specific_data_modeling/time_series_panel_data/panel_var.py +60 -0
  50. econometrics/specific_data_modeling/time_series_panel_data/structural_break_tests.py +87 -0
  51. econometrics/specific_data_modeling/time_series_panel_data/time_varying_parameter_models.py +106 -0
  52. econometrics/specific_data_modeling/time_series_panel_data/unit_root_tests.py +204 -0
  53. econometrics/specific_data_modeling/time_series_panel_data/var_svar_model.py +372 -0
  54. econometrics/statistical_inference/statistical_inference_techniques/__init__.py +0 -0
  55. econometrics/statistics/distribution_decomposition_methods/__init__.py +0 -0
  56. econometrics/tests/basic_parametric_estimation_tests/__init__.py +3 -0
  57. econometrics/tests/basic_parametric_estimation_tests/test_gmm.py +128 -0
  58. econometrics/tests/basic_parametric_estimation_tests/test_mle.py +127 -0
  59. econometrics/tests/basic_parametric_estimation_tests/test_ols.py +100 -0
  60. econometrics/tests/model_specification_diagnostics_tests/__init__.py +3 -0
  61. econometrics/tests/model_specification_diagnostics_tests/test_diagnostic_tests.py +86 -0
  62. econometrics/tests/model_specification_diagnostics_tests/test_robust_errors.py +89 -0
  63. econometrics/tests/specific_data_modeling_tests/__init__.py +3 -0
  64. econometrics/tests/specific_data_modeling_tests/test_arima.py +98 -0
  65. econometrics/tests/specific_data_modeling_tests/test_dynamic_panel.py +198 -0
  66. econometrics/tests/specific_data_modeling_tests/test_exponential_smoothing.py +105 -0
  67. econometrics/tests/specific_data_modeling_tests/test_garch.py +118 -0
  68. econometrics/tests/specific_data_modeling_tests/test_unit_root.py +156 -0
  69. econometrics/tests/specific_data_modeling_tests/test_var.py +124 -0
  70. prompts/__init__.py +0 -0
  71. prompts/analysis_guides.py +43 -0
  72. pyproject.toml +78 -0
  73. resources/MCP_MASTER_GUIDE.md +422 -0
  74. resources/MCP_TOOLS_DATA_FORMAT_GUIDE.md +185 -0
  75. resources/__init__.py +0 -0
  76. server.py +83 -0
  77. tools/README.md +88 -0
  78. tools/__init__.py +45 -0
  79. tools/data_loader.py +213 -0
  80. tools/decorators.py +38 -0
  81. tools/econometrics_adapter.py +286 -0
  82. tools/mcp_tool_groups/__init__.py +1 -0
  83. tools/mcp_tool_groups/basic_parametric_tools.py +173 -0
  84. tools/mcp_tool_groups/model_specification_tools.py +402 -0
  85. tools/mcp_tool_groups/time_series_tools.py +494 -0
  86. tools/mcp_tools_registry.py +114 -0
  87. tools/model_specification_adapter.py +369 -0
  88. tools/output_formatter.py +563 -0
  89. tools/time_series_panel_data_adapter.py +858 -0
  90. tools/time_series_panel_data_tools.py +65 -0
  91. aigroup_econ_mcp/__init__.py +0 -19
  92. aigroup_econ_mcp/cli.py +0 -82
  93. aigroup_econ_mcp/config.py +0 -561
  94. aigroup_econ_mcp/server.py +0 -452
  95. aigroup_econ_mcp/tools/__init__.py +0 -18
  96. aigroup_econ_mcp/tools/base.py +0 -470
  97. aigroup_econ_mcp/tools/cache.py +0 -533
  98. aigroup_econ_mcp/tools/data_loader.py +0 -171
  99. aigroup_econ_mcp/tools/file_parser.py +0 -829
  100. aigroup_econ_mcp/tools/machine_learning.py +0 -60
  101. aigroup_econ_mcp/tools/ml_ensemble.py +0 -210
  102. aigroup_econ_mcp/tools/ml_evaluation.py +0 -272
  103. aigroup_econ_mcp/tools/ml_models.py +0 -54
  104. aigroup_econ_mcp/tools/ml_regularization.py +0 -172
  105. aigroup_econ_mcp/tools/monitoring.py +0 -555
  106. aigroup_econ_mcp/tools/optimized_example.py +0 -229
  107. aigroup_econ_mcp/tools/panel_data.py +0 -553
  108. aigroup_econ_mcp/tools/regression.py +0 -214
  109. aigroup_econ_mcp/tools/statistics.py +0 -154
  110. aigroup_econ_mcp/tools/time_series.py +0 -667
  111. aigroup_econ_mcp/tools/timeout.py +0 -283
  112. aigroup_econ_mcp/tools/tool_handlers.py +0 -378
  113. aigroup_econ_mcp/tools/tool_registry.py +0 -170
  114. aigroup_econ_mcp/tools/validation.py +0 -482
  115. aigroup_econ_mcp-0.4.2.dist-info/METADATA +0 -360
  116. aigroup_econ_mcp-0.4.2.dist-info/RECORD +0 -29
  117. aigroup_econ_mcp-0.4.2.dist-info/entry_points.txt +0 -2
  118. /aigroup_econ_mcp-0.4.2.dist-info/licenses/LICENSE → /LICENSE +0 -0
  119. {aigroup_econ_mcp-0.4.2.dist-info → aigroup_econ_mcp-1.4.3.dist-info}/WHEEL +0 -0
@@ -0,0 +1,43 @@
1
+ """
2
+ 计量经济学分析指导提示模板
3
+ 提供分析步骤和最佳实践的指导提示
4
+ """
5
+
6
+ from mcp.server.fastmcp import FastMCP
7
+ from mcp.server.fastmcp.prompts import base
8
+
9
+
10
+ # 定义分析指导提示模板
11
+ def regression_analysis_guide(data_description: str) -> list[base.Message]:
12
+ """生成回归分析指导提示"""
13
+ return [
14
+ base.SystemMessage(
15
+ "You are an expert econometrics assistant helping with regression analysis."
16
+ ),
17
+ base.UserMessage(
18
+ f"Help me conduct a proper regression analysis for the following data:\n\n{data_description}"
19
+ ),
20
+ base.AssistantMessage(
21
+ """I'll guide you through the regression analysis process:
22
+
23
+ 1. First, let's identify the appropriate model specification based on your data.
24
+ 2. Then, we'll check the key assumptions of the classical linear regression model.
25
+ 3. Next, we'll discuss potential diagnostic tests.
26
+ 4. Finally, we'll interpret the results properly.
27
+
28
+ Let's start with understanding your data and research question."""
29
+ )
30
+ ]
31
+
32
+
33
+ def model_selection_prompt(data_type: str, research_question: str) -> list[base.Message]:
34
+ """根据数据类型和研究问题推荐合适的计量经济学方法"""
35
+ return [
36
+ base.SystemMessage(
37
+ "You are an expert econometrics methodologist."
38
+ ),
39
+ base.UserMessage(
40
+ f"I have {data_type} data and want to answer: {research_question}\n\n"
41
+ "What econometric methods would you recommend and why?"
42
+ )
43
+ ]
pyproject.toml ADDED
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aigroup_econ_mcp"
7
+ version = "1.4.3"
8
+ description = "专业计量经济学MCP工具 - 100%覆盖Stata核心功能,30+项专业分析工具,支持CSV/JSON/TXT/Excel格式,让大模型更智能地进行数据分析"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ authors = [
12
+ {name = "AIGroup", email = "jackdark425@gmail.com"}
13
+ ]
14
+ dependencies = [
15
+ "pandas>=1.5.0",
16
+ "numpy>=1.21.0",
17
+ "statsmodels>=0.13.0",
18
+ "scipy>=1.7.0",
19
+ "mcp>=1.0.0",
20
+ "pydantic>=2.0.0",
21
+ "uvicorn>=0.20.0",
22
+ "click>=8.0.0",
23
+ "linearmodels>=7.0",
24
+ "scikit-learn>=1.0.0",
25
+ "psutil>=5.9.0",
26
+ "PyYAML>=6.0",
27
+ "arch>=6.0.0",
28
+ "openpyxl>=3.0.0",
29
+ ]
30
+ keywords = ["mcp", "economics", "statistics", "regression", "data-analysis", "econometrics", "time-series", "panel-data"]
31
+ classifiers = [
32
+ "Development Status :: 5 - Production/Stable",
33
+ "Intended Audience :: Developers",
34
+ "License :: OSI Approved :: MIT License",
35
+ "Programming Language :: Python :: 3",
36
+ "Programming Language :: Python :: 3.8",
37
+ "Programming Language :: Python :: 3.9",
38
+ "Programming Language :: Python :: 3.10",
39
+ "Programming Language :: Python :: 3.11",
40
+ "Programming Language :: Python :: 3.12",
41
+ "Topic :: Scientific/Engineering :: Information Analysis",
42
+ "Topic :: Software Development :: Libraries :: Python Modules"
43
+ ]
44
+
45
+ [project.scripts]
46
+ aigroup-econ-mcp = "cli:cli"
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/jackdark425/aigroup-econ-mcp"
50
+ Repository = "https://github.com/jackdark425/aigroup-econ-mcp.git"
51
+ Issues = "https://github.com/ajackdark425/aigroup-econ-mcp/issues"
52
+
53
+ [tool.hatch.build.targets.wheel]
54
+ packages = ["."]
55
+
56
+ [tool.hatch.build.targets.sdist]
57
+ include = [
58
+ "/.",
59
+ "/README.md",
60
+ "/LICENSE",
61
+ "/cli.py",
62
+ "/server.py",
63
+ "/__init__.py",
64
+ "/econometrics/**/*",
65
+ "/tools/**/*",
66
+ "/resources/**/*",
67
+ "/prompts/**/*",
68
+ ]
69
+
70
+ [tool.uv]
71
+ dev-dependencies = [
72
+ "pytest>=7.0.0",
73
+ "pytest-asyncio>=0.21.0",
74
+ "black>=23.0.0",
75
+ "isort>=5.12.0",
76
+ "mypy>=1.0.0",
77
+ "ruff>=0.1.0"
78
+ ]
@@ -0,0 +1,422 @@
1
+ # AIGroup计量经济学MCP工具完整指南
2
+
3
+ ## 概述
4
+
5
+ 本MCP服务器提供**21个**计量经济学分析工具,采用组件化架构设计,支持多种数据格式输入和输出。
6
+
7
+ ## 服务器配置
8
+
9
+ ```json
10
+ {
11
+ "server_name": "aigroup-econ-mcp",
12
+ "version": "2.2.0-component",
13
+ "architecture": "Component-Based",
14
+ "tool_groups": 3,
15
+ "total_tools": 21,
16
+ "tools": [
17
+ "basic_parametric_estimation_ols",
18
+ "basic_parametric_estimation_mle",
19
+ "basic_parametric_estimation_gmm",
20
+ "model_diagnostic_tests",
21
+ "generalized_least_squares",
22
+ "weighted_least_squares",
23
+ "robust_errors_regression",
24
+ "model_selection_criteria",
25
+ "regularized_regression",
26
+ "simultaneous_equations_model",
27
+ "time_series_arima_model",
28
+ "time_series_exponential_smoothing",
29
+ "time_series_garch_model",
30
+ "time_series_unit_root_tests",
31
+ "time_series_var_svar_model",
32
+ "time_series_cointegration_analysis",
33
+ "panel_data_dynamic_model",
34
+ "panel_data_diagnostics",
35
+ "panel_var_model",
36
+ "structural_break_tests",
37
+ "time_varying_parameter_models"
38
+ ],
39
+ "description": "Econometrics MCP Tools with component-based architecture"
40
+ }
41
+ ```
42
+
43
+ ## 工具概览
44
+
45
+ ### 基础参数估计工具 (3个)
46
+
47
+ 1. **OLS回归分析 (basic_parametric_estimation_ols)**
48
+ - 核心算法: econometrics/basic_parametric_estimation/ols/ols_model.py
49
+ - 输入方式: 直接数据(y_data + x_data) 或 文件(file_path)
50
+ - 支持格式: txt/json/csv/excel
51
+
52
+ 2. **最大似然估计 (basic_parametric_estimation_mle)**
53
+ - 核心算法: econometrics/basic_parametric_estimation/mle/mle_model.py
54
+ - 输入方式: 直接数据(data) 或 文件(file_path)
55
+ - 分布类型: normal, poisson, exponential
56
+ - 支持格式: txt/json/csv/excel
57
+
58
+ 3. **广义矩估计 (basic_parametric_estimation_gmm)**
59
+ - 核心算法: econometrics/basic_parametric_estimation/gmm/gmm_model.py
60
+ - 输入方式: 直接数据(y_data + x_data) 或 文件(file_path)
61
+ - 已修复: j_p_value bug
62
+ - 支持格式: txt/json/csv/excel
63
+
64
+ ### 模型规范、诊断和稳健推断工具 (7个) 🆕
65
+
66
+ 4. **模型诊断检验 (model_diagnostic_tests)**
67
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/diagnostic_tests/
68
+ - 功能: 异方差检验(Breusch-Pagan, White)、自相关检验(Durbin-Watson)、正态性检验(Jarque-Bera)、多重共线性诊断(VIF)
69
+ - 输入方式: 直接数据(y_data + x_data) 或 文件(file_path)
70
+ - 支持格式: txt/json/csv/excel
71
+
72
+ 5. **广义最小二乘法 (generalized_least_squares)**
73
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/generalized_least_squares/
74
+ - 功能: 处理异方差性和自相关的GLS回归
75
+ - 特点: 可指定误差项协方差矩阵
76
+ - 输入方式: 直接数据 或 文件
77
+
78
+ 6. **加权最小二乘法 (weighted_least_squares)**
79
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/weighted_least_squares/
80
+ - 功能: 使用权重处理已知异方差性
81
+ - 特点: 需要提供观测值权重(通常为方差的倒数)
82
+ - 输入方式: 直接数据 或 文件
83
+
84
+ 7. **稳健标准误回归 (robust_errors_regression)**
85
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/robust_errors/
86
+ - 功能: 计算异方差稳健的标准误
87
+ - 支持类型: HC0, HC1, HC2, HC3
88
+ - 特点: 不改变系数估计,只调整标准误
89
+
90
+ 8. **模型选择准则 (model_selection_criteria)**
91
+ - 核心算法: econometrics/m odel_specification_diagnostics_robust_inference/model_selection/
92
+ - 功能: 计算AIC、BIC、HQIC信息准则
93
+ - 附加功能: K折交叉验证、留一法交叉验证
94
+ - 用途: 模型比较和变量选择
95
+
96
+ 9. **正则化回归 (regularized_regression)**
97
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/regularization/
98
+ - 方法: Ridge回归(L2)、LASSO(L1)、Elastic Net(L1+L2)
99
+ - 功能: 处理多重共线性和高维数据
100
+ - 特点: 可进行变量选择(LASSO)
101
+
102
+ 10. **联立方程模型 (simultaneous_equations_model)**
103
+ - 核心算法: econometrics/model_specification_diagnostics_robust_inference/simultaneous_equations/
104
+ - 方法: 两阶段最小二乘法(2SLS)
105
+ - 功能: 处理联立方程系统和内生性问题
106
+ - 要求: 需要有效的工具变量
107
+
108
+ ### 时间序列工具 (6个)
109
+
110
+ 11. **ARIMA模型 (time_series_arima_model)**
111
+ - 参数: (p,d,q) 阶数
112
+ - 功能: 多步预测
113
+
114
+ 12. **指数平滑模型 (time_series_exponential_smoothing)**
115
+ - 组件: 趋势项, 季节项
116
+ - 功能: 多步预测
117
+
118
+ 13. **GARCH模型 (time_series_garch_model)**
119
+ - 功能: 条件方差建模
120
+ - 参数: (p,q) 阶数
121
+
122
+ 14. **单位根检验 (time_series_unit_root_tests)**
123
+ - 检验方法: ADF, PP, KPSS
124
+ - 功能: 平稳性检验
125
+
126
+ 15. **VAR/SVAR模型 (time_series_var_svar_model)**
127
+ - 模型类型: VAR, SVAR
128
+ - 功能: 多变量时间序列分析
129
+
130
+ 16. **协整分析 (time_series_cointegration_analysis)**
131
+ - 检验方法: Engle-Granger, Johansen
132
+ - 模型: VECM
133
+ - 功能: 长期均衡关系分析
134
+
135
+ ### 面板数据工具 (3个)
136
+
137
+ 17. **动态面板模型 (panel_data_dynamic_model)**
138
+ - 模型类型: 差分GMM, 系统GMM
139
+ - 数据: 横截面和时间序列数据
140
+
141
+ 18. **面板数据诊断测试 (panel_data_diagnostics)**
142
+ - 检验方法: Hausman, Pooling F, LM, 组内相关性
143
+ - 功能: 模型选择 (FE vs RE vs Pooled)
144
+
145
+ 19. **面板VAR模型 (panel_var_model)**
146
+ - 功能: 面板向量自回归
147
+ - 效应: 个体效应和时间效应
148
+
149
+ ### 高级计量工具 (2个)
150
+
151
+ 20. **结构断点检验 (structural_break_tests)**
152
+ - 检验方法: Chow, Quandt-Andrews, Bai-Perron
153
+ - 功能: 检测时间序列结构变化
154
+
155
+ 21. **时变参数模型 (time_varying_parameter_models)**
156
+ - 模型类型: TAR, STAR, Markov Switching
157
+ - 功能: 基于阈值的机制转换
158
+
159
+ ## 详细参数说明
160
+
161
+ ### 通用参数格式
162
+
163
+ #### 输入数据格式
164
+ - **直接数据输入**: 使用 `y_data`, `x_data`, `data` 等参数
165
+ - **文件输入**: 使用 `file_path` 参数
166
+ - **支持的文件格式**: txt, json, csv, excel (.xlsx, .xls)
167
+
168
+ #### 输出格式选项
169
+ - `output_format`: json, markdown, txt
170
+ - `save_path`: 可指定输出文件路径保存结果
171
+
172
+ #### 通用配置参数
173
+ - `confidence_level`: 置信水平(默认0.95)
174
+ - `constant`: 是否包含常数项(默认true)
175
+ - `feature_names`: 特征名称列表
176
+
177
+ ### 工具特定参数示例
178
+
179
+ #### 1. OLS回归分析
180
+ ```json
181
+ {
182
+ "y_data": [1, 2, 3, 4, 5],
183
+ "x_data": [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
184
+ "feature_names": ["X1", "X2"],
185
+ "constant": true,
186
+ "confidence_level": 0.95
187
+ }
188
+ ```
189
+
190
+ #### 2. 模型诊断检验 🆕
191
+ ```json
192
+ {
193
+ "y_data": [1, 2, 3, 4, 5],
194
+ "x_data": [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
195
+ "feature_names": ["X1", "X2"],
196
+ "constant": true
197
+ }
198
+ ```
199
+
200
+ #### 3. 稳健标准误回归 🆕
201
+ ```json
202
+ {
203
+ "y_data": [1, 2, 3, 4, 5],
204
+ "x_data": [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
205
+ "cov_type": "HC1",
206
+ "confidence_level": 0.95
207
+ }
208
+ ```
209
+
210
+ #### 4. 正则化回归 🆕
211
+ ```json
212
+ {
213
+ "y_data": [1, 2, 3, 4, 5],
214
+ "x_data": [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
215
+ "method": "ridge",
216
+ "alpha": 1.0,
217
+ "l1_ratio": 0.5
218
+ }
219
+ ```
220
+
221
+ #### 5. 加权最小二乘法 🆕
222
+ ```json
223
+ {
224
+ "y_data": [1, 2, 3, 4, 5],
225
+ "x_data": [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
226
+ "weights": [1.0, 0.8, 1.2, 0.9, 1.1],
227
+ "confidence_level": 0.95
228
+ }
229
+ ```
230
+
231
+ #### 6. ARIMA模型
232
+ ```json
233
+ {
234
+ "data": [1.2, 2.1, 3.4, 4.2, 5.1, 6.3, 7.2, 8.1, 9.4, 10.2],
235
+ "order": [1, 1, 1],
236
+ "forecast_steps": 3
237
+ }
238
+ ```
239
+
240
+ #### 7. 动态面板模型
241
+ ```json
242
+ {
243
+ "y_data": [1.2, 2.1, 3.4, 4.2, 5.1],
244
+ "x_data": [[1, 0.5], [2, 1.2], [3, 1.8], [4, 2.5], [5, 3.1]],
245
+ "entity_ids": [1, 1, 1, 2, 2],
246
+ "time_periods": [1, 2, 3, 1, 2],
247
+ "model_type": "diff_gmm"
248
+ }
249
+ ```
250
+
251
+ ## 参数选项说明
252
+
253
+ ### 分布类型 (MLE)
254
+ - `normal`: 正态分布
255
+ - `poisson`: 泊松分布
256
+ - `exponential`: 指数分布
257
+
258
+ ### 稳健标准误类型 🆕
259
+ - `HC0`: 白异方差一致性标准误
260
+ - `HC1`: 修正的HC0(小样本调整)
261
+ - `HC2`: 杠杆调整的标准误
262
+ - `HC3`: 杠杆调整的标准误(更稳健)
263
+
264
+ ### 正则化方法 🆕
265
+ - `ridge`: 岭回归(L2惩罚)
266
+ - `lasso`: LASSO回归(L1惩罚,可变量选择)
267
+ - `elastic_net`: 弹性网络(L1+L2惩罚)
268
+
269
+ ### 单位根检验类型
270
+ - `adf`: Augmented Dickey-Fuller检验
271
+ - `pp`: Phillips-Perron检验
272
+ - `kpss`: KPSS检验
273
+
274
+ ### VAR/SVAR模型类型
275
+ - `var`: 向量自回归模型
276
+ - `svar`: 结构向量自回归模型
277
+
278
+ ### 协整分析方法
279
+ - `johansen`: Johansen协整检验
280
+ - `engle-granger`: Engle-Granger协整检验
281
+
282
+ ### 动态面板模型类型
283
+ - `diff_gmm`: 差分GMM模型
284
+ - `sys_gmm`: 系统GMM模型
285
+
286
+ ### 面板诊断测试类型
287
+ - `hausman`: Hausman检验 (FE vs RE)
288
+ - `pooling_f`: Pooling F检验
289
+ - `lm`: LM检验
290
+ - `within_correlation`: 组内相关性检验
291
+
292
+ ### 结构断点检验类型
293
+ - `chow`: Chow检验
294
+ - `quandt-andrews`: Quandt-Andrews检验
295
+ - `bai-perron`: Bai-Perron多重断点检验
296
+
297
+ ### 时变参数模型类型
298
+ - `tar`: 门限自回归模型
299
+ - `star`: 平滑转换自回归模型
300
+ - `markov_switching`: 马尔科夫转换模型
301
+
302
+ ### STAR类型
303
+ - `logistic`: Logistic转换函数
304
+ - `exponential`: 指数转换函数
305
+
306
+ ## 工具组分类
307
+
308
+ ### 第一组:基础参数估计 (3个工具)
309
+ 专注于基本的统计估计方法,适用于大多数标准回归分析场景。
310
+
311
+ ### 第二组:模型规范、诊断和稳健推断 (7个工具) 🆕
312
+ 提供全面的模型诊断、规范检验和稳健估计方法,确保模型的可靠性和有效性。
313
+
314
+ ### 第三组:时间序列和面板数据 (11个工具)
315
+ 涵盖时间序列分析、面板数据建模和高级计量方法。
316
+
317
+ ## 架构信息
318
+
319
+ **架构**: Component-Based
320
+ **版本**: 2.2.0
321
+ **Python版本**: 3.8+
322
+ **MCP协议**: FastMCP
323
+ **工具组数量**: 3
324
+ **总工具数**: 21
325
+ **文件格式**: txt, json, csv, excel (.xlsx, .xls)
326
+ **输出格式**: json, markdown, txt
327
+
328
+ ## 优势特点
329
+
330
+ - **组件化设计**: 工具按功能分组,便于维护和扩展
331
+ - **模块化**: 每个工具组独立管理
332
+ - **DRY原则**: 复用核心算法,无重复代码
333
+ - **易于扩展**: 轻松添加新工具类别
334
+ - **性能优化**: 高效的数据处理和计算
335
+ - **全面诊断**: 新增完整的模型诊断和稳健推断工具 🆕
336
+ - **稳健性**: 支持多种稳健估计方法处理数据问题 🆕
337
+
338
+ ## 使用建议
339
+
340
+ 1. **数据准备**: 确保数据格式正确,特别是多维数组的嵌套结构
341
+ 2. **参数选择**: 根据具体分析需求选择合适的模型参数
342
+ 3. **模型诊断**: 在进行推断前使用诊断工具检验模型假设 🆕
343
+ 4. **稳健性检查**: 对于可能存在异方差的数据使用稳健标准误 🆕
344
+ 5. **输出格式**: 根据后续处理需求选择合适的输出格式
345
+ 6. **错误处理**: 注意工具可能返回的错误信息,如矩阵奇异等
346
+
347
+ ## 典型工作流程 🆕
348
+
349
+ ### 标准回归分析流程
350
+ 1. 使用 `basic_parametric_estimation_ols` 进行OLS回归
351
+ 2. 使用 `model_diagnostic_tests` 检验模型假设
352
+ 3. 如发现异方差:
353
+ - 使用 `robust_errors_regression` 获取稳健标准误,或
354
+ - 使用 `weighted_least_squares` 或 `generalized_least_squares`
355
+ 4. 使用 `model_selection_criteria` 进行模型比较
356
+
357
+ ### 高维数据分析流程
358
+ 1. 使用 `regularized_regression` 处理多重共线性
359
+ 2. 通过LASSO进行变量选择
360
+ 3. 使用交叉验证选择最优alpha参数
361
+
362
+ ## 示例调用
363
+
364
+ ```python
365
+ # OLS回归分析示例
366
+ result = await mcp.basic_parametric_estimation_ols(
367
+ y_data=[1, 2, 3, 4, 5],
368
+ x_data=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
369
+ feature_names=["X1", "X2"],
370
+ constant=True,
371
+ output_format="json"
372
+ )
373
+
374
+ # 模型诊断检验示例 🆕
375
+ diagnostic_result = await mcp.model_diagnostic_tests(
376
+ y_data=[1, 2, 3, 4, 5],
377
+ x_data=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
378
+ feature_names=["X1", "X2"],
379
+ constant=True
380
+ )
381
+
382
+ # 稳健标准误回归示例 🆕
383
+ robust_result = await mcp.robust_errors_regression(
384
+ y_data=[1, 2, 3, 4, 5],
385
+ x_data=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
386
+ cov_type="HC1",
387
+ confidence_level=0.95
388
+ )
389
+
390
+ # 正则化回归示例 🆕
391
+ ridge_result = await mcp.regularized_regression(
392
+ y_data=[1, 2, 3, 4, 5],
393
+ x_data=[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],
394
+ method="ridge",
395
+ alpha=1.0
396
+ )
397
+
398
+ # ARIMA模型示例
399
+ arima_result = await mcp.time_series_arima_model(
400
+ data=[1.2, 2.1, 3.4, 4.2, 5.1, 6.3, 7.2, 8.1, 9.4, 10.2],
401
+ order=[1, 1, 1],
402
+ forecast_steps=3,
403
+ output_format="json"
404
+ )
405
+ ```
406
+
407
+ ## 更新历史
408
+
409
+ ### v2.2.0 (当前版本) 🆕
410
+ - 新增7个模型规范、诊断和稳健推断工具
411
+ - 总工具数从14个增加到21个
412
+ - 增强了模型诊断和稳健推断能力
413
+ - 添加了正则化方法支持
414
+
415
+ ### v2.1.0
416
+ - 提供14个基础工具
417
+ - 实现组件化架构
418
+ - 支持多种数据格式
419
+
420
+ ---
421
+
422
+ 这个完整指南包含了所有必要信息,帮助大模型正确理解和使用所有**21个**计量经济学工具。