我想知道为什么
pdwtest()
输出的p值与
lmtest
的和
car
是Durbin Watson测试(
dwtest()
和
dwt()
分别)。请在下面查找差异的文档。之后,我提供了从plm的源代码
pdwtest()
并试图解决这个问题。有人能看一下吗?p值仍然不匹配,但非常接近。我怀疑,这是因为数字精度?此外,我也不完全确定随机效应模型的p值,但这是一个统计问题,而不是编程问题(将截距留作测试?)。
编辑2019-01-04
:Bhargava等人(1982)的广义Durbin Watson统计和Baltagi/Wu的LBI统计现在在plm的最新版本(1.7-0)中实现为
pbnftest()
.
我认为,我们必须区分这里发生的事情:
1) p值:当附加的截距传递给lmtest::dwtest()时,p值似乎处于关闭状态。我的猜测是,这反过来导致对自由度的错误计算,从而导致可疑的p值。
参见以下文件和
http://www.stata.com/manuals14/xtxtregar.pdf
Bhargava,Franzini,Narendranathan,《序列相关性和固定效应模型》,《经济研究评论》(1982年),XLIX,第533-549页
Baltagi,B.H.和P.X.Wu。1999.具有AR(1)扰动的不等间隔面板数据回归。计量经济学理论15,第814823页。
版本:
第3.1.3条
第1.4-0页
lmtest_0.9-34
require(plm)
require(lmtest)
require(car)
data("Grunfeld")
# Use lm() for pooled OLS and fixed effects
lm_pool <- lm(inv ~ value + capital, data = Grunfeld)
lm_fe <- lm(inv ~ value + capital + factor(firm), data = Grunfeld)
# Use plm() for pooled OLS and fixed effects
plm_pool <- plm(inv ~ value + capital, data=Grunfeld, model = "pooling")
plm_fe <- plm(inv ~ value + capital, data=Grunfeld, model = "within")
plm_re <- plm(inv ~ value + capital, data=Grunfeld, model = "random")
# Are the estimated residuals for the pooled OLS and fixed effects model by plm() and lm() the same? => yes
all(abs(residuals(plm_pool) - residuals(lm_pool)) < 0.00000000001)
## [1] TRUE
all(abs(residuals(plm_fe) - residuals(lm_fe)) < 0.00000000001)
## [1] TRUE
# Results match of lmtest's and car's durbin watson test match
lmtest::dwtest(lm_pool)
## Durbin-Watson test
##
## data: lm_pool
## DW = 0.3582, p-value < 2.2e-16
## alternative hypothesis: true autocorrelation is greater than 0
car::dwt(lm_pool)
## lag Autocorrelation D-W Statistic p-value
## 1 0.8204959 0.3581853 0
## Alternative hypothesis: rho != 0
lmtest::dwtest(lm_fe)
## Durbin-Watson test
##
## data: lm_fe
## DW = 1.0789, p-value = 1.561e-13
## alternative hypothesis: true autocorrelation is greater than 0
car::dwt(lm_fe)
## lag Autocorrelation D-W Statistic p-value
## 1 0.4583415 1.078912 0
## Alternative hypothesis: rho != 0
# plm's dw statistic matches but p-value is very different (plm_pool) and slightly different (plm_fe)
pdwtest(plm_pool)
## Durbin-Watson test for serial correlation in panel models
##
## data: inv ~ value + capital
## DW = 0.3582, p-value = 0.7619
## alternative hypothesis: serial correlation in idiosyncratic errors
pdwtest(plm_fe)
## Durbin-Watson test for serial correlation in panel models
##
## data: inv ~ value + capital
## DW = 1.0789, p-value = 3.184e-11
## alternative hypothesis: serial correlation in idiosyncratic errors