Emily, thanks for your use and interest in NIMBLE, and also your patience with your question.
There are a few things with your code that needed addressing, which were preventing your model from working correctly. Please take a careful look at the descriptions below, and the updated code. Assuming these changes are all consistent with your *desired* model structure, then this should get you going.
I'll also point out that the dcat-dcat structure you have with the latent "surv_state" variable and the "surv_obs" data might benefit from the marginalizing distributions available in the nimbleEcology package - specifically in this case, I believe the dHMM distribution. But before you consider that, please spend some time reading and thinking about the changes and comments below.
(0. I commented out the line "input_data <- output_data %>% filter(Year < 10)", which I don't think was intended to be in this script, where data is loaded from the file you provided)
1. Defined a new constant "first", giving the temporal location of the first-non-3 (alive, juvenile or adult) observation of each individual. This is a commonly needed value in mark-recapture models of repeated observations of individuals, telling the model when to first use the dcat(initial_survival[1:3]) distribution, and subsequently, when to use the transition matrix.
2. Providing the "first" variable in the "constants" list provided for the model.
3. Changing the initial distribution for the first observation to begin at surv_state[i, first[i]], and the following loop to begin at (first[i]+1) .. (see code file)
4. Changing the initial values for "surv_site", specifically "surv_state_init" to be plausible. Equal to 1 or 2 on the first observation (the value which is consistent with capture_history), then 2 thereafter. Previously, your "surv_state_init" initial values were all 1's, for all individuals and all time periods, which given your observation and transition matrices, was generally impossible values given the capture histories.
5. Changing the initial values provided for "offspring_state", rather than to be randomly Poisson-distributed, which often times gave values that were 0 (and thus could not be used for the Poisson rate parameter for non-zero data) to instead use the values of "offspring_obs". If you want something random here, you could still use something like what you had, but it has to be positive, so perhaps rpois(length(offspring_obs),offspring_obs)+1, adding the "+1" at the end.
These represent fundamental changes to your model structure - in particular, at what time periods the model starts to consider the latent state values and initial probabilities, and what time periods in the capture histories are considered to be observed data for the likelihood. If I've made incorrect assumptions about your intended model, then you should not blindly accept these changes I've made - it's entirely possible that I've misunderstood your intended model.
Modified code is below, along with ## CHANGE to indicate where substantive changes have been made. I hope this helps.
Cheers,
Daniel