通过 Geyer 模型的 diagnose.ppm 绘制平滑残差测量时出错

Error plotting the Smoothed residual measure via diagnose.ppm of a Geyer model

我正在尝试将 Geyer 模型拟合到点模式中,并且我成功地做到了这一点。但是,当我想检查诊断图时,我遇到了一个问题。如果我将值 "all" 赋给参数 "which" 它会毫无问题地绘制 4 个面板,但是当我只询问平滑残差度量时(它 = "smooth" 我得到以下错误:

Error in as.vector(rasterx.mask(W)) : error in evaluating the argument 'x' in selecting a method for function 'as.vector': Error in validate.mask(w) : w is not a binary mask

可重现代码如下:

library(spatstat)
#generate a pattern
pattern <- rpoispp(300)
#generate a covariate
cov <- rnoise(rgen = rnorm, dimyx=32, mean=2, sd=1, w = pattern$window)

#fit the model
fit <- ppm(pattern ~ cov, Geyer(r = 0.01, s = 0.02))

#plot diagnostics
diag <- diagnose.ppm(fit, type = "pearson", which = "all") #this works
diag <- diagnose.ppm(fit, type = "pearson", which = "smooth") #this doesn't

我尝试了 type= 中允许的所有选项,但运气都一样。

知道我可能做错了什么吗? (我假设是我)或者我怎样才能通过其他方式获得平滑的残差?

这可能是 plot.diagppm 中的错误。我目前正在度假,所以我现在不会采取太多行动。我会在 https://github.com/spatstat/spatstat/issues 上报告这个错误,希望 Adrian 能在很长时间内修复它。

目前的解决方法:

library(spatstat)
#generate a pattern
pattern <- rpoispp(300)
#generate a covariate
cov <- rnoise(rgen = rnorm, dimyx=32, mean=2, sd=1, w = pattern$window)

#fit the model
fit <- ppm(pattern ~ cov, Geyer(r = 0.01, s = 0.02))

#plot diagnostics
diag <- diagnose.ppm(fit, type = "pearson", which = "smooth", plot.it = FALSE)
s <- diag$smooth$Z
plot(s)

只是确认这是一个错误。它已在 spatstat 的下一个开发版本(版本 1.45-0.026)中修复。感谢您提请我们注意此事。