# replicate Chen (2015)
data(chen)
( r <- crossCorrelation(x=chen[["X"]], y=chen[["Y"]], w = chen[["M"]],
clust=TRUE, type = "LSCI", k=0,
dist.function = "inv.power") )
# \donttest{
library(sf)
library(spdep)
if (require(sp, quietly = TRUE)) {
data(meuse, package = "sp")
meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant")
}
#### Using a default spatial weights matrix method (inverse power function)
( I <- crossCorrelation(meuse$zinc, meuse$copper,
coords = st_coordinates(meuse)[,1:2], k=99) )
meuse$lisa <- I$SCI[,"lsci.xy"]
plot(meuse["lisa"], pch=20)
#### Providing a distance matrix
if (require(units, quietly = TRUE)) {
Wij <- units::drop_units(st_distance(meuse))
( I <- crossCorrelation(meuse$zinc, meuse$copper, w = Wij, k=99) )
#### Providing an inverse power function weights matrix
Wij <- 1 / Wij
diag(Wij) <- 0
Wij <- Wij / sum(Wij)
diag(Wij) <- 0
( I <- crossCorrelation(meuse$zinc, meuse$copper, w = Wij,
dist.function = "none", k=99) )
}
# }
Run the code above in your browser using DataLab