【发布时间】: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 = 'individual 和effect = 'time' 分别设置cluster 选项。
比如我设置coeftest代码:
cluster = 'group' in plm of fem_city for effect = 'individual' in coeftest
plm 中的 plm 中的 effect = 'time' coeftest 中的effect = 'time'
这样合适吗?
还有,如何计算city 和year 的双向稳健标准误差?
【问题讨论】:
标签: r plm standard-error robust