secr error autoini/makestart 'secr.fit' failed

49 views
Skip to first unread message

madmon...@gmail.com

unread,
Oct 9, 2022, 8:11:26 PM10/9/22
to secr

Hello,
I am trying to fit a secr model to some camera trap data and I've tried a few different inputs I found when trying to find a solution and they all yield the same error/warning :

library(secr)
CH <- read.capthist(captfile = "DEC21cap2.txt",trapfile = "DEc21trap.txt", skip=1, detector = "proximity",covnames = NULL,binary.usage=TRUE)
No errors found :-)
my_traps <- traps(CH)
my_mask <- make.mask(my_traps, buffer = 3500, spacing = 1200, type = "trapbuffer")
m0<-secr.fit(CH,detectfn = "HHN", mask = my_mask, model = list(D=~1, lambda0=~1, sigma=~1))
Checking data
Preparing detection design matrices
Preparing density design matrix
Finding initial parameter values...
Warning messages:
1: In autoini(capthist = ch, mask = msk, binomN = tempbinomN, adjustg0 = details$binomN[1] == :
'dbar' close to zero; using detector spacing instead
2: In makeStart(start, parindx, capthist, mask, detectfn, link, details, :
'secr.fit' failed because initial values not found (data sparse?); specify transformed values in 'start'

initialsigma <-RPSV(captdata, CC=TRUE)[[1]]
cat("Quick and biased estimate of sigma=", initialsigma, "m/n")
Quick and biased estimate of sigma= 25.62888 m/n
fit <- secr.fit(CH, buffer = 4*initialsigma, trace = FALSE)
Warning messages:
1: In autoini(capthist = ch, mask = msk, binomN = tempbinomN, adjustg0 = details$binomN[1] == :
'dbar' close to zero; using detector spacing instead
2: In makeStart(start, parindx, capthist, mask, detectfn, link, details, :
'secr.fit' failed because initial values not found (data sparse?); specify transformed values in 'start'

library(secr)

ftraps<-read.csv("DEC21trap.csv")
names(ftraps)[2:3]<-c('x','y')
qtraps<-read.traps(data = ftraps, detector = "proximity")
cap<-read.csv("DEC21cap2.csv")
Dcap<-cap[,c(1,2,3,4)]
CH<-make.capthist(Dcap,qtraps,fmt = "trapID",noccasions = 38)
summary(CH, terse = TRUE)
Occasions Detections Animals Detectors
38 38 22 103
mask<-make.mask(qtraps,spacing = 1200)
Cats.secr0<-secr.fit(CH,model = list(D1,g01,sigma~1),mask = mask)
Checking data
Preparing detection design matrices
Preparing density design matrix
Finding initial parameter values...
Warning messages:
1: In autoini(capthist = ch, mask = msk, binomN = tempbinomN, adjustg0 = details$binomN[1] == :
'dbar' close to zero; using detector spacing instead
2: In makeStart(start, parindx, capthist, mask, detectfn, link, details, :
'secr.fit' failed because initial values not found (data sparse?); specify transformed values in 'start'


I thought I had my input data formatted correctly and was following inputs correctly, but in trying to solve this error I have just become more confused, unfortunately. I would appreciate any insight/help in trying to get this model finally fit.

Thank you,

Jennifer

DEC21cap2.csv
DEC21trap.csv

Murray Efford

unread,
Oct 9, 2022, 10:00:33 PM10/9/22
to madmon...@gmail.com, secr
Hi
As far as I can see, each of your animals was detected at just one detector (there were no spatial recaptures). That unfortunately means the data are not suitable for spatial capture-recapture because there are no data with which to estimate the spatial scale of detection (sigma). You might get a ballpark estimate by hypothesising a 'known' value of the sigma parameter from a comparable study, but otherwise SECR is a dead end, I'm sorry.
Murray

I tried with sigma between 0.5 and 2.5 km:
                             
ch <- read.capthist('Dec21cap2.csv', 'Dec21trap.csv', skip=1, noccasions = 38)
summary(ch, terse=T)
mask <- make.mask(traps(ch), buffer = 8000, spacing = 1200, type = 'trapbuffer')
setNumThreads(7)
options(digits = 3)
for (sig in seq(500,2500,500)) {
    cat("sigma = ", sig, '\n')
    fit <- secr.fit(ch, model = list(D~1,g0~1,sigma~1),
        mask = mask, trace = F, start = list(D=0.01, g0=0.1, sigma=1000),
        fixed = list(sigma = sig) )
    print(predict(fit))
}

sigma =  500
    link estimate SE.estimate      lcl     ucl
D    log  0.00105    0.000267 0.000639 0.00171
g0 logit  0.06684    0.018246 0.038803 0.11275
sigma =  1000
    link estimate SE.estimate      lcl      ucl
D    log 0.000537    0.000133 0.000334 0.000866
g0 logit 0.034108    0.008737 0.020567 0.056054
sigma =  1500
    link estimate SE.estimate      lcl     ucl
D    log 0.000446    0.000111 0.000276 0.00072
g0 logit 0.017386    0.004297 0.010692 0.02815
sigma =  2000
    link estimate SE.estimate      lcl      ucl
D    log 0.000408    0.000103 0.000251 0.000663
g0 logit 0.010160    0.002484 0.006285 0.016382
sigma =  2500
    link estimate SE.estimate      lcl      ucl
D    log 0.000383    9.75e-05 0.000235 0.000626
g0 logit 0.006707    1.65e-03 0.004138 0.010853

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/secrgroup/c41716a0-0741-41bd-861c-d1f8f214e308n%40googlegroups.com.

madmon...@gmail.com

unread,
Oct 10, 2022, 4:27:47 AM10/10/22
to secr
Thank you so much for your response! 
Some of the sigma values you tried actually do fall within a range from another study so if that is still giving such a low estimate then it looks like I need a larger dataset or maybe look more at the detector setup.
I appreciate you taking the time to check my data and run it through.
Jennifer
Reply all
Reply to author
Forward
0 new messages