【问题标题】:R - fixed effect of panel data analysis and robust standard errorsR - 面板数据分析和稳健标准误差的固定效应
【发布时间】:2018-11-09 13:36:07
【问题描述】:

我正在通过 R 中的plm 包处理面板数据。现在我正在考虑组(城市)、时间以及组和时间两种方式的固定效应模型。因为我通过 Breusch-Pagan 检验检测到异方差性,所以我计算了稳健的标准误。

我阅读了?vcovHC 的帮助,但我无法完全理解如何使用coeftest

我当前的代码是:

library(plm)
library(lmtest)
library(sandwich)

fem_city <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "individual")
fem_year <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "time")
fem_both <- plm (z ~ x+y, data = rawdata, index = c("city","year"), model = "within", effect = "twoways")

coeftest(fem_city, vcovHC(fem_city, type = 'HC3', cluster = 'group')
coeftest(fem_year, vcovHC(fem_city, type = 'HC3', cluster = 'time')

为了计算稳健标准误差,coeftest 的代码是否合适?我想知道如何为effect = 'individualeffect = 'time' 分别设置cluster 选项。 比如我设置coeftest代码:

cluster = 'group' in plm of fem_city for effect = 'individual' in coeftest

plm 中的 plm 中的 effect = 'time' coeftest 中的effect = 'time'

这样合适吗?

还有,如何计算cityyear 的双向稳健标准误差?

【问题讨论】:

    标签: r plm standard-error robust


    【解决方案1】:

    如果您想对用作单个索引的变量进行聚类,请设置 cluster='group'(在您的示例中为 city)。

    如果您想对用作时间索引的变量进行聚类(在您的示例中为year),请设置cluster='time'

    即使对于固定效应单向个体模型,您也可以在时间索引上进行聚类。

    对于两个索引变量的聚类,您无法使用 plm::vcovHC 进行此操作。从提供双集群(DC = 双集群)的相同包中查看vcovDC,例如,

    coeftest(fem_city, vcovDC(fem_city)

    【讨论】:

      猜你喜欢
      • 2014-05-02
      • 2020-10-18
      • 1970-01-01
      • 2021-03-04
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 2015-01-31
      相关资源
      最近更新 更多