Hi,
I'm trying to run a CJS-model using the dCJS_vv function from nimbleEcology. I have some individuals that first were captured at the second-to-last occasion (Tmax - 1), and when these are included in the analysis I get this error: "Dimension of distribution argument(s) 'probSurvive' does not match required dimension(s) for the distribution 'dCJS_vv'. Necessary dimension(s) are 1. You may need to ensure that you have explicit vectors and not one-row or one-column matrices."
If I remove the individuals with first capture at the second-to-last occasion, the model runs fine. Anyone encountered this issue or see an obvious error in my code?
Thanks!
Chris
nimbleCode({
##-----------------------------##
## Define survival & recapture ##
##-----------------------------##
for (i in 1:n.CH) {
for (t in first[i]:(Tmax-1)) {
# Survival
logit(phi[i, t]) <- beta[age.phi[i, t]] + eps.phi[age.phi[i, t], t]
}
}
# Detection
for (i in 1:n.CH) {
# p at the first capture occasion is fixed to 1
p[i, first[i]] <- 1
for (t in (first[i]+1):Tmax) {
logit(p[i, t]) <- alpha[age.p[i, t]] + eps.p[t]
}
}
##----------------##
## Likelihood ##
##----------------##
for (i in 1:n.CH) {
y[i, first[i]:Tmax] ~
dCJS_vv(
probSurvive = phi[i, first[i]:(Tmax-1)],
probCapture = p[i, first[i]:Tmax],
len = Tmax - first[i] + 1
)
}
##----------------------------##
## Priors ##
##----------------------------##
# Age-specific survival parameters
for (a in 1:n.age) {
# Intercept
beta[a] ~ dnorm(0, 1.5)
# Random temporal effect standard deviation
sdeps.phi[a] ~ dunif(0, 5)
# Temporal random effect
for (t in 1:(Tmax-1)) {
eps.phi[a, t] ~ dnorm(0, sd = sdeps.phi[a])
}
}
# Derived mean survival (probability scale)
mean.phi[1:n.age] <- ilogit(beta[1:n.age])
## Recapture
for (t in 1:Tmax) {
eps.p[t] ~ dnorm(0, sd = sdeps.p)
}
sdeps.p ~ dunif(0, 5)
for (u in 1:n.p) {
alpha[u] ~ dnorm(0, 1.5)
}
mean.p[1:n.p] <- ilogit(alpha[1:n.p])
})