Closed thekingofkings closed 8 years ago
In the R/pvalue-evaluation.R script, the following function calculates the spatial matrix.
R/pvalue-evaluation.R
spatialWeight <- function( ca, leaveOneOut = -1 ) { if (leaveOneOut > -1) { ca <- ca[ ! ca$AREA_NUMBE == as.character(leaveOneOut), ] } ids <- as.numeric(as.vector(ca$AREA_NUMBE)) w1 <- nb2mat(poly2nb(ca, row.names=ids), zero.policy=TRUE) ids.name <- as.character(ids) rownames(w1) <- ids.name colnames(w1) <- ids.name w1[ids.name,ids.name] <- w1 return(w1) }
Notice that the ids is not sorted in ascending order, therefore the line
ids
w1[ids.name, ids.name] <- w1
does nothing here.
fixed
The contiguous spatial matrix calculation is wrong
In the
R/pvalue-evaluation.R
script, the following function calculates the spatial matrix.Notice that the
ids
is not sorted in ascending order, therefore the linedoes nothing here.