# [R-sig-Geo] slope of regression line in moran scatter plot

Takahiro Yoshida yoshida.takahiro at sk.tsukuba.ac.jp
Tue Feb 16 10:45:22 CET 2016

```I am sorry. I forgot to add the R-Codes.
Best,

Takahiro

####################
library(spdep)
data(baltimore)

plot(baltimore\$X, baltimore\$Y)
nb <- knn2nb(knearneigh(cbind(baltimore\$X, baltimore\$Y), k=4))
listW <- nb2listw(nb, style="W")
W <- listw2mat(listW)

y <- baltimore\$PRICE 	# as variable
Wy <- W %*% y 		# as spatially lagged variable
Z_y <- scale(y)		# as standardized　variable
Z_Wy <- scale(Wy)		# as standardized spatially lagged variable
WZ_y <- W %*% Z_y		# as spatially lagged standardized variable

## Correration coefficient
cor(y, Wy)
## (Global) Moran's I
moran.test(y, listW, randomisation=F, alternative="two.sided")

par(mfrow=c(1,3))
## Moran scatterplot
# Case [1]: lm((spatially lagged variable) ~ (variable))
# equal to moran.plot(y, listW)
plot(y, Wy, xlab="variable", ylab="spatially lagged variable",
main=paste("[1] slope of line:", round(coef(lm(Wy~y))[2], 3)))
abline(lm(Wy~y))
abline(v=mean(y), lty=2); abline(h=mean(Wy), lty=2)

# Case [2]: lm((spatially lagged standardized variable) ~ (standardized　var
iable))
# equal to moran.plot(y, listW)
plot(Z_y, WZ_y, xlab="standardized　variable", ylab="spatially lagged standa
rdized variable",
main=paste("[2] slope of line:", round(coef(lm(WZ_y~Z_y))[2], 3)))
abline(lm(WZ_y~Z_y))
abline(v=mean(Z_y), lty=2); abline(h=mean(WZ_y), lty=2)

# Case [3]: lm((standardized spatially lagged variable) ~ (standardized　var
iable))
# equal to moran.plot(y, listW)
plot(Z_y, Z_Wy, xlab="standardized　variable", ylab="standardized spatially
lagged variable",
main=paste("[3] slope of line:", round(coef(lm(Z_Wy~Z_y))[2], 3)))
abline(lm(Z_Wy~Z_y))
abline(v=mean(Z_y), lty=2); abline(h=mean(Z_Wy), lty=2)

par(mfrow=c(1,1))
####################

2016-02-15 23:39 GMT+09:00 Takahiro Yoshida :
Dear list members,

In moran scatter plot, I checked
[1] Slope of lm((spatial lagged variable) ~ (variable)): moran coefficient
(spdep:::moran.plot),
[2] Slope of lm((spatial lagged standardized variable) ~ (standardized
variable)): moran coefficient, and
[3] Slope of lm((standardized spatial lagged variable) ~ (standardized
variable)): correlation coefficient.
However, I think Anselin (1999) remark case [3] is moran coefficient. Is
it true?

Anselin, L. (1999) Interactive techniques and exploratory spatial data
analysis. In: Longley P.A., Goodchild M.F., Maguire D.J., Rhind D.W. (eds)
Geographic information system: Principles, techniques, management and
applications, 253–266, Wiley, New York.

Thanks and regards,

Takahiro

--
Takahiro Yoshida
Ph.D. student
Real Estate & Spatial Statistics Laboratory
University of Tsukuba, Japan
E-mail: yoshida.takahiro at sk.tsukuba.ac.jp

```