Hi. I am trying to model the evolution of an object through several discrete states.
The amount of time that the object spends in each state, “tau", is a stochastic variable, parameterized by the “state” variable. State transition cannot happen, while “tau” is greater than time, “t”. In other words, while t < tau, the transition probability is 0. Once t > tau (i.e. the allocated time for the current state is up), a Bernoulli process determined by trans_prob, “p”, moves the object into one of two new states. In a new state, new time allocation, “tau”, for that state is simulated, and the whole process continues until t_max is reached. The ultimate goal is to visualize the dependency of the state on time (plot object state as a time-series).
I would like to start by defining a deterministic time variable “t”, initialized to 0, and incremented by 1 until it reaches t_max. However, my intuition tells me that this is precisely the wrong approach to take in PyMC. Also, I was unable to figure out how to create an upper bound, t_max, for such a variable. Anyway, here’s my feeble attempt at “t”:
init = 1 # Flag that signals t = 0
t = pm.Deterministic(“t”, pm.math.switch(pm.math.neq(init, 1), t + 1, 0)
init = 0
Assuming I can get past “t” definition, I am going to have a circular dependency problem next. The stochastic state duration variable, “tau”, is parameterized by the “state” variable. But the state variable, in turn, depends on “tau” via transition probability, “p”, that changes as “t”, “tau” and “state” change.
“t” is just a time step number
“tau” is a stochastic variable dependent on “state”
“p” is determined by “t”, “tau”, and “state”
“state” is determined by “p”
I understand that the process does not quite make sense in the way I am trying to define it just above. Perhaps the “state” variable should be lagged, i.e. a distinction should be made between the “last”, or “current” state and a “new” state? How would I program something like that in PyMC3?
Any advice is greatly appreciated.