3
$\begingroup$

I'm working with an unbalanced panel dataset. (Country-Time) of approximate dimensions H=100 individuals i and average time length over individuals $mean(T_i)\approx7.5$. And about n= 8 regressors (appart from the fixed effects dummies).

I want to use the Durbin-Watson panel generalization from Bhargava, Alok, Luisa Franzini, and Wiji Narendranathan. "Serial correlation and the fixed effects model." The Review of Economic Studies 49.4 (1982) 533-549 (http://restud.oxfordjournals.org/content/49/4/533.short)

$d_P = \frac{ \sum_{i=1}^H \sum_{t=2}^T \left( \tilde{u}_{it} - \tilde{u}_{it-1} \right)^2 }{ \sum_{i=1}^H \sum_{t=1}^T \tilde{u}_{it}^2 }$

Critical values are given in the paper and are dependent on (T, H, n) with n the number of regressors. Which i linearly interpolate. $cv(7.5, 100, 8) \to d_{PL}=1.8561,\; d_{PU}=1.9039$

Now if i simulate data without autocorrelation I tend to find very low values for $d_P$ that reject $H0: \rho=0$

#[R]
require(data.table)
set.seed(1)
DT <- data.table(i=c(rep(1:50, each=7), rep(51:100, each=8)), 
                 t=c(rep(1:7, 50), rep(1:8, 50)), u=rnorm(100*7.5))
DT[, ':='(du2=c(NA, diff(u))^2, u2=u^2), by=i] # difference by individual

#       i t          u          du2         u2
#  1:   1 1 -0.6264538           NA 0.39244438
#  2:   1 2  0.1836433 0.6562573681 0.03372487
#  3:   1 3 -0.8356286 1.0389152808 0.69827518
#  4:   1 4  1.5952808 5.9093205817 2.54492084
# ---                                         
#746: 100 4 -1.3457937 0.1434371834 1.81116064
#747: 100 5  1.0336654 5.6618254864 1.06846414
#748: 100 6 -0.8117765 3.4056556180 0.65898102
#749: 100 7  1.8017255 6.8303923814 3.24621470
#750: 100 8  1.7715420 0.0009110448 3.13836092

DT.sumT <- DT[, list(sumdu2=sum(du2, na.rm=T), sumu2=sum(u2)), by=i] #sum over T_i
#       i    sumdu2     sumu2
#  1:   1 12.239715  4.688696
#  2:   2  8.925133  8.698205
#  3:   3  2.463443  4.030220
# ---

d_P <- DT.sumT[, sum(sumdu2)/sum(sumu2)] #sum over i
d_P # Durbin-Watson Statistic
# 1.708489
# next in seed gives --> 1.617848, 1.735762, 1.614137

Which are all < 2 so positive autocorrelation and all simulated $d_P< d_{PL}$ so 5% significant. But the data is IID...

If a negative correlation of 0.2 is forced the test does flip side but still looks downward biased:

DT[, u:=u-0.2*c(0, u[1:(length(u)-1)])]
# d_P --> 2.038816

Am I missing something here? The tabulated 5%c.v. are for T=6 and T=10 so the short+wide property should not be a problem. Also balancing the simulation to e.g. $T_i=T=7$ gives low $d_P$

$\endgroup$
  • $\begingroup$ the generalized Durbin-Watson statistic of Bhargava et al. (1982) and Baltagi/Wu's LBI statistic are now implemented in the latest development version of plm as pbnftest(). $\endgroup$ – Helix123 Jun 16 '18 at 9:54
2
$\begingroup$

Found the error myself, just thought I'd post it here to help others

DT[, ':='(du2=c(NA, diff(u))^2, u2=u^2), by=i] # difference by individual

should be

DT[, ':='(du2=c(NA, diff(u-mean(u)))^2, u2=(u-mean(u))^2), by=i] #diff by i + FE

as the $\bar{u}$ in Bhargava, Alok, Luisa Franzini, and Wiji Narendranathan is for the fixed effects model after the 'within' transformation. The reference Baltagi, B.H. (2005) Econometric Analysis of Panel Data, 3rd. ed., Wiley, p. 98. helped. Also I found an implementation in R in plm::pdwtest

this gives d_P = 1.928698 for the random noise, as expected no significant autocorrelation.

EDIT:

after some research I found out that the plm::pdwtest did not calculate the DW statistic according to: $d_P = \frac{ \sum_{i=1}^H \sum_{t=2}^T \left( \tilde{u}_{it} - \tilde{u}_{it-1} \right)^2 }{ \sum_{i=1}^H \sum_{t=1}^T \tilde{u}_{it}^2 }$ but differences the demeaned residual vector AS IS: $d([\bar{u}_{11}..\bar{u}_{1T},\,\bar{u}_{21}..\bar{u}_{2T},\bar{u}_{31} ...\bar{u}_{it}..., \bar{u}_{NT}])$. This creates the differences $\bar{u}_{i+1,1}-\bar{u}_{i,T}$ That is the difference between the last observation of individual i and the first of individual i+1. In the context of serial correlation this is NOT what you want. Here is some R code that shows this:

set.seed(1)
DT <- data.table(i=c(rep(1:50, each=7), rep(51:100, each=8)), 
                  t=c(rep(1:7, 50), rep(1:8, 50)), u=rnorm(100*7.5))
DT[, zero:=0][1, zero:=10^-10]
require(lmtest)
DT[, sum(diff(u)^2)/sum(u^2)]  # pooled result, no panel properties
# [1] 2.054083
dwtest(u ~zero, data=DT) # pooled result, no panel properties
# 
#   Durbin-Watson test
# 
# data:  u ~ zero
# DW = 2.0547, p-value = 0.7679
# alternative hypothesis: true autocorrelation is greater than 0
# 
DT[, udm:=u-mean(u), by=i][, sum(diff(udm)^2)/sum(udm^2)] #WRONG! plm::dwtest results 
# [1] 2.221074
pdwtest(plm(u ~ zero, data=DT, index=c("i", "t"))) # WRONG! diff(u) includes across individual diff u_{i+1,1}-u_{i,T}
# 
#   Durbin-Watson test for serial correlation in panel models
# 
# data:  u ~ zero
# DW = 2.2219, p-value = 0.9989
# alternative hypothesis: serial correlation in idiosyncratic errors
# 

I created a R script that does use the $d_P$ from Bhargava et al and put it on gist: https://gist.github.com/w10/3ecc693725e6486d799a#file-dwpaneltest-r

dwpaneltest(DT$u, DT$i, DT$t, 2)
# -------------------------------------------------- 
# Test: Panel Generalization of Durbin-Watson 
#   H0: Zero residual autocorrelation rho = 0 
#   Ha: Nonzero residual autocorrelation rho != 0 
# Indiv. H = 100, (mean) T = 7.50 [T.cv=7.50], regressors n = 2
#  cv(d_PL+) = 1.8740, cv(d_PU+) = 1.8858
#  cv(d_PL-) = 2.1142, cv(d_PU-) = 2.1260
# Statistic d_P = 1.93   
#   2 >  d_P  > cv(d_PU+) 
#   2 >  1.93 > 1.89 
# No residual autocorrelation. 
# -------------------------------------------------- 
# P-values from: Bhargava, Franzini & Narendranathan
# Review of Economic Studies (1982), XLIX, p.533-549 
$\endgroup$
  • $\begingroup$ The generalized Durbin-Watson statistic of Bhargava et al. (1982) and Baltagi/Wu's LBI statistic are implemented in the latest version (1.7-0) of plm as pbnftest(). $\endgroup$ – Helix123 Mar 21 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.