Unable to specify noccasions in secr.fit()

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

Unable to specify noccasions in secr.fit()

Postby PhilipFaure » Fri May 26, 2023 8:11 am

Hi

I am trying to simulate animal capture histories from camera trapping under different conditions of sigma and camera trap spacing. Ultimately I want to run it with a variety of trap spacing and sigma combinations. Below I have written example code to do one of these combinations. However, every time I run secr.fit() the model output states that there was only one occasion (please see second code box for console output, here it states that "N occasions = 1", but should be 60). I have tried specifying the noccasions argument in both sim.capthist() and usage() functions. But that didn't help either. I am not sure what I am doing wrong... One of the things I noticed is the Warning message:
Warning message:
In bias.D(buffer, temptrps, detectfn = output$detectfn, detectpar = dpar, :
bias.D() does not allow for variable effort (detector usage)


Is this what is causing it? What does it mean and can/should I bypass/ignore it?

Below is some reproducible code, the console output from secr.fit(), and the session info for my machine.

Any advice or guidance would be highly appreciated!

Simulate animal capture histories and fit model:
Code: Select all
trap.test <- make.grid(spacing = 2000,
                       detector = "proximity",
                       nx = 10,
                       ny = 10)
usage(trap.test) <- matrix(sample(0:1,
                                  100*60,
                                  replace = T,
                                  p = c(0.1, 0.9)),
                           nc = 60)
caphist.test <- sim.capthist(trap.test,
                             popn = list(D = 0.0001,
                                         buffer = 15000),
                             detectfn = 'HN',
                             detectpar = list(lambda0 = 0.25,
                                              sigma = 2000),
                             noccasions = 60,
                             nsessions = 1,
                             seed = 123)
fit.test <- secr.fit(caphist.test,
                     model = list(D~1, g0~1, sigma~1),
                     buffer = 15000,
                     trace = T,
                     detectfn = "HN",
                     ncores = 12)
fit.test


Console output from secr.fit():
Code: Select all
>
> fit.test <- secr.fit(caphist.test,
+                      model = list(D~1, g0~1, sigma~1),
+                      buffer = 15000,
+                      trace = T,
+                      detectfn = "HN",
+                      ncores = 12)

Checking data
Preparing detection design matrices
Preparing density design matrix
Finding initial parameter values...
Initial values  D = 6e-05, g0 = 0.22596, sigma = 2182.52908
Maximizing likelihood...
Eval     Loglik        D       g0    sigma
   1   -212.104  -9.7636  -1.2313   7.6882
   2   -212.104  -9.7636  -1.2313   7.6882
   ...
   ...
   ...
  88   -207.207  -9.3804  -1.3457   7.6396
  89   -207.208  -9.3804  -1.3458   7.6404

Completed in 6.09 seconds at 14:00:49 26 May 2023

Warning message:
In bias.D(buffer, temptrps, detectfn = output$detectfn, detectpar = dpar,  :
  bias.D() does not allow for variable effort (detector usage)
>
>
> fit.test

secr.fit(capthist = caphist.test, model = list(D ~ 1, g0 ~ 1,
    sigma ~ 1), buffer = 15000, detectfn = "HN", trace = T, ncores = 12)
secr 4.5.10, 14:00:43 26 May 2023

Detector type      count
Detector number    100
Average spacing    2000 m
x-range            0 18000 m
y-range            0 18000 m

 Usage range by occasion
     1
min 48
max 60

N animals       :  7 
N detections    :  318
N occasions     :  1
Count model     :  Binomial, size from usage
Mask area       :  211500 ha

Model           :  D~1 g0~1 sigma~1
Fixed (real)    :  none
Detection fn    :  halfnormal
Distribution    :  poisson
N parameters    :  3
Log likelihood  :  -207.2064
AIC             :  420.4128
AICc            :  428.4128

Beta parameters (coefficients)
           beta    SE.beta        lcl       ucl
D     -9.380410 0.37861257 -10.122477 -8.638343
g0    -1.345794 0.09217003  -1.526444 -1.165145
sigma  7.638823 0.03165316   7.576784  7.700862

Variance-covariance matrix of beta parameters
                  D            g0         sigma
D      0.1433474767  0.0006908203 -0.0006864667
g0     0.0006908203  0.0084953153 -0.0016513867
sigma -0.0006864667 -0.0016513867  0.0010019223

Fitted (real) parameters evaluated at base levels of covariates
       link     estimate  SE.estimate          lcl          ucl
D       log 8.436064e-05 3.311956e-05 4.016652e-05 1.771803e-04
g0    logit 2.065588e-01 1.510595e-02 1.785145e-01 2.377338e-01
sigma   log 2.077297e+03 6.576947e+01 1.952339e+03 2.210252e+03
>
>


sessionInfo():
Code: Select all
>
> sessionInfo()

R version 4.3.0 (2023-04-21)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Africa/Johannesburg
tzcode source: internal

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

other attached packages:
[1] secr_4.5.10

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


Thank you!
PhilipFaure
 
Posts: 2
Joined: Fri May 26, 2023 1:52 am

Re: Unable to specify noccasions in secr.fit()

Postby murray.efford » Sat May 27, 2023 8:08 pm

You have stumbled on a 'feature' of secr. Binary proximity and count proximity data collected over many occasions may be modelled much more efficiently by collapsing observations of an individual at a particular detector to a single binomial observation (so long as there is no modelled variation over occasions, or learned response). The default in secr.fit is to collapse the data automatically, hence noccasions = 1 in the output. You can override this by setting details = list(fastproximity = FALSE).

This is indeed a trap, and maybe fastproximity = FALSE should be the default, but that's how it is.

The bias.D check is not relevant; you can suppress it with biasLimit=NA.

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

Re: Unable to specify noccasions in secr.fit()

Postby PhilipFaure » Mon May 29, 2023 1:59 am

Hi Dr Murray,

Thank you for the quick response. That makes sense, thanks for the advice!
PhilipFaure
 
Posts: 2
Joined: Fri May 26, 2023 1:52 am


Return to analysis help

Who is online

Users browsing this forum: No registered users and 2 guests

cron