[R-sig-Geo] Differences between moran.test and lm.morantest

Javier García javier.garcia at ehu.eus
Sat Jul 29 03:51:23 CEST 2017


Hello everybody:

 

Currently I am working on a paper in which we need to analyze the presence
of possible spatial correlation in the data. With this aim I am running some
tests in R. I am a little bit confused about the differences between
moran.test and lm.morantest R functions. The problem I face to is that when
I run moran.test on my  regression residuals the result is totally different
from the one I obtain when I use lm.morantest with the lm regression object
(please, see below the different outputs I get and after it a reproducible
example). In particular, whereas the observed Moran I is the same, the
expectation and variance differ dramatically, getting opposite conclusions.
I would appreciate very much if someone could clarify for me which is the
cause behind this. By the way, I also run LM tests (LMerr, RLMerr, LMlag and
RLMlag) not rejecting the null hypothesis in any of them (all p-values are
higher than 0.7), which is in clear contradiction with the lm.morantest
 how
is this possible?

 

 

MY PARTICULAR CASE 

 

reg.OLS <- lm(y~z1+z2+z3+z4+z5+z6+z7+z8+z9+z10, data=datos)

 

moran.test(resid(reg.OLS),alternative="two.sided", W_n)

 

        Moran I test under randomisation

 

data:  resid(reg.OLS)  

weights: W_n  

 

Moran I statistic standard deviate = 0.4434, p-value = 0.6575

alternative hypothesis: two.sided

sample estimates:

Moran I statistic       Expectation          Variance 

     1.596378e-05     -3.595829e-04      7.173448e-07

 

 

 

moran.lm <-lm.morantest(reg.OLS, W_n, alternative="two.sided")

print(moran.lm)

 

        Global Moran I for regression residuals

 

data:  

model: lm(formula = y ~ z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8 + z9 + z10

, data = datos)

weights: W_n

 

Moran I statistic standard deviate = 11.649, p-value < 2.2e-16

alternative hypothesis: two.sided

sample estimates:

Observed Moran I      Expectation         Variance 

    1.596378e-05    -1.913005e-03     2.741816e-08

 

 

A REPRODUCIBLE EXAMPLE

 

 

library(spdep)

data(oldcol)

oldcrime.lm <- lm(CRIME ~ HOVAL + INC + OPEN + PLUMB + DISCBD + PERIM, data
= COL.OLD)

 

moran.test(resid(oldcrime.lm), nb2listw(COL.nb, style="W"))

 

        Moran I test under randomisation

 

data:  resid(oldcrime.lm)  

weights: nb2listw(COL.nb, style = "W")  

 

Moran I statistic standard deviate = 1.2733, p-value = 0.1015

alternative hypothesis: greater

sample estimates:

Moran I statistic       Expectation          Variance 

      0.096711162      -0.020833333       0.008521765

 

 

lm.morantest(oldcrime.lm, nb2listw(COL.nb, style="W"))

 

        Global Moran I for regression residuals

 

data:  

model: lm(formula = CRIME ~ HOVAL + INC + OPEN + PLUMB + DISCBD +

PERIM, data = COL.OLD)

weights: nb2listw(COL.nb, style = "W")

 

Moran I statistic standard deviate = 1.6668, p-value = 0.04777

alternative hypothesis: greater

sample estimates:

Observed Moran I      Expectation         Variance 

     0.096711162     -0.052848581      0.008050938 

 

Thanks a lot in advance and sorry for the inconvenience.

 

Javi

 

 

	


JAVIER GARCÍA 

 

Departamento de Economía Aplicada III (Econometría y Estadística)

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_bilingue.gif

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20170729/3f3c891e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 6359 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20170729/3f3c891e/attachment.gif>


More information about the R-sig-Geo mailing list