楼主: xuehe
8458 6

[stata资源分享] 扩展工具变量多重高维固定效应面板回归命令ivreghdfe的github安装与本地安装 [推广有奖]

贵宾

已卖:14808份资源

学术权威

87%

还不是VIP/贵宾

-

威望
8
论坛币
577234 个
通用积分
483.3162
学术水平
370 点
热心指数
366 点
信用等级
207 点
经验
356065 点
帖子
4313
精华
8
在线时间
2646 小时
注册时间
2004-12-31
最后登录
2025-12-16

楼主
xuehe 发表于 2019-12-2 04:17:29 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
Run IV/2SLS with many levels of fixed effects (i.e. ivreg2+reghdfe)

This package integrates reghdfe into ivreg2, through an absorb() option. This allows IV/2SLS regressions with multiple levels of fixed effects.

Comparison with other commands

As seen in the table below, ivreghdfe is recommended if you want to run IV/LIML/GMM2S regressions with fixed effects, or run OLS regressions with advanced standard errors (HAC, Kiefer, etc.)

Commandregressaregreghdfeivreg2ivreghdfe
Models:OLSOLSOLSOLS, IV, LIML, GMM2S, CUEOLS, IV, LIML, GMM2S (not CUE!)
Fixed effects?-One-wayMulti-way-Multi-way
Cluster SE?One-wayOne-wayMulti-wayTwo-wayTwo-way
Additional SEs:---AC, HAC, Kiefer, Driscol-Kraay, etc.AC, HAC, Kiefer, Driscol-Kraay, etc.
(Speed) Time without FEs:1x-2x3.7x4.3x
(Speed) Time with one FE:-6.3x2.1x-4.6x

(Benchmark run on Stata 14-MP (4 cores), with a dataset of 4 regressors, 10mm obs., 100 clusters and 10,000 FEs)

Installation

ivreghdfe requires three packages: ivreg2, reghdfe (version 5.x) and ftools. Run the lines below to install everything you might possibly need:

* Install ftools (remove program if it existed previously)cap ado uninstall ftoolsnet install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")* Install reghdfecap ado uninstall reghdfenet install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")* Install boottest (Stata 11 and 12)if (c(version)<13) cap ado uninstall boottestif (c(version)<13) ssc install boottest* Install moremata (sometimes used by ftools but not needed for reghdfe)cap ssc install moremata* Install ivreg2, the core packagecap ado uninstall ivreg2ssc install ivreg2* Finally, install this packagecap ado uninstall ivreghdfenet install ivreghdfe, from(https://raw.githubusercontent.co ... reghdfe/master/src/)

If you are in a server, you can also download the zipfile and install it locally:

cap ado uninstall ivreghdfenet install ivreghdfe, from(c:\git\ivreghdfe)Advice

This code just modifies ivreg2 adding an absorb() option that uses reghdfes Mata functions (see this link for the line-by-line differences). When used, absorb() will also activate the small, noconstant and nopartialsmall options of ivreg2 (basically to force small sample adjustments, which are required as we might have a substantial number of fixed effects).

If you need to pass optimization options directly to reghdfe (e.g. tolerance, choice of transform, etc.) you can do that as a suboption of absorb():

sysuse auto, clearivreghdfe price weight (length=gear), absorb(turn trunk, tol(1e-6) accel(sd))

This is gives the same result as using the old version of reghdfe (but slower):

reghdfe price weight (length=gear), absorb(turn trunk) tol(1e-6) accel(sd) old
Residuals

To save residuals, do this:

sysuse autoivreghdfe price weight, absorb(trunk, resid(myresidname))

Notice the resid() option within absorb. If you call it without parenthesis, residuals will be saved in the variable _reghdfe_resid.

You can also use the other predict options of reghdfe, such as d:

predict d, d

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:GitHub IVREG 工具变量 固定效应 面板回归

沙发
xuehe 发表于 2019-12-2 04:18:50

藤椅
xuehe 发表于 2020-7-12 18:23:22
stata.rar (317 Bytes, 需要: 2 个论坛币) 本附件包括:
  • stata.toc

reghdfe-master.zip (1.21 MB, 需要: 3 个论坛币)
reghdfe.rar (1.06 MB, 需要: 5 个论坛币)
ivreghdfe-master.zip (63.26 KB, 需要: 5 个论坛币)
ivreghdfe.rar (70 KB, 需要: 3 个论坛币)
ftools-master.zip (325.12 KB, 需要: 2 个论坛币)
ftools.rar (313.91 KB, 需要: 3 个论坛币)


板凳
xuehe 发表于 2020-7-12 19:07:51

报纸
xuehe 发表于 2020-7-12 19:09:42

地板
xuehe 发表于 2020-7-12 19:11:03
机器学习:https://bbs.pinggu.org/thread-9060708-1-1.html

7
suq416319 发表于 2023-3-6 11:45:48
请问这个下载完放哪里

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-16 16:23