Survival model doesn't initialize

Hi everyone,
I’m trying to fit a “simple” two state continious-time multi state model as discribed here: Two-State-Model. The model is analogous to the Cormack-Jolly-Seber-Model, but detection times and state transitions are modeled as random processes. When using the model with simulated data it works just fine and gives reasonable results. But when using the model with my own data I get the Error that the initialization of the first Markov chain failed. Here is the R output:

SAMPLING FOR MODEL ‘anon_model’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 1 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error : Initialization failed.”
error occurred during calling the sampler; sampling not done

The difference between my own data and the simulated example data is the number of individuals in my data-set is 1,650 while the simulated data contains of 100 individuals. In the simulated data-set 96 percent were redetected while in my own real world data only about 35 percent were redetected.

I tried a bunch of different initial values and priors before, but nothing seems to work. Does anyone have an idea what might be the problem here?

Cheers

Does anyone have an idea what might be the problem here?

Well, yeah, the problem is that you’re trying to take log(0). :)

But to give you a possibly more helpful answer, the issue is probably that at some point in your forward algorithm Omega takes values of zero in all cells of matrix. Given that you have lower redetection rate then in the simulation, I think it’s likely that the reason is because of the model explicitly parameterizing the detection probability in the dead state as zero. (lambda[2] = 0). But my intuition is that it’s also possible it could be from having a large T.

You could try calculating the likelihood using the forward algorithm in the generated quantities block and supplying your initial values as data and then look to see where it becomes zero. I suspect it’s probably happening in the else block from lines 60-69 in the linked to file.

Ultimately though I think the solution (and the general solution for capture-recapture models in Stan) is to try to avoid explicitly including detection probabilities of zero in calculating the likelihood. I’ve been trying to do this (and also trying to keep everything on the log-scale from transformed parameters through to the likelihood) in the temporally-stratified migratory animal release-recapture models I work with frequently.

I’m really interested in adapting some of these continuous time approaches, but haven’t dug in deeply yet. So unfortunately I don’t have more then general advice for you.

1 Like