【问题标题】:How to run panel regression with both individual and time fixed effects?如何运行具有个人和时间固定效应的面板回归?
【发布时间】:2018-08-27 10:12:18
【问题描述】:

我正在尝试在 Stata 中运行具有个人和时间固定效应的面板回归。我的样本中有很多个人和时间段,所以我不想打印所有这些人的结果。但是我在网上阅读的文档只显示了如何使用一种固定效应运行面板回归,而不显示固定效应估计值:

xtset id time
xtreg y x, fe  //this makes id-specific fixed effects

areg y x, absorb(id)

以上两个代码给出相同的结果。

有谁知道如何运行具有 id 和 time 固定效应但不显示两者的估计值的面板回归?

【问题讨论】:

    标签: stata panel-data dummy-variable economics


    【解决方案1】:

    至少有一些用户编写的命令可以处理 Stata 中的高维 FE。

    以下是我经常使用的两个:

    capture ssc install regxfe
    capture ssc install reghdfe
    webuse nlswork
    regxfe ln_wage age tenure hours union, fe(ind_code occ_code idcode year)
    reghdfe ln_wage age tenure hours union, absorb(ind_code occ_code idcode year)
    

    您可能还会觉得这个Statalist thread 很有趣。

    另一种选择是使用margins 在抑制回归输出后仅显示您想要关注的相关输出:

    quietly xtreg ln_wage age tenure hours union i.(ind_code occ_code year), fe
    margins, dydx(age tenure hours union)
    

    当 FE 的数量变大时,这不太容易处理,并且会掩盖模型的其他问题。

    【讨论】:

      【解决方案2】:

      我找到了另一个解决方案:

       quietly xi: xtreg y x i.time, fe
       estimates store model1, title(Model 1)
       estimates table model1, keep(x) b se
      

      这样,时间和个体固定效应都包括在内,但只打印感兴趣变量 (x) 的估计值。

      【讨论】:

      • 这是我第二种方法的变体。如果您想对估计结果做点什么,您可以在边距中添加post 选项。此外,如果您有最新版本的 Stata,则不需要 xi 前缀。见help fvvarlist
      猜你喜欢
      • 1970-01-01
      • 2016-03-25
      • 2020-03-20
      • 2018-02-21
      • 1970-01-01
      • 2017-05-10
      • 2023-03-18
      • 2021-12-25
      • 2021-12-03
      相关资源
      最近更新 更多