Page 1 of 1

extracting traps with operation==1

PostPosted: Wed Apr 13, 2022 1:09 pm
by hbunderw
Been wracking my brain on how to do this. I first used subset on the capture history to isolate occasions 2:6 (of 7). That was easy. Where I'm falling down is in wanting to restrict the trap locations (and their effects on a multi-capthist) to those with a complete operational history (all usage(trap)==1). Seems like I have to work with the capthist object rather than a traps(capthist) object because removing a "multi" detector has consequences on the capture history. I know I can subset the capture history on trapIDs, but only a handful of the 600+ detectors have incomplete usage profiles. Does the row.number of the traps(capthist) correspond to the index of the trapID in trap(capthist, names=TRUE)? If so, I think I can get at it that way. I must be missing something. Thanks in advance.

Brian

Re: extracting traps with operation==1

PostPosted: Wed Apr 13, 2022 3:08 pm
by murray.efford
I'm not convinced what you're attempting makes sense - removing traps (and associated capture data) post-hoc that were actually there and affecting the capture pattern is a bit hard to justify.

On your specific question: trap(..., names = FALSE) should give you the row numbers.

However, this seems easy enough using a logical vector as the 'traps' argument to the subset method for capthist objects:

# construct some data with incomplete usage
library(secr)
usge <- matrix(runif(500) < 0.9, 100, 5)
tr <- make.grid(10,10)
usage(tr) <- usge
ch <- sim.capthist(tr, popn = list(D=5), detectpar=list(g0=0.2, sigma=25 ))
summary(ch)

# criterion TRUE if trap used on all occasions, FALSE otherwise
all.traps.used <- apply(usage(traps(ch)), 1, sum) == 5
ch2 <- subset(ch, traps = all.traps.used)
summary(ch2)

Murray

Re: extracting traps with operation==1

PostPosted: Thu Apr 14, 2022 3:37 pm
by hbunderw
I understand your concern, Murray. It's a large trap array involving hundreds of animals. The spatial capture has already been analyzed using secr and published. I'm writing a JAGS version of an integrated model using the secr objects. I'm trying to avoid looping through the occasions in the likelihood to reduce computational time. However, I think I can just pass the number of occasions associated with each trap instead and just loop over individuals and traps (my model uses data augmentation). You did answer my direct questions about how to extract the information and I appreciate your time.

Brian