Issues with hcov in multi-session model
Posted: 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.
Best,
Mathias
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.
Best,
Mathias
- Code: Select all
library(secr)
cameras <- make.grid(spacing = 2000, detector = 'proximity')
D <- 0.001
mask <- make.mask(cameras, buffer=10000)
set.seed(123)
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.All<-rbind(ch.M,ch.F)
ch.All2<-ch.All
covariates(ch.All2)$sex[covariates(ch.All2)$sex=="F"]<-NA
ch.MS<-MS.capthist(ch.All,ch.All2)
secr.fit(ch.MS,buffer=10000) #works
secr.fit(ch.MS,buffer=10000,hcov="sex") #fails