Skip to main content
Glama

R Econometrics MCP Server

R MCP 服务器

模型上下文协议 (MCP) 服务器通过 R 提供高级计量经济学建模和数据分析功能。该服务器使 AI 助手能够无缝执行复杂的计量经济学和统计分析,帮助您快速从数据中获得洞察。

特征

  • **线性回归:**运行具有可选稳健标准误差的线性模型。
  • **面板数据分析:**估计固定效应、随机效应、合并、之间和一阶差分模型。
  • **工具变量:**建立和估计 IV 回归模型。
  • **诊断测试:**评估异方差性、自相关性和模型错误指定。
  • **描述性统计:**使用 R 的 summary() 功能为数据集生成汇总统计数据。
  • **相关性分析:**计算变量之间的皮尔逊或斯皮尔曼相关性。
  • **分组聚合:**按指定列对数据进行分组,并使用 dplyr 计算汇总统计数据。
  • **资源:**访问各种计量经济学技术的参考文献。
  • **提示:**使用预定义的提示模板进行常见的计量经济学分析。

安装

使用 Docker(推荐)

  1. 构建 Docker 镜像:
    docker build -t r-econometrics-mcp .
  2. 运行容器:
docker run -it r-econometrics-mcp

手动安装

安装所需的 Python 包:

pip install -r requirements.txt

安装所需的 R 包(如果在容器外运行服务器):

install.packages(c("plm", "lmtest", "sandwich", "AER", "jsonlite"), repos="https://cloud.r-project.org/")

运行服务器:

python rmcp.py

用法

服务器通过标准输入/输出进行通信。运行以下命令:

python rmcp.py

它启动后会等待标准输入的 JSON 消息。要手动测试服务器,请创建一个包含紧凑(单行)JSON 消息的文件(例如,test_request.json)。

示例测试

创建具有以下内容的 test_request.json(单行 JSON):

{"tool": "linear_model", "args": {"formula": "y ~ x1", "data": {"x1": [1,2,3,4,5], "y": [1,3,5,7,9]}, "robust": false}}

然后运行:

cat test_request.json | python rmcp.py

输出

{"coefficients": {"(Intercept)": -1, "x1": 2}, "std_errors": {"(Intercept)": 2.8408e-16, "x1": 8.5654e-17}, "t_values": {"(Intercept)": -3520120717017444, "x1": 23349839270207356}, "p_values": {"(Intercept)": 5.0559e-47, "x1": 1.7323e-49}, "r_squared": 1, "adj_r_squared": 1, "sigma": 2.7086e-16, "df": [2, 3, 2], "model_call": "lm(formula = formula, data = data)", "robust": false}

与 Claude Desktop 一起使用

  1. 启动 Claude Desktop
  2. 打开 MCP 服务器面板
  3. 添加具有以下配置的新服务器:
    • 姓名:R计量经济学
    • 传输:stdio
    • 命令:path/to/python r_econometrics_mcp.py
    • (或者如果使用 Docker):docker run -i r-econometrics-mcp

示例查询

以下是服务器连接后可以与 Claude 一起使用的一些示例查询:

线性回归

Can you analyze the relationship between price and mpg in the mtcars dataset using linear regression?

面板数据分析

I have panel data with variables gdp, investment, and trade for 30 countries over 20 years. Can you help me determine if a fixed effects or random effects model is more appropriate?

工具变量

I'm trying to estimate the causal effect of education on wages, but I'm concerned about endogeneity. Can you help me set up an instrumental variables regression?

诊断测试

After running my regression model, I'm concerned about heteroskedasticity. Can you run appropriate diagnostic tests and suggest corrections if needed?

工具参考

线性模型

运行线性回归模型。

参数

  • formula (字符串):回归公式(例如,'y ~ x1 + x2')
  • data (对象):作为字典/JSON 对象的数据集
  • robust (布尔值,可选):是否使用稳健标准误差

面板模型

运行面板数据模型。

参数

  • formula (字符串):回归公式(例如,'y ~ x1 + x2')
  • data (对象):作为字典/JSON 对象的数据集
  • index (数组):面板索引变量(例如,['individual','time'])
  • effect (字符串,可选):效果类型:“个体”、“时间”或“双向”
  • model (字符串,可选):模型类型:'within'、'random'、'pooling'、'between' 或 'fd'

诊断

执行模型诊断。

参数

  • formula (字符串):回归公式(例如,'y ~ x1 + x2')
  • data (对象):作为字典/JSON 对象的数据集
  • tests (数组):要运行的测试(例如,['bp','reset','dw'])

iv_回归

估计工具变量回归。

参数

  • formula (字符串):回归公式(例如,'y ~ x1 + x2 | z1 + z2')
  • data (对象):作为字典/JSON 对象的数据集

资源

  • econometrics:formulas :有关常见计量经济学模型公式的信息
  • econometrics:diagnostics :诊断测试参考
  • econometrics:panel_data :R 面板数据分析指南

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

执照

MIT 许可证

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

通过 R 提供计量经济学建模功能,使 AI 助手能够执行复杂的分析,包括线性回归、面板数据模型、工具变量回归和诊断测试。

  1. 特征
    1. 安装
      1. 使用 Docker(推荐)
      2. 手动安装
    2. 用法
      1. 示例测试
    3. 与 Claude Desktop 一起使用
      1. 示例查询
        1. 线性回归
        2. 面板数据分析
        3. 工具变量
        4. 诊断测试
      2. 工具参考
        1. 线性模型
        2. 面板模型
        3. 诊断
        4. iv\_回归
      3. 资源
        1. 贡献
          1. 执照

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              Allows AI assistants to list tables, read data, and execute SQL queries through a controlled interface, making database exploration and analysis safer and more structured.
              Last updated -
              1
              580
              Python
              MIT License
              • Linux
              • Apple
            • -
              security
              A
              license
              -
              quality
              Serves as a guardian of development knowledge, providing AI assistants with curated access to latest documentation and best practices.
              Last updated -
              4
              87
              52
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              Enables AI models to interact with Linear for issue tracking and project management through capabilities like creating/searching issues, managing sprints, and retrieving workflow states.
              Last updated -
              TypeScript
            • A
              security
              F
              license
              A
              quality
              Enables AI assistants to interact with the World Bank open data API, allowing for listing and analysis of indicators across available countries.
              Last updated -
              1
              8
              Python

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/finite-sample/rmcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server