Spatial cross correlation
Calculates univariate or bivariate spatial cross-correlation using local Moran's-I (LISA), following Chen (2015)
crossCorrelation( x, y = NULL, coords = NULL, w = NULL, type = c("LSCI", "GSCI"), k = 1000, dist.function = "inv.power", scale.xy = TRUE, scale.partial = FALSE, scale.matrix = FALSE, alpha = 0.05, clust = TRUE, return.sims = FALSE )
x |
Vector of x response variables |
y |
Vector of y response variables, if not specified the univariate statistic is returned |
coords |
A matrix of coordinates corresponding to [x,y], only used if k = NULL. Can also be an sp object with relevant x,y coordinate slot (ie., points or polygons) |
w |
Spatial neighbors/weights in matrix format. Dimensions must match [n(x),n(y)] and be symmetrical. If w is not defined then a default method is used. |
type |
c("LSCI","GSCI") Return Local Spatial Cross-correlation Index (LSCI) or Global Spatial cross-correlation Index (GSCI) |
k |
Number of simulations for calculating permutation distribution under the null hypothesis of no spatial autocorrelation |
dist.function |
("inv.power", "neg.exponent") If w = NULL, the default method for deriving spatial weights matrix, options are: inverse power or negative exponent |
scale.xy |
(TRUE/FALSE) scale the x,y vectors, if FALSE it is assumed that they are already scaled following Chen (2015) |
scale.partial |
(FALSE/TRUE) rescale partial spatial autocorrelation statistics [-1 - 1] |
scale.matrix |
(FALSE/TRUE) If a neighbor/distance matrix is passed, should it be scaled using [w/sum(w)] |
alpha |
= 0.05 confidence interval (default is 95 pct) |
clust |
(FALSE/TRUE) Return approximated lisa clusters |
return.sims |
(FALSE/TRUE) Return randomizations vector n = k |
When not simulated k=0, a list containing:
I Global autocorrelation statistic
SCI A data.frame with two columns representing the xy and yx autocorrelation
nsim value of NULL to represent p values were derived from observed data (k=0)
p Probability based observations above/below confidence interval
t.test Probability based on t-test
clusters If "clust" argument TRUE, vector representing LISA clusters
when simulated (k>0), a list containing:
I Global autocorrelation statistic
SCI A data.frame with two columns representing the xy and yx autocorrelation
nsim value representing number of simulations
global.p p-value of global autocorrelation statistic
local.p Probability based simulated data using successful rejection of t-test
range.p Probability based on range of probabilities resulting from paired t-test
clusters If "clust" argument TRUE, vector representing lisa clusters
Chen., Y. (2015) A New Methodology of Spatial Cross-Correlation Analysis. PLoS One 10(5):e0126158. doi:10.1371/journal.pone.0126158
library(sp) library(spdep) data(meuse) coordinates(meuse) <- ~x+y #### Providing a neighbor contiguity spatial weights matrix all.linked <- max(unlist(nbdists(knn2nb(knearneigh(coordinates(meuse))), coordinates(meuse)))) nb <- nb2listw(dnearneigh(meuse, 0, all.linked), style = "B", zero.policy = TRUE) Wij <- as.matrix( as(nb, "symmetricMatrix") ) I <- crossCorrelation(meuse$zinc, meuse$copper, w = Wij, clust=TRUE, k=99) meuse$lisa <- I$SCI[,"lsci.xy"] spplot(meuse, "lisa") #meuse$lisa.clust <- as.factor(I$cluster) #spplot(meuse, "lisa.clust") #### Using a default spatial weights matrix method (inverse power function) I <- crossCorrelation(meuse$zinc, meuse$copper, coords = coordinates(meuse), clust = TRUE, k=99) meuse$lisa <- I$SCI[,"lsci.xy"] spplot(meuse, "lisa") #meuse$lisa.clust <- as.factor(I$cluster) # spplot(meuse, "lisa.clust")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.