# Master-worker messaging in ep-stan

**URL:** <https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844>\
**Category:** Modeling\
**Tags:** techniques\
**Created:** [September 11, 2017, 1:04am UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844 "2017-09-11T01:04:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhomass](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bhomass/32/407_2.png) [@bhomass](https://discourse.mc-stan.org/u/bhomass)\
**Post date:** [September 11, 2017, 1:04am UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844/1 "2017-09-11T01:04:04Z")

</div>

Not sure if this question is appropriate, since its on ep-stan, not on stan proper. ep-stan passes one Q matrix and one r vector between Master and Workers. That works for the simple Bernoulli use case. My model has multiple groups of logistic functions. Can any one suggest whether I should combine the unrelated sets of coefficients into one matrix and one vector, or should I modify the code to work with multiple Q and r parameters? if multiple, it means the ep-stan sample code is not readily generalizable.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 17, 2017, 4:04pm UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844/2 "2017-09-17T16:04:59Z")

</div>

What is “ep-stan”?

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [September 17, 2017, 7:12pm UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844/3 "2017-09-17T19:12:35Z")

</div>

> [@Bob\_Carpenter](#):
>
> What is “ep-stan”?

Python code supplement for “Expectation propagation as a way of life”  
[GitHub - gelman/ep-stan](https://github.com/gelman/ep-stan)

> [@bhomass](#):
>
> My model has multiple groups of logistic functions. Can any one suggest whether I should combine the unrelated sets of coefficients into one matrix and one vector, or should I modify the code to work with multiple Q and r parameters?

It’s not clear what you mean by multiple groups. Can you show your model code?

Aki

---

<div class="post-metadata">

**Author:** ![bhomass](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bhomass/32/407_2.png) [@bhomass](https://discourse.mc-stan.org/u/bhomass)\
**Post date:** [September 17, 2017, 8:01pm UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844/4 "2017-09-17T20:01:50Z")

</div>

let’s not do this by code. I know how that will go if I throw up a whole page of code. What it is, the model has a dynamic HMM component which calculates the transition probability using logistic regression, that’s one set of parameters. For each HMM state, there is another probability of conversion which is calculated by another set of parameters. there is a third set of parameters, which is involved in estimation of the HMM state. So all together, 3 separate sets of parameters. If I lump all 3 into the current parameter passing matrix, first there needs to be room for more than one set of intercepts, second, it would not make sense to generate covariance terms for parameters that are not in the same sets. My question is therefore, should I modify the ep-stan code to allow multiple sets of parameter passing structures. Hope this is clear.

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [September 18, 2017, 6:06am UTC](https://discourse.mc-stan.org/t/master-worker-messaging-in-ep-stan/1844/5 "2017-09-18T06:06:50Z")

</div>

> [@bhomass](#):
>
> What it is, the model has a dynamic HMM component which calculates the transition probability using logistic regression, that’s one set of parameters. For each HMM state, there is another probability of conversion which is calculated by another set of parameters. there is a third set of parameters, which is involved in estimation of the HMM state. So all together, 3 separate sets of parameters.

If these parameters are all for the same data, then they are not separate. If the values of one set of parameters changes, I would assume the conditional posterior for others would change, too.

Even if we would have separate sets of parameters for separate sets of data, the tilted distribution is likely to have dependencies between the parameters if they have common prior.
