[R-sig-Geo] heteroskedasticity corrections for lagsarlm() in spdep
Marco Helbich
marco.helbich at geog.uni-heidelberg.de
Fri Oct 21 13:11:37 CEST 2011
Dear list,
I have estimate a spatial simultaneous autoregressive lag model by means
of the lagsarlm() function in the spdep package. The Breusch-Pagan test
for spatial models bptest.sarlm() shows that there are some problems
with heteroskedasticity.
On p. 21 in the spdep manual states that "it is also technically
possible to make heteroskedasticity corrections to standard error
estimates by using the “lm.target” component of sarlm objects - using
functions in the lmtest and sandwich packages."
First I thought the code below could be the solution, but it fails. I
have slightly adapted the code (lagsarlm instead of errorsarlm) on page 21.
data(oldcol)
example <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, nb2listw(COL.nb,
style="W"))
lm.target <- lm(example$tary ~ example$tarX - 1)
if (require(lmtest) && require(sandwich)) {
coeftest(lm.target, vcov=vcovHC(lm.target, type="HC0"), df=Inf)
}
I am sure anyone has already done this. I would appreciate every hint or
piece of code (and sorry if this is nonsense).
Thank you in advance!
Best
Marco
--
Marco Helbich
Department of Geography
University of Heidelberg
marco.helbich at geog.uni-heidelberg.de
Berliner Straße 48, D-69120 Heidelberg, Germany
More information about the R-sig-Geo
mailing list