关于 deHaan (2021) 的具体内容,本文不做详细介绍,有兴趣的读者可以自行阅读原文。本文主要介绍 deHaan (2021) 附录 A 中关于 Good Practices when Using Fixed Effects 的内容,以及 Sergio Correia (reghdfe 命令的作者)、Ed deHaan、Ties de Kok 等三位作者为此编写的 Stata 包 SUMHDFE。
2. 固定效应使用建议
以下是使用固定效应时的一些注意事项:
注意固定效应将分析限定在组内 的变动上;
认真思考你是否需要固定效应:
如果不可观测变量 被认为与 和 都相关,并且在组内是常数,则 FE 是需要的。控制 FE 可以降低犯第一类错误的概率;
如果不可观测变量 与 不相关,则 FE 是不需要的。控制 FE 会增加犯第二类错误的概率,特别是当 与 相关时;
如果不可观测变量 仅与 相关,则 FE 是需要的。控制 FE 可以提高模型拟合度,并降低犯第二类错误的概率。
对于连续变量,报告 和其他关键变量的混合标准差 (pooled standard deviations)、组内标准差、以及由 FE 引起标准差的减少程度:
如果只保留了较少的标准差,则需要重新考虑 FE 结构是否合适。
当使用 标准差来解释回归系数的经济影响大小时,请使用组内标准差。
研究者在使用固定效应模型时,应当考虑以下信息:
其中,(i) 到 (iv) 为混合样本的统计结果;(v) 为同时考虑 FE 所有分组时,变量组内只有一个观测值的数量;(vi) 到 (vii) 为变量在 FE 组内没有变动的观测值数量;(viii) 为同时考虑 FE 所有分组时,变量组内标准差;(ix) 为变量组内标准差除以混合样本标准差,用以度量 FE 导致的标准差减少程度。
*作者提供的安装方式 *Uninstall any old versions of ftools, reghdfe, sumhdfe cap ado uninstall ftools cap ado uninstall reghdfe cap ado uninstall sumhdfe
*Install the most recent version of ftools, reghdfe, and sumhdfe net install ftools, from('https://raw./sergiocorreia/ftools/master/src/') net install reghdfe, from('https://raw./sergiocorreia/reghdfe/master/src/') net install sumhdfe, from('https://raw./ed-dehaan/sumhdfe/master/src/')
*To generate rtf files you also need to install rtfutil ssc install rtfutil
cap ado uninstall ftools cap ado uninstall reghdfe cap ado uninstall sumhdfe
net install ftools, from('D:\连享会\ftools-master\src') net install reghdfe, from('D:\连享会\reghdfe-master\src') net install sumhdfe, from('D:\连享会\sumhdfe-main\src')
*连享会命令安装 cap ado uninstall ftools cap ado uninstall reghdfe cap ado uninstall sumhdfe
Panel D: Residual variation after partialling-out ------------------------------------------------------------------------------------------------- | | Std. Dev. | R2 by fixed effect | R2 Variable | N* | Pooled Within* Ratio (%) | firm year | Overall -----------------+----------+---------------------------------+------------------------+--------- y | 585 | 502.1975 190.0668 37.85 | 0.816 0.113 | 0.866 x1 | 585 | 79.73515 22.68065 28.44 | 0.871 0.132 | 0.924 x2 | 585 | 9.809758 8.419488 85.83 | 0.254 0.055 | 0.308 ------------------------------------------------------------------------------------------------- Note: columns with * were computed excluding singleton observations
. *计算固定效应中变量标准差 . egen miss = rowmiss(y x1 x2) // 三个变量存在缺失值个数 . qui: reghdfe x1 if miss == 0, a(firm year) res(x1_res) . qui: sum x1_res . dis `r(sd)'
22.680647
. *计算固定效应对变量的解释能力 . //需要注意的是,这里不能使用 reghdfe 命令, . //因为该命令会自动删掉 singletons . qui: reg x1 i.firm if miss == 0 . est store m1 . qui: reg x1 i.year if miss == 0 . est store m2 . qui: reg x1 i.firm i.year if miss == 0 . est store m3 . esttab m1 m2 m3, r2 indicate('Frim FE = *.firm' 'Year FE = *.year') nogaps
------------------------------------------------------------ (1) (2) (3) x1 x1 x1 ------------------------------------------------------------ _cons 106.9*** 166.3* 51.39 (6.98) (2.17) (1.20) Frim FE Yes No Yes Year FE No Yes Yes ------------------------------------------------------------ N 623 623 623 R-sq 0.871 0.132 0.924 ------------------------------------------------------------
当然上述四张表也可以通过 sumhdfe_export 命令,导出为 .rtf 和 .tex 格式文档。例如,导出 .rtf 格式,具体命令如下。其中,panels(a b c d) 为导出四张表,也可以通过 panels(a b) 只导出 Panel A 和 Panel B。
. sumhdfe y x1 x2, a(firm year) . sumhdfe_export using table.rtf, panels(a b c d) sumhdfe tables saved in table.rtf