是否有一种方法可以将PCSE和PRAI-WINSTEN校正包括在R中的固定效应模型中(类似于Stata中的XTPCSE函



我想在使用面板校正的标准误差以及prais-winsten(ar1(转换时估算固定效应模型,以求解面板异质性,同时的空间相关性和自动相关性。<<<<<<<<<<<<

我有时间序列的横截面数据,并希望执行回归分析。我能够估算一个固定效应模型,面板校正了标准误差和Prais-Winsten单独估计。我能够在固定效应模型中包括面板校正的标准误差。但是我希望它们一次。

# Basic ols model
ols1 <- lm(y ~ x1 + x2, data = data)
summary(ols1)
# Fixed effects model
library('plm')
plm1 <- plm(y ~ x1 + x2, data = data, model = 'within')
summary(plm1)
# Panel Corrected Standard Errors
library(pcse)
lm.pcse1 <- pcse(ols1, groupN = Country, groupT = Time)
summary(lm.pcse1)
# Prais-Winsten estimates
library(prais)
prais1 <- prais_winsten(y ~ x1 + x2, data = data)
summary(prais1)
# Combination of Fixed effects and Panel Corrected Standard Errors
ols.fe <- lm(y ~ x1 + x2 + factor(Country) - 1, data = data)
pcse.fe <- pcse(ols.fe, groupN = Country, groupT = Time)
summary(pcse.fe)

在stata命令中:xtpcse可以同时包含面板校正的标准错误和prais-winsten校正的估计,并具有以下代码:

xtpcse y x x x i.cc, c(ar1)

我也想在r中实现这一目标。

我不确定我的答案是否会完全解决您的关注,这些天我一直在尝试处理与您提到的相同问题。

在我的情况下,我从软件包 prais 中运行了Prais-Winsten函数,其中包括我的模型具有固定的效果。之后,我使用函数vcovhc.prais纠正异性恋性,该功能与vcovhc函数类似,来自包装 sandwich 。。

这基本上会给您White/Sandwich HeteroSkedaticity与符合性的协方差矩阵,如果您以后将其拟合到package lmtest 的函数coeftest中,它将为您提供校正后的标准误差的表输出。以您发布的示例,请参阅下面我使用的代码:

# Prais-Winsten estimates with Fixed Effects
library(prais)
prais.fe <- prais_winsten(y ~ x1 + x2  + factor(Country), data = data)
library(lmtest)
prais.fe.w <- coeftest(prais.fe, vcov = vcovHC.prais(prais.fe, "HC1")
h.m1 # run the object to see the output with the corrected standard errors.
我不确定这两个在实践上有什么不同,但是有些东西。

我希望我的答案有所帮助,这实际上是我的第一个答案:D

最新更新