[R-sig-Geo] heteroskedasticity corrections for lagsarlm() in spdep
Marco Helbich
marco.helbich at geog.uni-heidelberg.de
Fri Oct 21 18:56:37 CEST 2011
Dear Roger,
sorry for my last incomplete posting. Below is the output you need to
know using the spdep example. Can you recommend other solutions to
correct heteroskedasticity in a lagsarlm?
I appreciate your helping hand!
Best
Marco
> data(oldcol)
> example <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"))
> lm.target <- lm(example$tary ~ example$tarX - 1)
Fehler in model.frame.default(formula = example$tary ~ example$tarX - 1, :
ungültiger Typ (NULL) für die Variable 'example$tary'
> traceback()
5: model.frame.default(formula = example$tary ~ example$tarX - 1,
drop.unused.levels = TRUE)
4: model.frame(formula = example$tary ~ example$tarX - 1,
drop.unused.levels = TRUE)
3: eval(expr, envir, enclos)
2: eval(mf, parent.frame())
1: lm(example$tary ~ example$tarX - 1)
> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252
LC_MONETARY=German_Austria.1252
[4] LC_NUMERIC=C LC_TIME=German_Austria.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
base
other attached packages:
[1] robustbase_0.7-6 AER_1.1-8 strucchange_1.4-4
sandwich_2.2-7 lmtest_0.9-28 zoo_1.7-4
[7] Formula_1.0-0 car_2.0-10 survival_2.36-5
nnet_7.3-1 spdep_0.5-35 coda_0.14-4
[13] deldir_0.0-13 nlme_3.1-101 MASS_7.3-12
Matrix_0.9996875-3 boot_1.2-43 maptools_0.8-7
[19] lattice_0.19-23 sp_0.9-82 foreign_0.8-43
loaded via a namespace (and not attached):
[1] grid_2.13.0 tools_2.13.0
>
Am 21.10.2011 17:31, schrieb Roger Bivand:
> On Fri, 21 Oct 2011, Marco Helbich wrote:
>
>> 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).
>
> But your code works? Could you please be more specific about what
> doesn't work, the exact error message, the output of traceback() after
> the message, and of sessionInfo()? Of course, for the spatial lag model,
> this is really not OK, because of interaction between the covariance of
> rho and the betas. For the spatial error model, they do not interact,
> and the beta covariance matrix block is the same in OLS on the
> transformed covariates and ML.
>
> Roger
>
>>
>> Thank you in advance!
>> Best
>> Marco
>>
>>
>
--
Marco Helbich
Chair of GIScience
Department of Geography, University of Heidelberg
marco.helbich at geog.uni-heidelberg.de
http://giscience.uni-hd.de
Berliner Straße 48, D-69120 Heidelberg, Germany
fon: +49(0)6221 / 54 5572 // fax: +49(0)6221 / 54 4529
More information about the R-sig-Geo
mailing list