簡體   English   中英

是否可以在 R 中給定另一個潛在的空間點模式來分析空間點模式

[英]Is it possible to analyse a spatial point pattern given another, underlying, spatial point pattern in R

我想分析動物所顯示的空間模式類型(即隨機、集群、統一),同時考慮到其可用棲息地的潛在空間模式。 有問題的動物棲息在樹上,因此對動物 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)

為動物創建點圖案。 為此,首先制作一個新的 dataframe,在動物計數中重復行,以便點是個體動物。 抖動 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

我還嘗試在擬合點過程 Model 上運行完全空間隨機性測試,其中可以通過 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 中缺少聰明的編碼解決方案。 提前致謝!

您可以 model 強度取決於到棲息地模式的距離。 這是一個簡單的例子,其中動物遵循強度為 function 的泊松點過程,該過程隨到棲息地的距離呈對數線性衰減:

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 函數中沒有偏離泊松 model 的跡象:

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)

您不必對距離有簡單的對數線性依賴性。 您還可以設置一個閾值 model ,其中您有一個強度,例如距離棲息地 1 和該距離之外的另一個強度。 您可以根據距離制作各種派生協變量,例如在 model 中使用。

如果animals是動物的點模式,而trees是樹的點模式(spatstat 中 class "ppp" 的兩個對象),那么你可以這樣做

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

了解動物的集中度如何取決於到最近的樹的距離。 您可以使用

berman.test(animals, d)

對樹的依賴性進行假設檢驗。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM