A global autocorrelation statistic for categorical data?
On Tue, 16 Feb 2021, Pedro Perez wrote:
Hello everybody!
Sorry for the dumb question, I have very limited experience with regards to
spatial autocorrelation. I have a lot of spatial points for which I
measured both continuous and categorical variables. I need to calculate
*global* measures of spatial autocorrelation for both kinds of variables. I
know that this task is relatively easy for continuous ones, here an example
using the package elsa:
rm(list = ls())
library(raster)
library(elsa)
dta <- data.frame(Lon = (runif(60)*100),
Lat = (runif(60)*100),
Cat = sample(LETTERS[1:5], 60, replace = T),
Cont = (runif(60)*100))
coordinates(dta) <- ~Lon + Lat
# Moran's I global index:
moran(dta[,2], d1=0, d2=2000)
[1] -0.01694915 # The value varies given that seed was not set
# Geary's c global index:
geary(dta[,2], d1=0, d2=2000)
[1] 1
set.seed(1)
dta <- data.frame(Lon = (runif(60)*100),
Lat = (runif(60)*100),
Cat = sample(LETTERS[1:5], 60,
replace = TRUE),
Cont = (runif(60)*100))
coordinates(dta) <- ~Lon + Lat
library(spdep)
nb <- dnearneigh(dta, 0, 50) # 2000 was far too big, all neighbours of all
moran.test(dta$Cont, nb2listw(nb, style="B"))$estimate[1]
elsa::moran(dta[,2], d1=0, d2=50)
geary.test(dta$Cont, nb2listw(nb, style="B"))$estimate[1]
elsa::geary(dta[,2], d1=0, d2=50)
joincount.multi(factor(dta$Cat), nb2listw(nb, style="B"))["Jtot",]
Jtot summarises all the k-colour matches.
Hope this clarifies,
Roger
That is, I need something like the moran or geary commands in the previous example, but applicable to categorical covariates. I have been googleing for a while, but I have not been able to find a solution. Any idea? Thanks in advance! Perep ResponderReenviar [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
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 https://orcid.org/0000-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en