sim.capthist for unused traps

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

sim.capthist for unused traps

Postby sarogers » Thu Jan 09, 2025 6:50 pm

I am using sim.capthist to simulated detections from traps with variable effort across occasions. Sometimes detections get simulated for unused traps. Here's an example:
Code: Select all
set.seed(1)
#traps
traps <- read.traps(data = expand.grid(x = seq(0, 30, 5),
                                       y = seq(0, 30, 5)),
                    detector = "multi",
                    binary.usage = F)

zero <- 0

#variable usage
usage(traps) <- cbind(c(100, 50, zero , zero, 125, rep(50, nrow(traps)-5)),
                      c(50, zero, 50, 50, 100, rep(50, nrow(traps)-5)),
                      c(50, 100, zero, 25, 75, rep(50, nrow(traps)-5)))   
#simulate a capture history with those traps, HHN detection function                 
ch <- sim.capthist(traps = traps,
             popn = list(D = 200, buffer = 20),
             detectfn = "HHN",
             detectpar = list(lambda0 = .9, sigma = 4) ,
             noccasions = 3,
             nsessions = 1,
             renumber = FALSE)

#sum detection counts by occasion and trap
sumdet_occxtrap <- apply(ch, c(2,3), sum)
#track which trap occasion combinations have 0 use
nonuse <- as.data.frame(which(usage(traps) == 0, arr.ind = T))
colnames(nonuse) <- c("trap", "occ")
#check detection counts for unused trap/occasion combos
apply(as.array(1:nrow(nonuse)), 1, function(x){sumdet_occxtrap[nonuse$occ[x], nonuse$trap[x]]})
#produces detections for unused trap/occasion combos


Trap 3 on occasion 3 has 0 usage, but still detects 2 individuals.
Interestingly, this doesn't happen if I set "zero = 1E-7" instead of "zero = 0."


Any ideas what is happening here?
sarogers
 
Posts: 2
Joined: Wed Jan 08, 2025 6:49 pm

Re: sim.capthist for unused traps

Postby murray.efford » Fri Jan 10, 2025 5:00 am

I have traced this to a missing line in the C++ code for simulating from multi-catch traps. I cannot publish a new version immediately because my working code has other untested changes - it may take a few weeks. If you really need it now then let me know offline and I'll send a beta version of secr 5.2.0.

By the way, verify(ch) does a pretty good job of spotting these errors. As verify is the default in secr.fit() I'm optimistic this hasn't been a big problem.

Thanks for sending a fully reproducible example - it made all the difference.

Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: sim.capthist for unused traps

Postby sarogers » Fri Jan 10, 2025 7:28 pm

Thank you! I'll email you directly.
sarogers
 
Posts: 2
Joined: Wed Jan 08, 2025 6:49 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest

cron