到源的距离的空间聚类定向测试 [英] directional testing of spatial clustering by distance from source

查看:76
本文介绍了到源的距离的空间聚类定向测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动物位置的空间数据集,如源(半径为5 km的圆形图案)周围的(x,y)点.在考虑方向性的同时,我需要测试这些点是否相对于距源较远的位置聚集(或排斥)在源周围.
我尝试过的事情:

I have a spatial dataset of animal locations, as (x,y) points around a source (circular pattern with 5 km radius). I need to test whether the points are clustered (or repulsed) around the source relative to farther from the source, while accounting for directionality.
Things I tried:

  1. 检查了最近的邻居和Ripley的K-无法弄清楚如何合并到源或方向的距离(再加上,看起来Ripley的期望矩形的窗口,而我的是圆形的)
  2. 将数据划分为基本方向(N,E,S,W)和距离区间,并计算每个距离/方向区间的点密度.然后又被卡住了.

理想地,我得到的结果可以告诉我您的点在X方向上像甜甜圈一样分布,在Y方向上是随机的,在Z方向上像山峰一样".我觉得此答案(重采样+ mad.test)对我来说可能是正确的方向,但不能完全适应我的情况...

Ideally, I'd get a result that could tell me "your points are distributed like a doughnut in direction X, are random in direction Y, and are mountain-peak-like in direction Z". I feel like this answer (resampling + mad.test) might be the right direction for me, but can't quite adapt it to my scenario...

这是一个围绕点源的圆形分布的伪数据集:

Here's a fake dataset of a circular distribution around a point source:

library(ggplot2)
library(spatstat)
library(dplyr)

set.seed(310366)
nclust <- function(x0, y0, radius, n) {
           return(runifdisc(n, radius, centre=c(x0, y0)))
         }

c <- rPoissonCluster(1000, 0.1, nclust, radius=0.02, n=2)

df <- data.frame(x = c$x - 0.5, y = c$y - 0.5) %>%
    mutate(Distance = sqrt(x^2 + y^2)) %>%
    filter(Distance < 0.5)

ggplot(df) + 
    geom_point(aes(x = x, y = y)) +
    # source point
    geom_point(aes(x = 0, y = 0, colour = "Source"), size = 2) +
    coord_fixed()

推荐答案

也许您只需研究模式的各向异性即可获得一些相关的见解(即使它可能无法为您提供所需的所有答案).

Maybe you can get some relevant insight by just studying the anisotropy of the pattern (even though it probably won't give you all the answers you are looking for).

用于检测点模式各向异性的工具包括:扇区K函数,线对方向分布,各向异性线对相关函数.这些都在空间点模式:R的方法和应用(免责声明:,我是共同作者).幸运的是,第7章是免费的示例章节之一,因此您可以在此处下载: http://book.spatstat.org/sample-chapters.html .

Tools to detect anisotropy in point patterns include: sector K-function, pair orientation distribution, anisotropic pair correlation function. These are all described in Section 7.9 of Spatial Point Patterns: Methodology and Applications with R (dislaimer: I'm a co-author). Luckily Chapter 7 is one of the free sample chapters, so you can download it here: http://book.spatstat.org/sample-chapters.html.

它不会以特殊方式对待您的源位置,因此它并不能解决整个问题,但是当您考虑要做什么时,它可能会起到启发作用.

It does not treat your source location in a special way, so it is not solving the entire problem, but it may serve as inspiration when you consider what to do.

您可以建立一个强度与距离源的距离和方向有关的泊松模型,看看是否能为您提供任何见识.

You could make a Poisson model with an intensity that depends on the distance and direction from the source and see if that gives you any insight.

由于我没有时间详细说明,下面是一些注释不清的代码段(请记住,这些只是粗略的想法-可能会有更好的选择).随时改进.

Below are some lightly commented code snippets since I don't have time to elaborate (remember these are just rough ideas -- there may be much better alternatives). Feel free to improve.

单位光盘中的均匀点:

library(spatstat)
set.seed(42)
X <- runifdisc(2000)
plot(X)

W <- Window(X)

极坐标作为协变量:

rad <- as.im(function(x,y){sqrt(x^2+y^2)}, W)
ang <- as.im(atan2, W)
plot(solist(rad, ang), main = "")

north <- ang < 45/180*pi & ang > -45/180*pi
east <- ang > 45/180*pi & ang < 135/180*pi
west <- ang < -45/180*pi & ang > -135/180*pi
south <- ang< -135/180*pi | ang > 135/180*pi
plot(solist(north, east, west, south), main = "")

plot(solist(rad*north, rad*east, rad*west, rad*south), main = "")

拟合一个简单的 log -线性模型(可以拟合更复杂的关系 与ippm():

Fit a simple log-linear model (more complicated relations could be fitted with ippm():

mod <- ppm(X ~ rad*west + rad*south +rad*east)
mod
#> Nonstationary Poisson process
#> 
#> Log intensity:  ~rad * west + rad * south + rad * east
#> 
#> Fitted trend coefficients:
#>   (Intercept)           rad      westTRUE     southTRUE      eastTRUE 
#>    6.37408999    0.09752045   -0.23197347    0.18205119    0.03103026 
#>  rad:westTRUE rad:southTRUE  rad:eastTRUE 
#>    0.32480273   -0.29191172    0.09064405 
#> 
#>                  Estimate      S.E.    CI95.lo   CI95.hi Ztest       Zval
#> (Intercept)    6.37408999 0.1285505  6.1221355 6.6260444   *** 49.5843075
#> rad            0.09752045 0.1824012 -0.2599794 0.4550203        0.5346480
#> westTRUE      -0.23197347 0.1955670 -0.6152777 0.1513307       -1.1861588
#> southTRUE      0.18205119 0.1870798 -0.1846184 0.5487208        0.9731206
#> eastTRUE       0.03103026 0.1868560 -0.3352008 0.3972613        0.1660651
#> rad:westTRUE   0.32480273 0.2724648 -0.2092185 0.8588240        1.1920904
#> rad:southTRUE -0.29191172 0.2664309 -0.8141066 0.2302832       -1.0956377
#> rad:eastTRUE   0.09064405 0.2626135 -0.4240690 0.6053571        0.3451614
plot(predict(mod))

非均匀模型:

lam <- 2000*exp(-2*rad - rad*north - 3*rad*west)
plot(lam)

set.seed(4242)
X2 <- rpoispp(lam)[W]
plot(X2)

适合:

mod2 <- ppm(X2 ~ rad*west + rad*south +rad*east)
plot(predict(mod2))
plot(X2, add = TRUE, col = rgb(.9,.9,.9,.5))

在中心添加点,然后将限制在该点的Ksector()视为 参考点(在此示例中不是很有用,但可能会有所帮助 在其他情况下??):

Add point in centre and look at Ksector() restricted to that point as the reference point (not very informative for this example, but might be helpful in other cases??):

X0 <- ppp(0, 0, window = W)
plot(X2[disc(.1)], main = "Zoom-in of center disc(0.1) of X2")
plot(X0, add = TRUE, col = "red")
dom <- disc(.01)
plot(dom, add = TRUE, border = "blue")

X3 <- superimpose(X2, X0)

估计的北方扇形K函数在西方上方(绘制的差异):

The estimated North sector K-function is above West (difference plotted):

Knorth <- Ksector(X3, 45, 135, domain = dom)
Kwest <- Ksector(X3, 135, 225, domain = dom)
plot(eval.fv(Knorth-Kwest), iso~r)

reprex软件包(v0.2.1)于2018年12月18日创建

Created on 2018-12-18 by the reprex package (v0.2.1)

这篇关于到源的距离的空间聚类定向测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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