Non-uniform populations and mask covariates

42 views
Skip to first unread message

Juliana Vélez

unread,
Jun 25, 2020, 4:31:01 PM6/25/20
to secr
Hi secr group,

I'm trying to generate non-uniform populations using a mask with density values. I would like to test 9 different trap layouts so I'm creating the following scenario and poplist with D1 (inhomogeneous) and D2 (homogeneous), which are stored as attributes in the masks:

scen1 <- make.scenarios(trapsindex=1:9, sigma = 1500, g0 = 0.32, noccasions = 8, popindex = 1:2)
poplist <- list(list(model2D = "IHP", D = "D1"), list(model2D = "IHP", D = "D2"))

sims1 <- run.scenarios(nrepl = 10, scenarios = scen1, trapset = mydetectors, maskset = mymask, pop.args = poplist, seed = 345, fit=TRUE, fit.args = list(detectfn = 'HN'))

I'm trying to run the previous code, but I'm getting the following error message:

Error in (function (f, p, ..., hessian = FALSE, typsize = rep(1, length(p)),  :
  missing value in parameter
In addition: There were 18 warnings (use warnings() to see them)

Error in for (j in seq_along(x)) { :
  Shadow graphics device error: r error 4 (R code execution error)
Error in for (j in seq_along(x)) { :
  Shadow graphics device error: r error 4 (R code execution error)

Warning messages:
1: In mean.default(covariates(full.pop.args[[pi]]$core)[,  ... :
  argument is not numeric or logical: returning NA


The masks that I'm using were created using:

mymasks <- lapply(mydetectors, make.mask, buffer = 4500, type = "trapbuffer", spacing = 100)
mymask <- lapply(mymasks, addCovariates, covers, replace = TRUE)


The masks with the density covariates are plotted correctly with the traps on it. I'm not sure what I'm missing or why the error is produced... Any help or hint that you could provide me will be very helpful! I could generate data and fit the model correctly before including a mask, so maybe it has to do with it... Also I'm using secr 4.2.2 and secrdesign 2.5.10.

Thanks,

Juliana

Murray Efford

unread,
Jun 25, 2020, 5:37:31 PM6/25/20
to secr
Hi Juliana
Thanks for laying this out. I can reproduce the problem (using datasets you sent offline). It seems to work with fit = FALSE. I'll have to investigate further. Meantime, can you please say which version of R you are using (R 4.0 has broken some other code)?
Murray

Juliana Vélez

unread,
Jun 25, 2020, 6:02:20 PM6/25/20
to secr
Hi Murray,

Thanks for taking a look at the problem. I'm using R 3.6.1.

Juliana

Murray Efford

unread,
Jun 25, 2020, 6:12:42 PM6/25/20
to secr
Thanks. It seems run.scenarios() has some internal problems with multiple ways of specifying the IHP model. I suspect you can work around this by specifying the 'core' argument of sim.popn e.g.,
poplist <- list(list(core = mymask[[1]], model2D = "IHP", D = "D1"),
                list
(core = mymask[[1]], model2D = "IHP", D = "D2"))

See if that works. Side comment: you do have a lot of mask points, so fitting will be slow.
Murray

Juliana Vélez

unread,
Jun 25, 2020, 7:00:17 PM6/25/20
to secr
It worked, thanks for your help! And thanks for your comment about the mask points, I increased a little bit the spacing so model fitting won't be too slow.
Thanks!
Juliana 

Reply all
Reply to author
Forward
0 new messages