Dear nimble team,
I have this part of code in my multi-state model estimating individual survival for each state and time occasion, with first[i] being the first capture/sighting event and T the number of time occasions.
for(k in 1:9){ # for each state
for(i in 1:n){ # for each individual
for(j in (first[i]+1):T){ # for each sampling after first capture
logit(phi[k,i,j]) <- mu.phi[k,i,j] + epst.phi[k,j-1] # epst.phi being a random time effect
mu.phi[k,i,j] <- int.phi[k,age[i,j-1]] + beta1 * eta1[i] #int.phi=intercept for each age/state #occasion, eta being the individual condition
} #j
} #i=n
} #k
Since I want to estimate the effect of condition on survival only for one time occasion after the capture event (seeing the condition as a dynamic rather than static individual trait), I was thinking of an if-else-statement as for instance like this:
for(k in 1:9){ # for each state
for(i in 1:n){ # for each individual
for(j in (first[i]+1):T){ # for each sampling after first capture
if (T=tcatch) #where tcatch is a vector with the time occasion of capture for each individual
logit(phi[k,i,j]) <- mu.phi[k,i,j] + epst.phi[k,j-1]
mu.phi[k,i,j] <- int.phi[k,age[i,j-1]] + beta1 * eta1[i] #eta being the condition
else
logit(phi[k,i,j]) <- mu.phi[k,i,j] + epst.phi[k,j-1]
mu.phi[k,i,j] <- int.phi[k,age[i,j-1]] # here without eta
} #j
} #i=n
} #k
So that the survival is estimated with the term“beta1+eta1[i]” only for the year after capture and otherwise without the “beta1+eta1[i]”-term.
I read that if-then-else statements like this will not work in this case. So I guess I would need to write a custom function which includes the if-else statement and plug it in the code. I was wondering if you think that a function could work in my case? Since I have never written an own function in nimble, can you give me some suggestions as a starting help? Or do you have other ideas how I could model this if-else-statement?
Thank you very much!
Magali
--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/35ba3bb3-8ac8-4031-9743-6052bfd0ba6bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/CAEbSdx39aYSRxSmtUW0EiY1jpyufB-1ofmuaBFvVnF3m4bKW9g%40mail.gmail.com.