在 R 中进行空间自相关分析(全局 Moran's I)

4

我有一个点列表,想用Moran's I检查自相关性,并通过将感兴趣的区域划分为4 x 4象限来完成。

现在我在Google上找到的每个示例(例如http://www.ats.ucla.edu/stat/r/faq/morans_i.htm)都使用某种测量值作为Moran's I函数的第一个输入,无论使用哪个库(我查看了ape和spdep包)。

然而,我手头只有要检查其相关性的点本身。

问题是,尽管这听起来很有趣(或悲哀),但我不知道我在这里做什么。 我不是很擅长(空间)统计学,我想找出的只是使用Moran's I方法,一个点集合是分散的,聚集的还是随机的。

我的方法正确吗? 如果不是,请指出我在哪里做错了?

谢谢。

这是我目前所拥有的:

# download, install and load the spatstat package (http://www.spatstat.org/)
install.packages("spatstat")
library(spatstat)

# Download, install and run the ape package (http://cran.r-project.org/web/packages/ape/)
install.packages("ape")
library(ape)

# Define points
x <- c(3.4, 7.3, 6.3, 7.7, 5.2, 0.3, 6.8, 7.5, 5.4, 6.1, 5.9, 3.1, 5.2, 1.4, 5.6, 0.3)
y <- c(2.2, 0.4, 0.8, 6.6, 5.6, 2.5, 7.6, 0.3, 3.5, 3.1, 6.1, 6.4, 1.5, 3.9, 3.6, 5.2)

# Store the coordinates as a matrix
coords <- as.matrix(cbind(x, y))

# Store the points as two-dimensional point pattern (ppp) object (ranging from 0 to 8 on both axis)
coords.ppp <- as.ppp(coords, c(0, 8, 0, 8))

# Quadrat count
coords.quadrat <- quadratcount(coords.ppp, 4)

# Store the Quadrat counts as vector
coords.quadrat.vector <- as.vector(coords.quadrat)

# Replace any value > 1 with 1
coords.quadrat.binary <- ifelse(coords.quadrat.vector > 1, 1, coords.quadrat.vector)

# Moran's I

# Generate the distance matrix (euclidean distances between points)
coords.dists <- as.matrix(dist(coords))

# Take the inverse of the matrix
coords.dists.inv <- 1/coords.dists

# replace the diagonal entries (Inf) with zeroes
diag(coords.dists.inv) <- 0

writeLines("Moran's I:")
print(Moran.I(coords.quadrat.binary, coords.dists.inv))
writeLines("")

提供一个可重现的示例,加一分。 - Simon O'Hanlon
1个回答

7
有几种方法可以做到这一点。我曾经参加过Roger Bivand的分析空间数据的免费课程,他在r-sig-geo邮件列表上非常活跃(您可能希望将此查询定向到该列表)。您基本上想评估您的点模式是否完全是空间随机的。您可以绘制观察点最近邻距离的经验累积分布函数图,并将其与观测窗口内完全空间随机点模式的随机生成集合的ecdf进行比较:
#  The data
coords.ppp <- ppp( x , y , xrange = c(0, 8) , yrange = c(0, 8) )

#  Number of points
n <- coords.ppp$n

#  We want to generate completely spatially random point patterns to compare against the observed
ex <- expression( runifpoint( n , win = owin(c(0,8),c(0,8))))

#  Reproducible simulation
set.seed(1)

# Compute a simulation envelope using Gest, which estimates the nearest neighbour distance distribution function G(r)
res <- envelope( coords.ppp , Gest , nsim = 99, simulate = ex ,verbose = FALSE, savefuns = TRUE )

#  Plot
plot(res)

enter image description here

观察到的最近邻分布完全包含在随机生成点模式的ecdf的灰色包络线内。我的结论是你拥有一个完全空间随机的点模式,但需要注意的是你没有很多点。
另外,当黑色观察线低于灰色包络线时,我们可以推断出点之间的距离比预期的要远,反之则相反。

@lightxx 非常欢迎你。拥有一个可重现的示例总是很有帮助的。 - Simon O'Hanlon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接