Code problem: Bayesian Cognitive Modeling - chapter 12.2 Psychophysical functions

The containment data model needs some update actually, as a start, uniform prior for sigma is not recommended (works okish in Gibbs sampling, but for nuts it is not good) try halfnormal or halfcachy with a small standard deviation.

The second point to improve is rewriting the part involving the latent discrete variable. The STAN solution for these kind of model is marginalized out the discrete variable, which leaves only continuous variables in the model. You can have a look at the STAN code comes with the book about this solution.