Model for finding arbitrary number of changepoints

Hello,

I am trying to implement a changepoint model. Perhaps a time series example would make it clearer:

Each color is a different segment, where each segment is modeled as a normal distribution with mean zero and a different standard deviation (in the picture, the y-axis are the displacements sampled from such normal distribution for the segment). The number of segments is arbitrary.

I implemented a model for this using maximum likelihood based on literature specific for my problem. However, I need to add a bit more complexity to the model so I want to move on to a Bayesian framework.

In the past, I’ve implemented change points using reversible-jump mcmc. I don’t think this is possible with Stan correct? Any suggestions?

Thank you.

Hi!
Have you tried the prophet package?! It has some methods for estimating change points! And You can always use their stan code is a bit tricky to follow and personalize but maybe the package itself is a good start :)

Thanks @asael_am! I will look into it. I am just concerned that it would not be flexible enough for what I need but will check it out. I am just at a loss as to whether just try to implement a model using plain RJ-MCMC in R, or whether there is a package out there that takes advantage of HMC for these kinds of problems.