# [R-sig-Geo] Heteroscedasticity in Spatial Error Model

Javier García javier.garcia at ehu.eus
Sat Sep 9 17:36:20 CEST 2017

```Dear Roger,

Once again thanks a lot for your help. Unfortunately we find very difficult
to do anything else to correct the possible misspecification (we have to
estimate a theoretical model where there are no more covariates, the
funtional form is given, etc), so the only way to continue with the analysis
is using robust standard deviations. Instead of using the sphet package, I
would prefer to continue with the spdep package. In page 23 in the spdep
manual it is stated 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.", and gives an example that honestly I do not understand
(what is \$tary and \$tarX? what is the lm.target component? where are they
documented?). Anyway, I have adapted the example to my case, obtaining an
estimated model with its corresponding coefficients, standard errors, etc.
My question is: is this correct? Are these standard errors already robust
under heteroskedasticity? (the model I have estimated is a spatial error
model by means of the lagsarlm() function)

Best
Javi

PD: below you can see the piece of code and the generated output

reg.SLM <- lagsarlm(precio_m2~z1+z2+z3+z4+z5+z6+z7+z8+z9+z10-1,
data=datos,W_n,method="eigen",  tol.solve=1.0e-20)

lm.target <- lm(reg.SEM\$tary ~ reg.SEM\$tarX - 1)
if (require(lmtest) && require(sandwich)) {
coeftest(lm.target, vcov=vcovHC(lm.target, type="HC0"), df=Inf)
}

z test of coefficients:

Estimate
Std. Error  z value    Pr(>|z|)
reg.SEM\$tarXI(x - lambda * WX)z1       1489.27593  124.86303 11.9273 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z2       1471.24060  135.03910 10.8949 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z3       1646.50753  126.03324 13.0641 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z4       1615.11404  232.94826  6.9334
4.110e-12  ***
reg.SEM\$tarXI(x - lambda * WX)z5       1947.56387  149.28017 13.0464 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z6       1903.80428  132.62287 14.3550 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z7       1943.40961  118.29268 16.4288 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z8       2576.77441  144.33295 17.8530 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z9       3037.47241  215.77036 14.0773 <
2.2e-16  ***
reg.SEM\$tarXI(x - lambda * WX)z10     3976.81752  260.71406 15.2536 <
2.2e-16  ***

---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

-----Mensaje original-----
De: Roger Bivand [mailto:Roger.Bivand at nhh.no]
Enviado el: domingo, 13 de agosto de 2017 12:49
Para: Javier García
CC: r-sig-geo at r-project.org
Asunto: Re: [R-sig-Geo] Heteroscedasticity in Spatial Error Model

On Sun, 13 Aug 2017, Javier García wrote:

> Hello again:
>
>
>
> Please, could anyone tell me how to estimate robust standard errors
> for a spatial error model? The residuals of my model show
> heteroscedasticity evidence, but the functions I have looked at only work
with lm type objects.
>

The documented approaches use GM rather than ML for fitting - see the sphet
package and https://www.jstatsoft.org/index.php/jss/issue/view/v063.
You should really try to remove the sources of model mis-specification
from MAUP, missing covariates and/or wrong functional forms.

Roger

>
>
> Thanks a lot in advance.
>
>
>
> Javi
>
>
>
>
>
>
> JAVIER GARCÍA
>
>
>
>
> Facultad de Economía y Empresa (Sección Sarriko) Avda. Lehendakari
> Aguirre 83
>
> 48015 BILBAO
> T.: +34 601 7126 F.: +34 601 3754
> <http://www.ehu.es/> www.ehu.es
>
> http://www.unibertsitate-hedakuntza.ehu.es/p268-content/es/contenidos/
> inform
> acion/manual_id_corp/es_manual/images/firma_email_upv_euskampus_biling
> ue.gif
>
>
>
>
>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics, Helleveien 30,
N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no Editor-in-Chief of The R
Journal, https://journal.r-project.org/index.html
http://orcid.org/0000-0003-2392-6140