Issues running multisession model with multiple masks

69 views
Skip to first unread message

Jayna Bergman

unread,
Feb 28, 2025, 4:04:32 PMFeb 28
to secr

Hello,

I am fairly new to secr and I am trying to make a multi-session model using masks that are made with polygons that cover different sections of a given area. I have read through multiple of the pdf tutorials and I believe all my input data are correctly structured.

 

I’m using R version 4.3.1 and the secr package version 5.2.0

 

First, I made a capthist object with 3 sessions:

caps <- read.capthist(“captxy.txt",

                                trapfile = list("detector_1.txt", “detector_2.txt", "detector_3.txt"),

                                fmt = "trapID", detector = 'proximity', covnames = "Sex")

 

I then fitted three separate masks and list them:

Mask1 <- make.mask(traps(caps[[1]]), type = "polygon", spacing = 1500, poly = polygon1, poly.habitat = T)

Mask2 <- make.mask(traps(caps[[2]]), type = "polygon", spacing = 1500, poly =polygon2, poly.habitat = T)

Mask3 <- make.mask(traps(caps[[3]]), type = "polygon", spacing = 1500, poly =polygon3, poly.habitat = T)

 

Masks <- list(Mask1, Mask2, Mask3)

 

Next I used secr.fit:

model <- secr.fit(capthist = ‘caps’, mask =Masks, model = list(D~session, lambda0~t+bk, sigma~t+bk), detectfn = "HEX", trace = FALSE, method = "BFGS",  CL = FALSE)

 

I get the following error:

no verify method for objects of class list

Error in if (notOK) stop("'verify' found errors in 'mask' argument") : argument is of length zero

 

The class of the “Masks” is list, but if I check the individual masks within the list using

              class(Masks[[1]])

the class is “mask”.

 

I have tried restructuring the code so I list the masks as they are made:

masks2 <- list( Mask1 <- make.mask(traps(caps[[1]]), type = "polygon", spacing = 1500, poly = polygon1, poly.habitat = T),

Mask3 <- make.mask(traps(caps[[2]]), type = "polygon", spacing = 1500, poly =polygon2, poly.habitat = T),

Mask3 <- make.mask(traps(caps[[3]]), type = "polygon", spacing = 1500, poly =polygon3, poly.habitat = T))

 

However, I got the same error as above.

 

I’ve also tried using the make.mask function again on the list:

masks3<- make.mask(list( Mask1 <- make.mask(traps(caps[[1]]), type = "polygon", spacing = 1500, poly = polygon1, poly.habitat = T),

Mask3 <- make.mask(traps(caps[[2]]), type = "polygon", spacing = 1500, poly =polygon2, poly.habitat = T),

Mask3 <- make.mask(traps(caps[[3]]), type = "polygon", spacing = 1500, poly =polygon3, poly.habitat = T)))

 

This makes the “list” a “mask” object, but I go from having 15718 rows in mask1 to ~4000 rows. Thus, I believe I am losing data by doing it this way?

Also, if I run secr.fit without specifying the mask argument, it runs without issue. Therefore, I don’t think the capthist object is the problem.

 

I’m not sure what else to try to troubleshoot this problem!

 

Thanks in advance for any advice!

-Jayna

Murray Efford

unread,
Feb 28, 2025, 4:22:47 PMFeb 28
to secr
Hi
Welcome to the group!

When the 'verify' argument of secr.fit is TRUE then both the capthist and mask arguments are checked internally with verify(). This works when there is a verify method for the particular class. There is no verify method for lists. So you can (i) turn off verify, or (ii) change the class of the mask list to c('mask','list'), for which there is a method. That gets you over the immediate problem; I haven't examined the rest of your code.

Murray

Jayna Bergman

unread,
Mar 4, 2025, 9:37:23 AMMar 4
to secr
Hi Murray,

Changing the class of the mask list worked! Thank you for the help and quick response!

Thank you,
Jayna

Murray Efford

unread,
Mar 17, 2025, 3:21:25 AMMar 17
to secr
I decided this was really a small bug in secr.fit (internally generated multi-session masks should automatically get class c("mask","list")). Now fixed in the development version of 'secr' that can be installed with install.packages("secr", repos = "https://MurrayEfford.r-universe.dev").
Reply all
Reply to author
Forward
0 new messages