Giuseppe Vittucci and Artur Tarassow
2.0
2016-10-28
Wooldridge test for serial correlation of residuals in panel
C23
This package computes the Wooldridge test for serial correlation of residuals in panel.
The null hypothesis is: no serial correlation.
The function prints:
- the results of the auxiliary regression for the model in first-differences;
- the results of the regression of the estimated residuals in the previous regression against their lag;
- the F-test (with the related p-value) for the null that the coefficient attached to the lagged residuals is equal to -0.5.
The function returns a matrix with:
- the point estimate of the AR coefficient;
- the test statistic;
- the p-value.
The parameters of the function are:
y - series for the dependent variable
X - list of regressors
verbose - integer (optional) for printing test output: 0=NO, 1=YES (default)
The test is discussed in: Wooldridge, J.M. 2002. Econometric Analysis of Cross Section and Panel Data. Cambridge, MA: MIT Press, pp.282-283.
Please note that the degrees of freedom for the F-test in the corresponding function in Stata (xtserial, see Drukker, D.M. 2003. Testing for serial correlation in linear panel-data models, Stata Journal 3(2), 168-177) are lower and equal to the number of cross-sectional units minus one, for the command uses the option "cluster" in the regression.
Please also note that the results obtained with the sample db provided with xtserial in Stata are different from the results obtained in gretl with the same db by using this function simply because the db has got the variable time with breaks. Ex.: year 75, 77, 80, 81...
While Stata looks at the content of the variable and does not treat as successive two time periods when they are not contiguous years, gretl does not look at the value of the variable set for the time. Therefore the two programs return different series for teh first-differenced variables.
NOTE: the return type from version 1 (scalar) to version 2 (matrix) has been
changed. To adapt the code written for version 1, add [2] at the end of the line.
For any suggestion, bug, etc. write to:
giuseppe.vittucci@unimib.it or artur.tarassow@gmail.com
dependent variable
regressors
Print details: 0=NO, 1=YES
```
# Wooldridge test for autocorrelation in panel data
# Wooldridge (2002) Econometric Analysis of Cross Section and Panel Data, pp.282-283;
# Giuseppe Vittucci (2011) and Artur Tarassow (2016).
diff y X
list dX = null
loop foreach i X --quiet
list dX += d_$i
endloop
ols d_y dX --robust --quiet
matrix coef_stde = $coeff ~ $stderr
string parnames = varname(dX)
if verbose==1
printf "\nFirst-Differenced equation (dependent d_y):\n"
modprint coef_stde parnames
printf "\nRegression of residuals of the FD equation on lagged residuals\n"
printf "uhat = rho*uhat(-1) + e\n"
endif
series u = $uhat
ols u u(-1) --robust --quiet
matrix coef_stde = $coeff ~ $stderr
scalar m = ($coeff[1,1]+0.5)^2/$vcv[1,1]
scalar p = pvalue(F, 1, $df, m)
if verbose==1
string parnames = "uhat(-1)"
modprint coef_stde parnames
printf "\nWooldridge test for autocorrelation in panel data\nH0: no first-order autocorrelation (rho = -0.5)\n"
printf "F(1,%g) = %g\n", $df, m
printf "Prob > F = %g", p
endif
mat = $coeff ~ m ~ p
colnames(mat,"ARcoeff Teststat. Pvalue")
return mat
```

include wooldridge_test_serial.gfn
open abdata.gdt
list X = n k
matrix M = wooldridge_test_serial(ys,X)
print M