All,
After running several models using -xtgls- together with the -c(p)- or
-c(a)- option, I've noticed that whatever post-estimation test for
autocorrelation I use (I've used -xtbac- [shown below] and -xtserial-),
they all show pretty serious serial correlation, despite using options
that correct for it. I don't understand why!
I've been working 'behind the curtains' of Statalist with Brian Poi at
Support, who has been outstanding and very helpful on all aspects relating
to -xtgls-, but we couldn't find a way around this 'little local
difficulty', to quote an ex-Prime Minister.
Are there any other tests for SC that anybody could suggest? I have
downloaded Kit Baum's -panelauto- suite of SC tests, but none of these are
really suitable for post-FGLS regressions.
----------------------------------------------------------------------------
*This program calculated the Baltagi test for autocorrelation in panel
data, after estimating with xtreg, xtgls, reg or areg.
*Part of this code is a modified version of the already existing command
"pantest.ado".
*author: Luca Nunziata, Nuffield College, OX1 1NF, Oxford, UK
*email: [email protected]
*Version 2.0 (15.11.02)
prog def xtbac, rclass
preserve
local tvar : char _dta[tis]
local ivar : char _dta[iis]
tempvar e ee y sumee ee1 sumee1 noo nog
tempname dnum dden N T see see1 LM LM5 chi np
quietly drop if e(sample)==0
*nog=number of groups
egen `noo'=group (`ivar')
egen `nog'=max (`noo')
scalar `N'= `nog'
scalar `T'= e(N)/`N'
if e(cmd)=="xtreg" {
xtpred `e',e
}
if e(cmd)=="areg"| e(cmd)=="regress" {
predict `e',res
}
if e(cmd)=="xtgls" {
quietly predict `y'
loc d=e(depvar)
gen `e'=`d'-`y'
}
if e(cmd)~="xtgls" & e(cmd)~="xtreg" & e(cmd)~="areg" & e(cmd)~="regress" {
display in red /*
*/ "ERROR: you didn't use either xtreg,
xtgls, reg or areg to perform last
estimation"
}
* (1) Test for serial correlation in residuals
sort `ivar' `tvar'
quietly {
gen `ee'=`e'*`e'
gen `sumee'=sum(`ee')
scalar `see'=`sumee'[_N]
by `ivar': gen `ee1'=`e'*`e'[_n-1]
/* omit 1st obs on each unit */
gen `sumee1'=sum(`ee1')
scalar `see1'=`sumee1'[_N]
scalar `LM'=`N'*`T'*(`T'/(`T'-1))*((`see1'/`see')^2)
* strictly, valid only for balanced panel
scalar `LM5'=sqrt(`LM')
* strictly, valid only for balanced panel
scalar `chi'=chiprob(1,`LM')
scalar `np'=1-normprob(abs(`LM5'))
}
return scalar LM=round(`LM',0.00001)
return scalar chi=round(`chi',0.00001)
return scalar LM5=round(`LM5',0.00001)
return scalar np=round(`np',0.000001)
dis _newline
dis in gr "Test for serial correlation in residuals"
dis in gr "Null hypothesis is either that rho=0 if residuals are AR(1)"
dis in gr "or that lamda=0 if residuals are MA(1)"
dis in gr "Following tests only approximate for unbalanced panels"
dis in gr "LM= " in ye `LM'
dis in gr "which is asy. distributed as chisq(1) under null, so:"
dis in gr "Probability of value greater than LM is " in ye `chi'
dis in gr "LM5= " in ye `LM5'
dis in gr "which is asy. distributed as N(0,1) under null, so:"
dis in gr "Probability of value greater than abs(LM5) is " in ye `np'
dis _newline
restore
end
----------------------------------------------------------------------------
CLIVE NICHOLAS |t: 0(44)191 222 5969
Politics Building |e: [email protected]
School of Geography, |f: 0(44)870 126 2421
Politics & Sociology |
University of |
Newcastle-upon-Tyne |
Newcastle-upon-Tyne |
NE1 7RU |
United Kingdom |http://www.ncl.ac.uk/geps
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/