Hi all,
I am trying to use run.scenarios using a linear mask (attachment) and a non-Euclidean function.
I tried not to specify this in the code as the vignette says it (userdist = networkdistance) is default with a linear mask.
However, I get such a warning message for some scenarios (I am using 1 rep per scenario and only 12 rows to speed it up):
sims <- run.scenarios (1, scenarios = scens[1:12,],
trapset = simtraps, maskset = riversmask,
pop.args = list(model2D = 'linear'),
fit = TRUE, extractfn = predict, fit.function = 'secr.fit',
ncores = 12, byscenario = FALSE, seed = 345)
...
24: In (function (capthist, model = list(D ~ 1, g0 ~ 1, sigma ~ ... :
using Euclidean distances with linear mask
Hence, I tried putting it in the det.args:
arg <- list(userdist = networkdistance)
sims <- run.scenarios (1, scenarios = scens[1:12,],
trapset = simtraps, maskset = riversmask,
det.args = list(arg),
pop.args = list(model2D = 'linear'),
fit = TRUE, extractfn = predict, fit.function = 'secr.fit',
ncores = 12, byscenario = FALSE, seed = 345)
However, I still get the same warning for some scenarios.
Finally, I tried using the fit.args and I get an error
arg <- list(userdist = networkdistance)
sims <- run.scenarios (1, scenarios = scens[1:12,],
trapset = simtraps, maskset = riversmask,
fit.args = list(arg),
pop.args = list(model2D = 'linear'),
fit = TRUE, extractfn = predict, fit.function = 'secr.fit',
ncores = 12, byscenario = FALSE, seed = 345)
Error in f(x, ...) :
unused argument (userdist = function (xy1, xy2, geometry)
{
if (missing(xy1)) return(character(0))
rn <- list(rownames(xy1), rownames(xy2))
if (is.null(dim(xy1))) xy1 <- matrix(xy1, ncol = 2)
if (is.null(dim(xy2))) xy2 <- matrix(xy2, ncol = 2)
if (missing(geometry)) geometry <- xy2
gr <- attr(geometry, "graph")
if (is.null(gr)) gr <- asgraph(geometry)
geometryxy <- cbind(V(gr)$x, V(gr)$y)
matchedxy1 <- nearesttrap(xy1, geometryxy)
matchedxy2 <- nearesttrap(xy2, geometryxy)
uniquematchedxy1 <- unique(matchedxy1)
tmp <- t(igraph::shortest.paths(gr, weights = NULL, v = matchedxy2, to = uniquematchedxy1))
rematch <- match(matchedxy1, uniquematchedxy1)
tmp <- tmp[rematch, , drop = FALSE]
if (!("weight" %in% igraph::list.edge.attributes(gr))) tmp <- tmp * spacing(geometry)
dimnames(tmp) <- rn
tmp
})
In addition: There were 13 warnings (use warnings() to see them)
Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "try-error"
Mymask has an issue, it consists of 4 separate systems. Considering real data, individuals do not move across systems and thus "networkdistance" can be used. Perhaps in simulated scenarios, individuals are fabricated with detections across systems causing an issue in the model?
Thank you very much
Stefano