# Combining two models and contexts

Hi,

I have two different models trained on two different datasets.
I need to build a third model which combines parts of the two models There is no observed data/Likelihood, just some pm.Deterministic which are based on distributions of the two initial models.

Here is a stripped down example

    with pm.Model() as model1:
mu1 = pm.Normal('mu1', mu=1, sd=1)
like1 = pm.Normal('like1', mu=mu1, sd=1.0, observed=data1)

with pm.Model() as model2:
mu2 = pm.Normal('mu2', mu=1, sd=1)
like2 = pm.Normal('like2', mu=mu2, sd=1.0, observed=data2)

with pm.Model() as model3:
interested_in = pm.Deterministic('interested_in', some_function(mu1, mu2))


In general, if you have some function that computed on the MCMC samples, it is valid to do so if the RVs are from the same model. In another word, you should try to rewrite the model 1 and model 2 into one model and sample from it. Then you can get interested_in by computing some_function(mu1, mu2).