Issues with hcov in multi-session model

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

Issues with hcov in multi-session model

Postby matobler » Fri Oct 21, 2022 6:03 pm

Hi Murray,

I am working with a large (40 sessions) multi-session dataset with a sex covariate (coded as "F" and "M"with some NA). This dataset was working well in secr 4.4.7 but after updating to 4.5.x (tried different versions) I can't get it to converge even for a null model when I include hcov="sex" (Loglik is NA and optimization stops after 15-20 iterations). I saw in the change log that there were changes to the hybrid mixture model in version 4.5.1, so I assume it is related to that. It looks like the problem is with sessions where only one of the two sexes was detected. If I remove those sessions everything works fine. There is no issue with sessions that have all NAs. Here few more notes:

- I standardized factor levels to "F" and "M" for all sessions.
- Some sessions only have "F" and NA or "M" and NA, some sessions have all NA.
- Providing start values does not make a difference.
- There are not convergence issues when removing hcov="sex"

Below a simulated example replicating the issue, borrowing some code from the previous post.

Please let me know if you have any thoughts on what the issue could be or how to solve it.



Code: Select all
cameras <- make.grid(spacing = 2000, detector = 'proximity')
D <- 0.001
mask <- make.mask(cameras, buffer=10000)


my_pop <- sim.popn(D = D, core = mask, buffer = 0, Ndist = 'fixed',
                   covariates = list(sex = c(F = 0.5625, M = 0.4375)))
covariates(my_pop)$sex <- factor(covariates(my_pop)$sex, levels = c('F','M'))

ch.M <- sim.capthist(traps = cameras, pop = subset(my_pop, covariates(my_pop)$sex=="M"),
                     noccasions = 10, detectpar = list(lambda0 = 0.01, sigma =5100), detectfn = "HHN")
ch.F <- sim.capthist(traps = cameras, pop = subset(my_pop, covariates(my_pop)$sex=="F"),
                     noccasions = 10, detectpar = list(lambda0 = 0.005, sigma =2700), detectfn = "HHN")


ch.MS<-MS.capthist(ch.All,ch.All2),buffer=10000) #works,buffer=10000,hcov="sex") #fails

Posts: 19
Joined: Fri Nov 03, 2006 9:44 pm
Location: Peru

Re: Issues with hcov in multi-session model

Postby murray.efford » Mon Oct 24, 2022 7:48 pm

Hi Mathias

Yes, the patch I made in January didn't account for sessions with one 'known class' level missing. Sorry about that. I think this is now fixed in the pre-release version on GitHub that you can also install from one of these links - (Windows binary) or
secr_4.5.8.tar.gz (source).

Thanks for investigating this and providing a reproducible example.
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Issues with hcov in multi-session model

Postby matobler » Tue Oct 25, 2022 3:33 pm

Hi Murray,

thanks a lot for the quick fix! Everything is working so far. I am running some large models and will let you know if I run into any other issues.


Posts: 19
Joined: Fri Nov 03, 2006 9:44 pm
Location: Peru

Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest