Hi NIMBLE community,
I am trying to understand the outputs of my multistate capture-recapture model, and I feel I have exhausted all other troubleshooting options. I hope you can assist!
In summary, I had been trying to troubleshoot oddly low population size estimates when I became confused by the categorical sampling of the state process matrix. When I monitor the underlying deterministic parameters and calculate out the probabilities per iteration of sampling (i.e. essentially build the state matrix for each iteration), it appears that certain transitions should be very likely (e.g. 2>2). However, the monitored z-matrix does not suggest this pattern and rather state 7 is the more likely state in most instances. There are no issues in the z-matrix for individuals that have known states assigned the question relates to instances where sampling occurs.
What I am trying to understand is how the sampling process could produce a z-matrix that is so different from what the calculated probability matrix suggest. The sampling never behaves aberrantly (i.e. unallowed transitions (e.g. 2>1) never occur) so I don't think it is some sort of indexing or referencing issue. Is there something obvious that I am missing here?
For context, the purpose of the model is to estimate abundance of a species across N-occasions while accounting for subpopulation-, time-, and individual-dependent covariates. It becomes quite complex and lengthy so I don't want to burden you with detail on the data, model structure and initialization. The important components I think are the following:
1) nind = N (real individuals) + N (pseudo-individuals) # data augmentation with zeros
2) all individuals start in latent state 1 within occasion 1 (dummy occasion)
3) a z.init matrix is provided which has all unknown states as 2 (assume still alive) for real individuals and 1 (not yet entered) for pseudo-individuals
4) inputted data are y (observation matrix); z (state matrix, with NAs for unknown states)
5) Not all state transitions are possible and probabilities are outlined below along with the likelihood portion of the nimbleCode.
# -------------------------------------------------------------------
for (i in 1:nind){
# Define probabilities of state S(t+1) given S(t)
for (t in 1:(n.occasions-1)){
ps[1,i,t,1] <- (1-gamma[t]) * (1-intro[t])
ps[1,i,t,2] <- gamma[t]
ps[1,i,t,3] <- intro[t] * (1-gamma[t])
ps[1,i,t,4] <- 0
ps[1,i,t,5] <- 0
ps[1,i,t,6] <- 0
ps[1,i,t,7] <- 0
ps[2,i,t,1] <- 0
ps[2,i,t,2] <- s[i,t] * (1-tran[t])
ps[2,i,t,3] <- 0
ps[2,i,t,4] <- (1-s[i,t]) * pp[t] * r[i,t]
ps[2,i,t,5] <- (1-s[i,t]) * (1-pp[t]) * r[i,t]
ps[2,i,t,6] <- s[i,t] * tran[t]
ps[2,i,t,7] <- (1-s[i,t]) * (1-r[i,t])
ps[3,i,t,1] <- 0
ps[3,i,t,2] <- 1
ps[3,i,t,3] <- 0
ps[3,i,t,4] <- 0
ps[3,i,t,5] <- 0
ps[3,i,t,6] <- 0
ps[3,i,t,7] <- 0
ps[4,i,t,1] <- 0
ps[4,i,t,2] <- 0
ps[4,i,t,3] <- 0
ps[4,i,t,4] <- 0
ps[4,i,t,5] <- 0
ps[4,i,t,6] <- 0
ps[4,i,t,7] <- 1
ps[5,i,t,1] <- 0
ps[5,i,t,2] <- 0
ps[5,i,t,3] <- 0
ps[5,i,t,4] <- 0
ps[5,i,t,5] <- 0
ps[5,i,t,6] <- 0
ps[5,i,t,7] <- 1
ps[6,i,t,1] <- 0
ps[6,i,t,2] <- 0
ps[6,i,t,3] <- 0
ps[6,i,t,4] <- 0
ps[6,i,t,5] <- 0
ps[6,i,t,6] <- 0
ps[6,i,t,7] <- 1
ps[7,i,t,1] <- 0
ps[7,i,t,2] <- 0
ps[7,i,t,3] <- 0
ps[7,i,t,4] <- 0
ps[7,i,t,5] <- 0
ps[7,i,t,6] <- 0
ps[7,i,t,7] <- 1
# Define probabilities of O(t) given S(t)
po[1,i,t,1] <- 0
po[1,i,t,2] <- 0
po[1,i,t,3] <- 0
po[1,i,t,4] <- 0
po[1,i,t,5] <- 0
po[1,i,t,6] <- 1
po[2,i,t,1] <- p[i,t]
po[2,i,t,2] <- 0
po[2,i,t,3] <- 0
po[2,i,t,4] <- 0
po[2,i,t,5] <- 0
po[2,i,t,6] <- 1-p[i,t]
po[3,i,t,1] <- 0
po[3,i,t,2] <- 1
po[3,i,t,3] <- 0
po[3,i,t,4] <- 0
po[3,i,t,5] <- 0
po[3,i,t,6] <- 0
po[4,i,t,1] <- 0
po[4,i,t,2] <- 0
po[4,i,t,3] <- 1
po[4,i,t,4] <- 0
po[4,i,t,5] <- 0
po[4,i,t,6] <- 0
po[5,i,t,1] <- 0
po[5,i,t,2] <- 0
po[5,i,t,3] <- 0
po[5,i,t,4] <- 1
po[5,i,t,5] <- 0
po[5,i,t,6] <- 0
po[6,i,t,1] <- 0
po[6,i,t,2] <- 0
po[6,i,t,3] <- 0
po[6,i,t,4] <- 0
po[6,i,t,5] <- 1
po[6,i,t,6] <- 0
po[7,i,t,1] <- 0
po[7,i,t,2] <- 0
po[7,i,t,3] <- 0
po[7,i,t,4] <- 0
po[7,i,t,5] <- 0
po[7,i,t,6] <- 1
} #t
} #i
# Likelihood
for (i in 1:nind){
z[i,1] <- 1 # Define latent state at first capture
for (t in 2:n.occasions){
# State process: draw S(t) given S(t-1)
z[i,t] ~ dcat(ps[z[i,t-1], i, t-1, 1:7])
# Observation process: draw O(t) given S(t)
y[i,t] ~ dcat(po[z[i,t], i, t-1, 1:6])
} #t
} #i
I am happy to provide a reproducible example if helpful. I just thought I would put the question out there first to see if there was something obvious that I was missing or if anyone has ever encountered something like this.
Thanks in advance,
Robin