You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在reghdfe模型的esttab LaTeX输出中添加固定效应标识

解决reghdfe+esttab添加固定效应YES/NO标识列的方法

当然可以实现,核心是利用esttab的indicate()选项匹配reghdfe生成的固定效应变量(或自定义的吸收效应名称),具体有两种常用方式:

方式1:匹配固定效应虚拟变量的前缀

当你用a(i.industry)加入行业固定效应时,Stata会自动生成以_Iindustry_为前缀的虚拟变量(比如_Iindustry_1、_Iindustry_2等)。直接在esttab里用通配符匹配这个前缀即可:

// 先运行reghdfe模型
reghdfe y x, cl(i.industry) a(i.industry)

// 用esttab输出并添加Industry FE标识列
esttab, indicate("Industry FE = _Iindustry_*")

这样输出的结果里就会多出一列「Industry FE」,对应模型里纳入了该固定效应就显示YES,未纳入则显示NO。

方式2:给吸收效应命名后直接调用

更简洁的方式是给reghdfe的a()选项里的固定效应起个名字,之后在esttab里直接用这个名字匹配:

// 运行模型时给行业固定效应命名为industry_fe
reghdfe y x, cl(i.industry) a(industry_fe = i.industry)

// esttab里直接调用命名好的效应
esttab, indicate("Industry FE = industry_fe")

这种方式不用记虚拟变量的前缀,更清晰,尤其当你有多个固定效应时(比如同时加行业和年份FE),可以批量处理:

reghdfe y x, cl(i.industry) a(industry_fe = i.industry year_fe = i.year)
esttab, indicate("Industry FE = industry_fe" "Year FE = year_fe")

小提示

如果不确定固定效应虚拟变量的前缀,可以运行estimates list查看当前估计结果的变量,或者用describe命令查看数据里新增的虚拟变量,确认前缀后再写indicate()的匹配规则。

内容的提问来源于stack exchange,提问作者cascom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 11:37:49