Taylor Hamlin
unread,Mar 29, 2026, 7:01:27 PM (14 days ago) Mar 29Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to secr
Kia ora,
I am currently working on implementing stratification in openCR. I have three sites that I would like to implement as different strata within the same model. Each site is visited monthly (primary session) and traps are run for a non-fixed amount of days (usually around 3-7 days; secondary sessions).
I have been attempting to get the data in the correct format to start and so was systematically testing the capture histories and masks across model types. During testing, most of the spatial models ran without issue, however, I noticed that models that estimated density-related parameters (superD, BD, and D) returned the same error:
Error in if (N < ncf) return(1e+10) :
missing value where TRUE/FALSE needed
Upon further testing I found that if I ran the strata separately (no stratification) or in pairs of two, the models ran successfully (all pairwise combinations were found to work). It is only when all three strata are run in the same model do I encounter problems.
Is this an issue anyone has encountered before? Is there something I am missing about increasing the amount of stratification? I would be grateful if anyone had any insights.
All the best,
Taylor
# R-Version: 4.5.2
# openCR Version: 2.2.7
Current code:
## Draw in pre-processed capture histories, one for each site/strata
capt_hist_BP <- readRDS(file.path(path_input, "openCR", "Input", "Site_Bruie Plains Rd_CH.rds"))
capt_hist_MR <- readRDS(file.path(path_input, "openCR", "Input", "Site_Mailers Rd_CH.rds"))
capt_hist_PD <- readRDS(file.path(path_input, "openCR", "Input", "Site_Pig Dam_CH.rds"))
## All capture histories generate: "No errors found :-)"
verify(capt_hist_BP)
verify(capt_hist_MR)
verify(capt_hist_PD)
## Create individual masks for each site/strata
msk_BP <- make.mask(traps(capt_hist_BP), buffer = 200, spacing = 10, type = 'trapbuffer')
msk_MR <- make.mask(traps(capt_hist_MR), buffer = 200, spacing = 10, type = 'trapbuffer')
msk_PD <- make.mask(traps(capt_hist_PD), buffer = 200, spacing = 10, type = 'trapbuffer')
## Run each site/strata independently.
## Currently all converge and have reasonable estimates.
m_test1 <- openCR.fit(capt_hist_BP,
mask = msk_BP,
type = "secrD")
m_test2 <- openCR.fit(capt_hist_MR,
mask = msk_MR,
type = "secrD")
m_test3 <- openCR.fit(capt_hist_PD,
mask = msk_PD,
type = "secrD")
## Run pairwise combinations of all sites/strata.
## Currently all converge and have reasonable estimates
capt_hist_4 <- stratify(capt_hist_BP, capt_hist_MR)
msk_4 <- list(msk_BP, msk_MR)
m_test4 <- openCR.fit(capt_hist_4,
mask = msk_4,
type = "secrD",
stratified = TRUE)
capt_hist_5 <- stratify(capt_hist_BP, capt_hist_PD)
msk_5 <- list(msk_BP, msk_PD)
m_test5 <- openCR.fit(capt_hist_5,
mask = msk_5,
type = "secrD",
stratified = TRUE)
capt_hist_6 <- stratify(capt_hist_MR, capt_hist_PD)
msk_6 <- list(msk_MR, msk_PD)
m_test6 <- openCR.fit(capt_hist_6,
mask = msk_6,
type = "secrD",
stratified = TRUE)
## Run all three sites/strata in the same model.
## Generates error: "Error in if (N < ncf) return(1e+10) : missing value where TRUE/FALSE needed"
capt_hist_7 <- stratify(capt_hist_BP, capt_hist_MR, capt_hist_PD)
msk_7 <- list(msk_BP, msk_MR, msk_PD)
m_test7 <- openCR.fit(capt_hist_7,
mask = msk_7,
type = "secrD",
stratified = TRUE)