# Adding Multilevel to my hierarchical switchpoint model

**URL:** <https://discourse.pymc.io/t/adding-multilevel-to-my-hierarchical-switchpoint-model/2965>\
**Category:** Questions\
**Created:** [March 20, 2019, 3:45pm UTC](https://discourse.pymc.io/t/adding-multilevel-to-my-hierarchical-switchpoint-model/2965 "2019-03-20T15:45:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [March 20, 2019, 3:59pm UTC](https://discourse.pymc.io/t/adding-multilevel-to-my-hierarchical-switchpoint-model/2965/2 "2019-03-20T15:59:45Z")

</div>

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](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](https://discourse.pymc.io/t/switch-point-metropolis-tuning/1082). But hopefully it will be useful for you.

---

_[View the full topic](https://discourse.pymc.io/t/adding-multilevel-to-my-hierarchical-switchpoint-model/2965)._
