dclf.test无法评估'spatstat''信封'-对象(错误:错误的行数)

时间:2019-02-22 10:00:21

标签: spatstat

我有灌木丛定居的时空数据,这是因为非常多的个体被限制在三个多边形断面(宽5m,长60-100m,间隔约30m)中。我正在分析“ spatstat” 1.58-2版中的数据。

我想通过“ pcfinhom”和“ pcfcross.inhom”评估总体(所有映射的个体)和后续队列(新兵与在随后的7个时期中建立的)之间的集群。 我创建了带有参数'savefuns = T'和'savepatterns = T'的'envelope'对象,供以后通过DCLF测试进行评估,例如:

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

我已将问题追溯到“信封”对象,其中“ simfun”具有比数据帧本身更多的观察力,但是我该怎么办呢?如何解决此问题并使DCLF测试正常工作?

最奇怪的是,这并不是在所有7个“ pcfcross.inhom”“信封”对象中都发生,而是显然仅适用于人数较多(> 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)

1 个答案:

答案 0 :(得分:0)

这可能是spatstat中的错误,但我无法复制它。没有您的数据,我可能找不到该错误。

请重新运行示例,并在发生错误后键入traceback(,3)并捕获打印的输出。这可以帮助我找出错误。

您还可以尝试在对ginterval的调用中包含参数envelope。该问题可能与计算ginterval的默认规则有关。