我正在通过plmR 中的包处理面板数据。现在我正在考虑组(城市)、时间以及组和时间两种方式的固定效应模型。因为我通过 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合适?我想知道如何为每个设置cluster选项。例如,我设置代码:effect = 'individualeffect = 'time'coeftest
cluster = 'group'在plmfem_cityeffect = 'individual'中coeftest
cluster = 'time'在plmfem_yeareffect = 'time'中coeftest
这种方式合适吗?
并且,如何计算 和 的双向稳健标准city误差year?