Discrete change point unnormalized probability estimate

I am trying to reproduce the example in section 15.2 of the stan manual dealing with modelling latent discrete parameters. My code and data is at: https://gist.github.com/jsta/46d76e689055cbf3708002a06e7ddb97

I think I have it working correctly (at least my plot resembles Figure 15.2B). However, I am having trouble reproducing 15.2A. Am I correct that no code is given for calculating the unnormalized probability estimate here? As far as I can tell the manual source code provides no clues because it is using pre-rendered figures. Is there some place where I can view the full stan programs used in creating the manual?

Does the required code also go in the generated quantities block? What is s prime?

Sorry I missed this a few weeks ago. See:

https://github.com/stan-dev/stan/tree/develop/src/docs/stan-reference/programs/mining-disasters

Specifically, line 16 of:

https://github.com/stan-dev/stan/blob/develop/src/docs/stan-reference/programs/mining-disasters/fit.R

which has the plotting code. You could do this in the generated quantities block, but I just did it on the outside.

That sould’ve been log_softmax not log <- softmax—I’ll blame ESS for that one.

@Bob_Carpenter Funny, I went and ran the example. I missed the fact that log was being assigned to and was so confused by,

Error: C stack usage 7970696 is too close to the limit

I made a few edits here: https://github.com/stan-dev/stan/pull/2517/files