'spatstat' 'envelope'-object cannot be assessed by dclf.test (error: wrong number of rows)

'spatstat' 'envelope'-object cannot be assessed by dclf.test (error: wrong number of rows)

我有灌木殖民化的时空数据,因为大量个体仅限于三个多边形横断面(5m 宽,60-100m 长,间隔约 30m)。我正在分析 'spatstat' 版本 1.58-2.

中的数据

我想通过 'pcfinhom' 和 'pcfcross.inhom' 评估个体之间的聚类,包括总数(所有映射的个体)和后续队列(新兵与在随后 7 个时期建立的队列)。 我创建了带有参数 'savefuns = T' 和 'savepatterns = T' 的 'envelope'-objects 用于 DCLF-test 的后续评估,例如:

T_all_PCFi_gl<-envelope(T_all_ppp,fun=pcfinhom,nsim=39,verbose=T, simulate=expression(rpoispp(den_tr[["T_all"]])), #density in all transects correction="trans",global=T, savefuns = T, savepatterns = T)

但是,如果我想通过 DCLF 测试检查结果,

dclf.test(T_all_PCFi_gl)

我仍然收到此错误消息:

Error in data.frame(r = rvals, obs = fX, mmean = m, lo = lo, hi = hi):arguments imply differing number of rows: 55, 56

我已经将问题追溯到 'envelope'-object,其中 "simfun" 比数据框本身多了一个观察值,但我做错了什么?我该如何解决这个问题并让 DCLF 测试正常工作?

最奇怪的是,它并没有发生在所有 7 个 'pcfcross.inhom' 'envelope' 对象中,但显然只发生在那些个体数量较多 (>700) 的对象中。

这是我的错误吗(如果是,在代码的什么地方?),还是一个错误?

非常感谢您的回答! (很抱歉没有上传数据,但是要发表在一篇文章中)

编辑: 这是 traceback (,3) 的输出:
> traceback(,3) 8: stop(gettextf("arguments imply differing number of rows: %s", paste(unique(nrows), collapse = ", ")), domain = NA) 7: data.frame(r = rvals, obs = fX, mmean = m, lo = lo, hi = hi) 6: (function (Y, ..., rvals = NULL, observed = NULL, theory = NULL, funX = NULL, nsim = NULL, nsim2 = NULL, jsim = NULL, jsim.mean = NULL, type = c("pointwise", "global", "variance"), alternative = c("two.sided", ... 5: do.call(envelope.matrix, resolve.defaults(list(Y = as.matrix(df)), aargh, list(type = etype, csr = csr, funX = Y, Yname = Yname, weights = wt), .StripNull = TRUE)) 4: envelope.envelope(X, ..., savefuns = TRUE, savepatterns = savepatterns, Yname = Xname, verbose = verbose) 3: envelope(X, ..., savefuns = TRUE, savepatterns = savepatterns, Yname = Xname, verbose = verbose) 2: envelopeTest(X, ..., exponent = 2, alternative = alternative, rinterval = rinterval, leaveout = leaveout, scale = scale, clamp = clamp, interpolate = interpolate, Xname = Xname) 1: dclf.test(colcl_b1_pcf, alternative = "greater")

编辑 2: 升级到版本 1.58-2.042 后:

> dclf.test(colcl_b5_pcf)
Error in (function (Y, ..., rvals = NULL, observed = NULL, theory = NULL,  
: 
nrow(funX) == nrow(Y) is not TRUE`

> traceback(,3)
8: stop(simpleError(msg, call = sys.call(-1)))
7: stopifnot(nrow(funX) == nrow(Y))
6: (function (Y, ..., rvals = NULL, observed = NULL, theory = NULL, 
   funX = NULL, nsim = NULL, nsim2 = NULL, jsim = NULL, jsim.mean = NULL, 
   type = c("pointwise", "global", "variance"), alternative = 
c("two.sided", 
...
5: do.call(envelope.matrix, resolve.defaults(list(Y = as.matrix(df)), 
   aargh, list(type = etype, csr = csr, funX = Y, Yname = Yname, 
       weights = wt), .StripNull = TRUE))
4: envelope.envelope(X, ..., savefuns = TRUE, savepatterns = savepatterns, 
   Yname = Xname, verbose = verbose)
3: envelope(X, ..., savefuns = TRUE, savepatterns = savepatterns, 
   Yname = Xname, verbose = verbose)
2: envelopeTest(X, ..., exponent = 2, alternative = alternative, 
   rinterval = rinterval, leaveout = leaveout, scale = scale, 
   clamp = clamp, interpolate = interpolate, Xname = Xname)
1: dclf.test(colcl_b5_pcf)

这可能是 spatstat 中的错误,但我无法重现它。没有你的数据,我可能无法找到错误。

Please re-运行 the example and after a error occurs, type traceback(,3) and capture the printed output.这可能会帮助我找到错误。

您也可以尝试在 envelope 的调用中包含参数 ginterval。该问题可能与计算 ginterval.

的默认规则有关