代码之家  ›  专栏  ›  技术社区  ›  Helix123

p值错误的plm的pdwtest(和统计?)对于面板模型和集合OLS(Durbin Watson自相关检验)?

  •  0
  • Helix123  · 技术社区  · 9 年前

    我想知道为什么 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
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Helix123    5 年前

    这里是“plm”开发人员。奇怪的p值值得调查(注意 pdwtest 只是一个包装 dwtest 来自程序包 lmtest ),感谢您的报道。

    关于这背后的计量经济学:Bharghava等人的检验基本上是什么 pdwtest() 做德宾-沃森测试在很多方面都是次优程序,因此大多数现代教科书都倾向于使用布鲁斯·戈弗雷(参见 pbgtest() 在面板版本的“plm”中)。RE很好,因为变换后的残差在H0下是“白色”的。由于降级导致的序列相关性,因此应谨慎对待FE,因此DW和BG测试通常是 不恰当的 除了非常长的面板:见我在JStatSoft 27/2008,p.26中的评论。更好的选择,特别是对于宽面板,是Wooldridge的测试:第一差异测试( pwfdtest() 在“plm”中,也在Stata中,参见Drukker的论文),并且在“plm”中实现的测试为 pwartest() ,再次参见JStatSoft 27/2,6.4。