I am looking into a (deterministic) state-space model where the state is a function of two continuous processes and a discrete one - this last one is either “on” or “off”.

For two continuous processes, the first is a simple sine-like oscillating function C(t) = a\ sin(\omega(t-\alpha)), and the second is either exponentially decreasing or a saturating increase, depending on the discrete state:

State switching happens when the difference H(t) - C(t) reaches a lower or upper threshold. This is a classic conceptual model, formalized in several papers, including this (PLoS) one.

In the context of inference, under one particular experimental set up, we can’t observe the continuous processes, only the “on” state through activity counts (which for know I’ll assume is Poisson distributed with a constant parameter), and the “off” state always produces zero counts. So a forward simulation of this looks like this:

While I am not sure results will be great, implementing this deterministic model in Stan should be straightforward. Real data is rarely this regular, though, so I’m hoping to implement a version where the system switches stochastically between the on and off states. However, this model doesn’t seem to fall into a clear category, so it’s not clear to me what the best approach would be. Some options (and drawbacks) are:

- Fully stochastic state, Particle Filter approach (may be difficult with observations of discrete process only);
- Hidden Markov Model-like approach (but transition rates depend on state, so may not be feasible);
- Deterministic, but estimating switch times as additional parameters (not always clear how many switch points are there);
- Forget counts, and use the durations of on/off periods as observations to fit the model.

Ideally this would already fit into some class of model, but otherwise I am wondering if there’s some reasoning on what the best approach may be. Thank you.