# STATA外部命令 **Repository Path**: richdo/stata ## Basic Information - **Project Name**: STATA外部命令 - **Description**: STATA外部命令合集 网络安装 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-07 - **Last Updated**: 2025-12-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Stata 命令集合 本仓库包含多个常用的 Stata 命令,适用于计量经济学和数据分析。 ## 包含的命令 ### 1. pwcorr_a **版本**: 2.49.1 (08aug2023) 用于计算和显示变量间的成对相关系数矩阵。与 Stata 官方的 `pwcorr` 命令相比,`pwcorr_a` 可以同时显示多个显著性水平(1%、5%、10%),而 `pwcorr` 一次只能显示一个显著性水平。 **主要特点**: - 同时显示 `***`(1%水平)、`**`(5%水平)和 `*`(10%水平)的显著性标记 - 支持自定义显著性水平 - 可导出到 Word 或 Excel 文档 ### 2. ftools **版本**: 2.49.1 (08aug2023) 针对大型数据集优化的 Stata 命令替代工具集。使用哈希函数而非排序来创建标识符,时间复杂度为 O(N) 而非 O(N log N)。 **主要命令**: - `fcollapse`: 数据聚合 - `fegen group`: 创建分组变量 - `fsort`: 快速排序 - `fisid`: 检查唯一标识 - `flevelsof`: 列出变量水平 - `fmerge`: 数据合并 - `join`: 数据连接 **要求**: Stata 11.2 或更高版本 ### 3. reghdfe **版本**: 6.12.5 (27Dec2023) 带有多维固定效应和多维聚类的线性回归命令。可以吸收任意数量的分类因子和因子交互项。 **主要特点**: - 支持多维固定效应 - 支持多维聚类标准误 - 可保存估计的固定效应 - 支持工具变量/GMM 回归 **要求**: - Stata 11.2 或更高版本 - 需要先安装 `ftools` ### 4. ivreghdfe **版本**: 1.1.4 (29nov2025) 带有多维固定效应的工具变量回归命令,相当于 `ivreg2` 命令的 `absorb()` 选项版本。 **要求**: - Stata 13.0 或更高版本 - 需要先安装 `ftools`、`reghdfe` 和 `ivreg2` - Stata 12 或更早版本还需要 `boottest` 包 ## 安装说明 ### 方法一:使用 install.do 文件(推荐) 1. 打开 Stata 2. 在 Stata 命令窗口中运行: ```stata do install.do ``` ### 方法二:手动安装 #### 安装 pwcorr_a ```stata net install pwcorr_a, from(https://gitee.com/richdo/stata/raw/master/pwcorr_a/latest/) replace which pwcorr_a ``` #### 安装 ftools(必须先安装) ```stata net install ftools, from(https://gitee.com/richdo/stata/raw/master/ftools/latest/) replace which ftools ``` #### 安装 reghdfe(需要先安装 ftools) ```stata net install reghdfe, from(https://gitee.com/richdo/stata/raw/master/reghdfe/latest/) replace which reghdfe ``` #### 安装 ivreghdfe(需要先安装 ftools 和 reghdfe) ```stata net install ivreghdfe, from(https://gitee.com/richdo/stata/raw/master/ivreghdfe/latest/) replace which ivreghdfe ``` ### 安装顺序 **重要**:请按照以下顺序安装命令: 1. `pwcorr_a`(独立安装,无依赖) 2. `ftools`(必须先安装) 3. `reghdfe`(依赖 ftools) 4. `ivreghdfe`(依赖 ftools 和 reghdfe) ## 验证安装 安装完成后,可以使用 `which` 命令查看命令版本,确认安装成功: ```stata which pwcorr_a which ftools which reghdfe which ivreghdfe ``` 如果命令版本没有变化,可能是 `base` 文件夹中有重复的命令。 ## 使用帮助 安装完成后,可以使用 `help` 命令查看各命令的详细帮助文档: ```stata help pwcorr_a help ftools help reghdfe help ivreghdfe ``` ## 系统目录 如果需要查看 Stata 的系统目录,可以运行: ```stata sysdir ``` `ssc install` 和 `net install` 命令会将文件安装到 `plus` 文件夹中。 ## 更多信息 - **pwcorr_a**: 详细说明请参考 [连享会文章](https://www.lianxh.cn/details/348.html) - **reghdfe**: 官方网站 http://scorreia.com/reghdfe/ - **ftools**: 作者 Sergio Correia (sergio.correia@gmail.com) ## 许可证 各命令的许可证可能不同,请查看各命令目录下的 LICENSE 文件。 ## 更新日志 - **pwcorr_a**: 2.49.1 (08aug2023) - **ftools**: 2.49.1 (08aug2023) - **reghdfe**: 6.12.5 (27Dec2023) - **ivreghdfe**: 1.1.4 (29nov2025)