# Cascade Hierarchical Model

**URL:** <https://discourse.pymc.io/t/cascade-hierarchical-model/10147>\
**Category:** version agnostic\
**Tags:** modeling\
**Created:** [August 13, 2022, 6:21pm UTC](https://discourse.pymc.io/t/cascade-hierarchical-model/10147 "2022-08-13T18:21:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdhooghe](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jdhooghe/32/590_2.png) [@jdhooghe](https://discourse.pymc.io/u/jdhooghe)\
**Post date:** [August 13, 2022, 6:21pm UTC](https://discourse.pymc.io/t/cascade-hierarchical-model/10147/1 "2022-08-13T18:21:29Z")

</div>

Hello,

I am hoping to get some help on how to program a particular model in pymc. It is a two stage logistic regression hierarchical cascade where:

Event A has a probability of occurring and if it does, then there is some probability of Event B happening. If Event A does not happen then there is no possibility of Event B happening.

I have samples where B has occurred, where A has occurred but not B and where A has not occurred. One thing to note is that this is not a balanced dataset

Some ideas I had:

1. The second level, B, probability is the multiplication of A’s logistic probability and B’s logistic probability
2. The second level’s training data should only be those events which A was observed

Any help would be greatly appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![jdhooghe](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jdhooghe/32/590_2.png) [@jdhooghe](https://discourse.pymc.io/u/jdhooghe)\
**Post date:** [August 13, 2022, 10:04pm UTC](https://discourse.pymc.io/t/cascade-hierarchical-model/10147/2 "2022-08-13T22:04:12Z")

</div>

I had an insight after I created this post. Instead of using a double Bernoulli, I just use a multinomial with probabilities:

[p\_A \* p\_B, p\_A \* (1-p\_B), (1-p\_A)]

Due to class imbalance I have to under-sample but I correct the probabilities using Bayes’ rule using  
Dal Pozzolo 2015. Hopefully this helps someone in the future
