|
you can try R package "spdep"
Spatial dependence: weighting schemes, statistics and models
###############
library(spdep)
data(oldcol)
test1=moran.test(COL.OLD$CRIME, nb2listw(COL.nb, style="W"))
>test1
Moran's I test under randomisation
data: COL.OLD$CRIME
weights: nb2listw(COL.nb, style = "W")
Moran I statistic standard deviate = 5.6341, p-value = 8.797e-09
alternative hypothesis: greater
sample estimates:
Moran I statistic Expectation Variance
0.510951264 -0.020833333 0.008908762
######## moran's I - exact test
test2=moran.test(COL.OLD$CRIME, nb2listw(COL.nb, style="W"),
+ randomisation=FALSE)
>test2
Moran's I test under normality
data: COL.OLD$CRIME
weights: nb2listw(COL.nb, style = "W")
Moran I statistic standard deviate = 5.6754, p-value = 6.92e-09
alternative hypothesis: greater
sample estimates:
Moran I statistic Expectation Variance
0.510951264 -0.020833333 0.008779831
####自行运算如下
statistic standard deviate =(0.5109513-( -0.020833333 ))/sqrt( 0.008779831)=5.6754
alternative == "greater"
p=pnorm(5.6754,lower.tail=FALSE)=6.918248e-09
|