mark-resight and b compatability?

83 views
Skip to first unread message

Tess O'Malley

unread,
May 15, 2022, 6:59:49 PM5/15/22
to secr
I'm running a combined capture-mark-resight model and am having trouble incorporating learnt behaviour (b). Variance calculation fails (and 80% of the time R studio crashes, aborting the session, but I suspect that's an R issue not a secr issue).

I've tried different fit methods. Before I go too into detail trying to fix it, I wanted to check there weren't any known limitations with resight data with regards to learnt behaviour (b).

Thank you!
Tess

Murray Efford

unread,
May 16, 2022, 11:11:19 PM5/16/22
to secr
If running 'secr' causes R Studio to crash then 'secr' is responsible and need to be fixed (audible groans, as I don't enjoy mark-resight at the best of times). So could you please send an example, preferably small and simple?

Exactly how do you see a learned response working? is that within the capture phase, or between the capture and sighting phases? The latter sounds implausible, but I haven't thought deeply on it. However, it's natural to model different detection probabilities for capture and sighting (canned predictor 'ts'). There is no mechanism or code for a learned response from one sighting to the next.

Murray

Dusit Ngoprasert

unread,
Oct 2, 2023, 11:57:55 AM10/2/23
to secr
Dear Murray,
I have the same issue when modeling g0~b, with the sighting-only model. R crashed every time at the maximing likelihood step. Is there anything I miss? I have tried several methods, but still crashes. I attached the .Rdata file for your investigation.

Best regards,
Dusit

mb <-secr.fit(MFR, model=list(D~1, g0~b, sigma~1), buffer=5000, fixed=list(pID=1.0),
details=list(iterlim = 500, knownmarks=FALSE, nsim=2000), trace = TRUE,
method = "Nelder-Mead", start=list(g0=0.001))
sessionInfo()

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8  
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: Asia/Bangkok
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] secr_4.6.1

loaded via a namespace (and not attached):
 [1] Matrix_1.6-1        dplyr_1.1.3         compiler_4.3.1    
 [4] tidyselect_1.2.0    Rcpp_1.0.11         RcppNumerical_0.6-0
 [7] stringr_1.5.0       parallel_4.3.1      splines_4.3.1      
[10] lattice_0.21-8      R6_2.5.1            generics_0.1.3    
[13] classInt_0.4-10     sf_1.0-14           MASS_7.3-60        
[16] tibble_3.2.1        units_0.8-3         DBI_1.1.3          
[19] pillar_1.9.0        rlang_1.1.1         utf8_1.2.3        
[22] sp_2.0-0            stringi_1.7.12      terra_1.7-46      
[25] RcppParallel_5.1.7  cli_3.6.1           magrittr_2.0.3    
[28] mgcv_1.9-0          class_7.3-22        grid_4.3.1        
[31] lifecycle_1.0.3     nlme_3.1-163        vctrs_0.6.3        
[34] KernSmooth_2.23-22  proxy_0.4-27        glue_1.6.2        
[37] raster_3.6-23       codetools_0.2-19    abind_1.4-5        
[40] fansi_1.0.4         e1071_1.7-13        pkgconfig_2.0.3    
[43] tools_4.3.1        
>

banteng_density.Rdata

Murray Efford

unread,
Oct 3, 2023, 1:50:42 PM10/3/23
to secr
Thanks for the example dataset - I see there is at least one problem, and possibly several. I'll look at it later this week.
Murray

Dusit Ngoprasert

unread,
Oct 4, 2023, 11:01:13 AM10/4/23
to secr
Thanks, Murray

Ben Augustine

unread,
Oct 4, 2023, 12:20:36 PM10/4/23
to Dusit Ngoprasert, secr
Just to expand on Murray's comment: " There is no mechanism or code for a learned response from one sighting to the next.",

the challenge here is that you don't know which captures are first vs. subsequent captures. You can account for this uncertainty if using MCMC for estimation, in principle, though it is complicated and I don't have any canned software to point anyone to do this. Also, if the magnitude of the behavioral response is large, the posterior uncertainty can be extreme.

The basic idea is that you must update both the true capture history and each individual's first and subsequent capture events (at each trap if trap specific Mb) if those change when you update the true capture history. There is nimble code to do that in the link below in the context of another latent ID SCR model. You can do the same thing for spatial mark-resight or any other latent ID SCR model. But, it's quite complex to implement and you may end up with unhelpfully imprecise parameter estimates (but maybe that is really the situation we face using SMR with a behavioral response to capture)

https://github.com/benaug/Random-Thin-MVHyper

--
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/431d003f-65bd-49fe-bbab-7da33afbe83bn%40googlegroups.com.

Murray Efford

unread,
Oct 9, 2023, 12:40:20 AM10/9/23
to secr
Thanks, Ben. I'm happy to keep out of mark-resight complexity where I can.

'secr' should not have crashed in this case. I have added a check in the next release - it aborts with a message if the mark-resight model includes any learned response. A learned response within the marking phase should be manageable, but would need some special coding, and I'd rather just block learned responses in general for mark-resight data.

Dusit's data gave me another problem that I don't fully understand. With the default (automatic) starting values the Nelder-Mead method for likelihood maximisation sometimes stops at a bad estimate that is not even a local maximum as far as I can tell by plotting the likelihood surface. The Newton-Raphson method simply fails with default starting values. Given reasonable starting values both methods get to about the same likelihood and estimates.

set.seed(123)
testA <-secr.fit(MFR, model = list(D~1, g0~1, sigma~1), buffer = 5000,
                 details = list(knownmarks = FALSE), method = "Nelder-Mead")
etc.
AIC(testA,testB,testC,testD, testE, testF, testG)
                       model   detectfn npar    logLik      AIC     AICc  dAICc AICcwt
testE D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3711.679 7431.357 7431.415  0.000 0.2501 Newton-Raphson, testA start
testF D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3711.679 7431.357 7431.415  0.000 0.2501 Nelder-Mead, testA start
testD D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3711.679 7431.358 7431.416  0.001 0.2499 Newton-Raphson, testB start
testG D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3711.679 7431.358 7431.416  0.001 0.2499 Nelder-Mead, testB start
testC D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3732.231 7472.462 7472.520 41.105 0.0000 Nelder-Mead, automatic
testB D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3739.202 7486.404 7486.462 55.047 0.0000 Nelder-Mead, automatic
testA D~1 g0~1 sigma~1 pID~1 halfnormal    4 -3744.819 7497.638 7497.696 66.281 0.0000 Nelder-Mead, automatic

Murray Efford

unread,
Oct 9, 2023, 8:13:52 PM10/9/23
to secr
Dusit asked me offline "What are the reasonable starting values that you used?" I should have made this clear. I just provided the (inadequate) earlier fit (testA or testB).
Thus
testE <- secr.fit(MFR, model = list(D~1, g0~1, sigma~1), buffer = 5000,
                 details = list(knownmarks = FALSE), start = testA)
where
> predict(testA) link estimate SE.estimate lcl ucl D log 0.1576767 0.005827601 0.1466623 0.1695183 g0 logit 0.4373848 0.018347407 0.4018133 0.4736121 sigma log 626.6220073 12.669217881 602.2787946 651.9491365 pID logit 0.7008977 0.009770064 0.6814046 0.7196888 > predict(testB) link estimate SE.estimate lcl ucl D log 0.1141661 0.003297694 0.1078836 0.1208145 g0 logit 0.4413345 0.017291164 0.4077679 0.4754459 sigma log 768.1356139 17.716075046 734.1902718 803.6504214 pID logit 0.7002661 0.009766033 0.6807827 0.7190511
etc.
Reply all
Reply to author
Forward
0 new messages