I was watching a video on PyMC3 for fitting Bayesian models, and an example they gave was of "switchpoint" analysis for coal mining disasters. A picture of the data is below, and the goal is to identify the year in which the distribution changes from a high number of disasters to low number of disasters regime.
My question is, what is the likelihood function for a switchpoint model? That was not mentioned in the talk or documentation. I understand the priors, but the likelihood almost seems like a mixture of poissons or something. I was just wondering what the precise mathematical specification of the likelihood function was--or at least the probability distribution used to setup the likelihood.
Now, the model is specified as:
$$ \begin{aligned} D_{t} & \sim \operatorname{Pois}\left(r_{t}\right), r_{t}=\left\{\begin{array}{ll} e, & \text { if } t \leq s \\ l, & \text { if } t>s \end{array}\right.\\ s & \sim \operatorname{Unif}\left(t_{l}, t_{h}\right) \\ e & \sim \exp (1) \\ l & \sim \exp (1) \end{aligned} $$
And the PyMC3 code is
with pm.Model() as disaster_model:
switchpoint = pm.DiscreteUniform('switchpoint', lower=years.min(), upper=years.max(), testval=1900)
# Priors for pre- and post-switch rates number of disasters
early_rate = pm.Exponential('early_rate', 1)
late_rate = pm.Exponential('late_rate', 1)
# Allocate appropriate Poisson rates to years before and after current
rate = pm.math.switch(switchpoint >= years, early_rate, late_rate)
disasters = pm.Poisson('disasters', rate, observed=disaster_data)
Thanks for taking the time to look at my question.
Note, a similar question was asked before about this type of switchpoint analysis, but that question did not ask for the mathematical form of the likelihood function.