secr.test error: attempt to set an attribute on NULL

23 views
Skip to first unread message

Rebeca Becdach

unread,
Mar 12, 2025, 4:02:06 PMMar 12
to secr
Hello,

I am trying to run secr.test for a multisession model with a user defined distance function. Here is the model specification ("sf" is a  spatial covariate added to the habitat mask):

details <- list(userdist = anisodistfn, miscparm = c(psiA = 3, psiR = 1.5))

model <- secr.fit(CH, mask = habitat.mask, detectfn = "HHN", trace = FALSE,
                              details = details, groups = "sex",
                              model = list(lambda0 = ~ g, sigma = ~ g, D = ~ sf + session))


I am getting the following error:

Error in attr(session.mask, "miscparm") <- coef(object)[miscindx, 1] :
  attempt to set an attribute on NULL


I am hoping to get some direction on what could be going wrong. Thanks and please let me know if I can provide more information — this is my first time posting here.

-Rebeca

Murray Efford

unread,
Mar 12, 2025, 5:43:31 PMMar 12
to secr
1. I'm not too surprised that secr.test fails with such a complex model (user distance function with groups and covariates) as it's tested only on simple examples, but
2. This smells like a bug in the passing of parameters to anisodistfn within secr.test. I'll look into it.

Murray Efford

unread,
Mar 13, 2025, 6:06:48 PMMar 13
to secr
The immediate problem was a bug in the simulation code (sim.detect) for the exotic case that secr.fit estimates additional parameters special to a user-defined distance function. These are labelled 'miscparm' internally; they may be estimated but there is no machinery for submodels (e.g., does not allow them to vary by occasion or group). For anisodistfn (I assume this is the one in the supplements for Efford 2019 Ecology e02580) the additional parameters are for the anisotropy angle and ratio. sim.detect() failed to forward these to anisodistfn().

I have fixed this in the version on GitHub. You should be able to install this with
install.packages("secr", repos = "https://MurrayEfford.r-universe.dev")

On Thursday, March 13, 2025 at 9:02:06 AM UTC+13 reb...@humboldt.edu wrote:
Reply all
Reply to author
Forward
0 new messages