[R-sig-Geo] localmoran p-values with/without permutation

Valerio Bartolino valerio.bartolino at uniroma1.it
Sun Feb 15 10:51:56 CET 2009


Dear list,
I've the objective to identify hotspot areas from a model prediction
over a high resolution grid. After calculating a spatial weight object I
easily applied the localmoran function from the spdep library. It's not
really clear to me the meaning of the p-values associated to the
localmoran function and how much I can rely on them in terms of
statistical significance. For instance can I use these p-values instead
using a randomization approach? I would be glad for any clarification.

Moreover, I want to calculate a statistical significance also through a
randomization approach (commonly used with Moran's I statistic). The
idea behind the randomization is rather simple, and also coding doesn't
seem too difficult, but the identified hotspots appear larger and
disaggregated respect those identified looking at the p-values provided
by the localmoran function at a similar significant level.

Did I do some mistake in the following code I wrote for the permutation?
Thanks for any advice, explanation or comment you will have

Valerio Bartolino

###########################################
require(spdep)

locMoranI.perm <- function(x, R, listw, ...){

# x is a vector of the values on which to calculate the MoranI statistic
# R, listw, ... are all the arguments passed to the localmoran function

	mat <- matrix(data=NA, nrow=R, ncol=length(x))
		for(i in 1:R){
		perm <- sample(x, replace=F)
		I.locmor <- localmoran(perm, listw, ...)
		mat[i,] <- I.locmor[,1]
		rm(I.locmor)
		rm(perm)
		}

	return(mat)
}

# I used this new function as follow:
nsim <- 1000
I.perm <- locMoranI.perm(z, R=nsim, listw=nbw)

MorI <- localmoran(z, listw=nbw)

# select for instance a 0.01 pseudo-significance level
p.perm <- apply(I.perm, 2, quantile, probs=0.99)

## because I-Moran identify spatial clustering
## high and low hotspots have no distinct I values
## make a vector to distinguish significant and high hotspots
hot <- ifelse(p.perm-MorI[,1]<0 & z>mean(z),1,0)



More information about the R-sig-Geo mailing list