[Gretl-users] Heteroskedasticity tests other than White's

Allin Cottrell cottrell at wfu.edu
Wed Mar 26 21:55:16 EDT 2008


On Wed, 26 Mar 2008, Mariusz Doszy? wrote:

> I doubt that the tests you are asking for are built in gretl, 
> but it's quite easy to apply them with using scripting. You need 
> just standard commands...

Mariusz is right, these are not (yet) built-in commands, but since 
this is not the first time the Breusch-Pagan test has been 
requested, I've added it in CVS.  Goldfeld-Quandt is conceptually 
simple, but a little awkward to script since you have to sort all 
the observations by the value of the chosen Xi.  That can be done 
(see the "sortby" function) but it could be made easier (and will 
be, before long).

In the meantime, here is an illustration of how you can do 
Breusch-Pagan:

<gretlscript>
# Variants on Breusch-Pagan test, simple example

open data4-1
list xlist = 2
ols 1 0 xlist
u2 = $uhat * $uhat
ols u2 0 2 --quiet
# White-type test statistic
LM1 = $nrsq

# Basic Breusch-Pagan (Econometrica, 1979)
s2 = sum(u2)/$T
g = u2/s2
ols g 0 xlist --quiet
gbar = mean(g) 
gdev = g - gbar
TSS = sum(gdev*gdev)
ESS = $ess
# LM = one half of the explained sum of squares
LM2 = .5*(TSS-$ess)

# Koenker robust variant (Journal of Econometrics, 1981)
V = (1/$T)*sum((u2 - s2)^2)
g = u2 - s2
ols g 0 xlist --quiet
gbar = mean(g)  
gdev = g - gbar
TSS = sum(gdev*gdev)
ESS = $ess
LM3 = (TSS-ESS)/V

# compare the variants
print LM1 LM2 LM3

# shortcuts, new in gretl CVS
ols 1 0 xlist --quiet
lmtest --breusch     
lmtest --breusch --robust  # invokes Koenker
</gretlscript>

Allin Cottrell


More information about the Gretl-users mailing list