Possible to make a change/switch point model?


#1

Hi I was wondering if a switch point model a la the coal accidents problem. Some pseudocode follows:

switchpoint = round(uniform(1, length(counts)))
distribution(counts[1:switchpoint]) = poisson(lambda1, dim = ...)
distribution(counts[(switchpoint + 1):length(counts)]) = poisson(lambda2, dim = ...)

#2

Unfortunately, this is a model with a discrete parameter (switchpoint is not continuous-valued), so it’s not possible to do inference on this model directly with HMC. greta is still HMC-focussed, so it’s not currently possible to fit this with one of the other samplers, just because greta doesn’t have the internal workings to deal with discrete parameters yet.

You can fit this type of model with HMC, but you need to explicitly marginalise out the discrete parameter. See the Stan example here:

There’s a prototype marginalise() function being developed for greta that would make this straightforward, but it isn’t fully implemented yet.

So the short answer is that you can’t fit this in greta yet (at least not without writing a custom extension package and sone tensorflow code), but the ability to fit these models, by both the direct MCMC and marginalisation approaches, is on the to do list.