R中的空间自相关分析(Global Moran's I) [英] Spatial Autocorrelation Analysis (Global Moran's I) in R

查看:881
本文介绍了R中的空间自相关分析(Global Moran's I)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个点列表,我想使用Moran的I并通过将感兴趣区域除以4 x 4个四边形来检查自相关。

I have a list of points I want to check for autocorrelation using Moran's I and by dividing area of interest by 4 x 4 quadrats.

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

Now every example I found on Google (e. g. http://www.ats.ucla.edu/stat/r/faq/morans_i.htm) uses some kind of measured value as the first input for the Moran's I function, no matter which library is used (I looked into the ape and spdep packages).

但是,我所拥有的只是要检查其相关性的点。

However, all I have are the points themselves I want to check the correlation for.

问题是,听起来可能很有趣(或悲伤),但我不知道我在这里做什么。我不是一个(空间)统计专家,我想找出的只是使用Moran的I来分散,聚集或随机分布点集。

The problem is, as funny (or sad) as this might sound, I've no idea what I'm doing here. I'm not much of a (spatial) statistics guy, all I want to find out is if a collection of points is dispersed, clustered or ramdom using Moran's I.

我的方法正确吗?如果不是在哪里以及我在做什么错呢?

Is my approach correct? If not where and what I am doing wrong?

谢谢

这是我到目前为止的事情:

This is what I have so far:

# 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("")


推荐答案

有几种方法可以做到这一点。我参加了 分析空间数据的优秀(免费)课程 ,作者是Roger Bivand的R,他非常活跃于 r-sig-geo 邮件列表(您可能希望在其中定向此查询)。您基本上想评估您的点模式在空间上是否完全随机。

There's a few ways of doing this. I took a great (free) course in analysing spatial data with R by Roger Bivand who is very active on the r-sig-geo mailing list (where you may want to direct this query). You basically want to assess whether or not your point pattern is completely spatially random or not.

您可以绘制观测点最近邻距离的经验累积分布,然后将其与 ecdf 在观察窗口内随机生成的完全空间随机的点模式集:

You can plot the empirical cumulative distribution of nearest neighbour distances of your observed points, and then compare this to the ecdf of randomly generated sets of completely spatially random point patterns within your observation window:

#  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)

观察到的最近邻居分布完全包含在灰色信封内随机生成的点模式的ecdf。我的结论是,您拥有一个完全在空间上随机的点模式,但要注意的是您没有很多点。

The observed nearest neighbour distribution is completely contained within the grey envelope of the ecdf of randomly generated point patterns. My conclusion would be that you have a completely spatially random point pattern, with the caveat that you don't have many points.

顺便说一句,在观察到的黑色线落在灰色包络线以下的情况下,我们可以推断出点之间的距离比偶然预期的要远,反之亦然。

As an aside, where the black observed line falls below the grey envelope we may infer that points are further apart than would be expected by chance and vice versa above the envelope.

这篇关于R中的空间自相关分析(Global Moran's I)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆