Adding Multilevel to my hierarchical switchpoint model

You need to code it in a design matrix, and do switch point on the linear predictor (since the switch is always conditioned on age, you can essentially do pm.math.switch on any linear predictor that has age on it, being it age*sex or age*body_length).

You can have a look at one of the analysis i did for a paper: https://github.com/iBMLab/Static_dynamic the repo is a bit dated, and if I were to do the same analysis again I will use a continues switch point model. But hopefully it will be useful for you.