【问题标题】:Is it possible to analyse a spatial point pattern given another, underlying, spatial point pattern in R给定R中的另一个潜在空间点模式,是否可以分析空间点模式
【发布时间】:2020-01-20 20:30:15
【问题描述】:

我想分析动物所显示的空间模式类型(即随机、聚集、统一),同时考虑其可用栖息地的潜在空间模式。有问题的动物栖息在树上,因此对动物 spp 的标准分析将始终显示聚集分布(即聚集在树木周围),但我想测试树木之间是否存在聚集,以及它们是否在整个树木中随机分布。为了提供视觉效果,我希望能够区分图像中的以下场景:

https://imgur.com/a/iE3nAoh(不允许使用图像,因为我是堆栈溢出的新手,但可以通过链接获得)

这是一个可重现的数据框。这里的场景是统一的栖息地(25 个栖息地区域)和统一的动物(每个栖息地 16 只动物):

library(spatstat)
data <- data.frame(matrix(ncol = 4, nrow = 25))
x <- c("habitat", "x", "y", "animalcount")
colnames(data) <- x
data$habitat <- 1:25
data$x <- seq(from=2, to=20, by=4)
data$y[1:5] <- 2
data$y[6:10] <- 6
data$y[11:15] <- 10
data$y[16:20] <- 14
data$y[21:25] <- 18
data$animalcount <- 16

为空间分析设置条件:

plot.win <- owin(c(0,20), c(0,20)) # set the plot window as 20x20m
nS <- 499 # number of simulations
cd <- 5 # cluster distance
ed <- 50 # envelope distance
incr.dist <- 0.5 # increment distance for envelopes

为栖息地创建点模式:

habitat <- ppp(x = data$x, y = data$y, window = plot.win)

为动物创建点图案。为此,首先创建一个新的数据框,其中包含重复行的动物计数,以便点是个体动物。抖动 x/y 使 x/y 坐标不完全相同:

data <-data[which(data$animalcount>0),]
duplicate_rows <- function(habitat, x, y, animalcount) {
  expanded <- paste0("animal-", 1:animalcount)
  repeated_rows <- data.frame("habitat" = habitat, "x" = x, "y" = y, "animalcount" = expanded)
  repeated_rows
}
expanded_rows <- Map(f = duplicate_rows, data$habitat, data$x, data$y, data$animalcount)
animal_data <- do.call(rbind, expanded_rows)
animal_data$xan <- jitter(animal_data$x)
animal_data$yan <- jitter(animal_data$y)

animal <- ppp(x = animal_data$xan, y = animal_data$yan, window = plot.win)

现在测试动物的完全空间随机性,而不考虑栖息地。这应该以集群形式出现:

an.csr <- envelope(animal, Kest, nsims = nS, savepatterns = TRUE, r = seq(0, ed, incr.dist), correction=c("Ripley"), verbose = FALSE) #CSR fit and determine the number of simulations
an.dclf <- dclf.test(an.csr, rinterval = c(0,cd), verbose = FALSE) #calculate the summary statistics of the CSR null model fit (dclf.test)
plot(an.csr, sqrt(./pi)-r~r, ylab="L(r)-r", xlab="r (meters)", xlim=c(0,ed), legend="NULL", main=paste("Animal - CSR", sep = "")) #plot 0-centered fit with the confidence bounds 
clarkevans(animal)[2] #R > 1 suggests ordering, < 1 suggests clustering
clarkevans.test(animal, "Donnelly")$p

现在在给定可用栖息地的情况下测试动物的完全空间随机性。这应该不是聚集的。但简单地将栖息地添加为协变量显然不是合适的方法:

an.csr <- envelope(animal, covariates = animal_data[,2:3], Kest, nsims = nS, savepatterns = TRUE, r = seq(0, ed, incr.dist), correction=c("Ripley"), verbose = FALSE)
an.dclf <- dclf.test(an.csr, rinterval = c(0,cd), verbose = FALSE) 
plot(an.csr, sqrt(./pi)-r~r, ylab="L(r)-r", xlab="r (meters)", xlim=c(0,ed), legend="NULL", main=paste("Animal - CSR", sep = "")) 
clarkevans(animal)[2] 
clarkevans.test(animal, "Donnelly")$p

我还尝试在拟合点过程模型上运行完全空间随机性测试,其中可以通过 x&y 预测动物点模式,但这也没有改变结果:

animalppm<-ppm(animal~x+y)
an.csr <- envelope(animalppm, Kest, nsims = nS, savepatterns = TRUE, r = seq(0, ed, incr.dist), correction=c("Ripley"), verbose = FALSE) 
an.dclf <- dclf.test(an.csr, rinterval = c(0,cd), verbose = FALSE) 
plot(an.csr, sqrt(./pi)-r~r, ylab="L(r)-r", xlab="r (meters)", xlim=c(0,ed), legend="NULL", main=paste("Animal - CSR", sep = "")) 
clarkevans(animalppm)[2] #R > 1 suggests ordering, < 1 suggests clustering
clarkevans.test(animalppm, "Donnelly")$p

从那里我将运行聚合模型的测试,但添加第二个点模式的逻辑应该是相似的。

我将不胜感激有关处理此问题的方法的任何建议。我想不出一种有效的方法来谷歌这个,并且在 R 中缺少聪明的编码解决方案。提前致谢!

【问题讨论】:

    标签: r spatial spatstat


    【解决方案1】:

    您可以将强度建模为取决于到 栖息地格局。这是一个简单的例子,动物遵循泊松 具有强度函数的点过程,它随距离呈对数线性衰减 到栖息地:

    library(spatstat)
    
    data <- expand.grid(x = seq(2, 18, by=4), y = seq(2, 18, by=4))
    data$animalcount <- 16
    
    plot.win <- owin(c(0,20), c(0,20)) # set the plot window as 20x20m
    
    habitat <- ppp(x = data$x, y = data$y, window = plot.win)
    
    d <- distmap(habitat)
    plot(d)
    

    lam <- exp(3-2*d)
    plot(lam)
    

    animal <- rpoispp(lam)
    plot(animal)
    

    fit <- ppm(animal ~ d)
    fit
    #> Nonstationary Poisson process
    #> 
    #> Log intensity:  ~d
    #> 
    #> Fitted trend coefficients:
    #> (Intercept)           d 
    #>    2.952048   -1.974381 
    #> 
    #>              Estimate       S.E.   CI95.lo   CI95.hi Ztest      Zval
    #> (Intercept)  2.952048 0.07265533  2.809646  3.094450   ***  40.63085
    #> d           -1.974381 0.07055831 -2.112673 -1.836089   *** -27.98226
    

    考虑潜在的非均匀强度 没有偏离泊松模型的迹象 (非齐次)K-函数:

    plot(Kinhom(animal, lambda = fit))
    #> Warning: The behaviour of Kinhom when lambda is a ppm object has changed
    #> (in spatstat 1.37-0 and later). See help(Kinhom)
    

    您不必对距离有简单的对数线性依赖性。您还可以制作一个阈值模型,其中您具有一种强度,例如栖息地的距离 1 和此距离之外的另一个强度。您可以制作各种派生的协变量,例如在您的模型中使用的距离。

    【讨论】:

      【解决方案2】:

      如果animals 是动物的点模式,trees 是树的点模式(spatstat 中的两个对象都是“ppp”类),那么你可以这样做

      d <- distfun(trees)
      f <- rhohat(animals, d)
      plot(f)
      

      了解动物的集中度如何取决于到最近的树的距离。你可以使用

      berman.test(animals, d)
      

      对树的依赖性进行假设检验。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多