Hi everyone!

I’m trying to do something fairly “simple”. Imagine I observe a process generating `y2`

and a sub-process which generates `y`

, where `y2 = f(y)`

I have an assumption about how y comes into place (i.e., I have a model of `y`

) and how `y2`

and `y`

are related (i.e., about `f()`

).

I want to sample the parameters of the function that constitute `y`

*and* those that make up the connection of `y`

and `y2`

. So far I just call multiple sample statements with `obs=`

(which works for simpler models) but Im wondering how to approach this properly.

One idea would be the sample first from the posterior of the parameters of `y`

(maybe in a separate call) or try to formulate a prior based on the empirical posterior samples of the parameters of `y`

but I’m a bit lost right now.

This can be set up quite quickly (and as I said works), but for more complex models the chains dont converge.

Here is my MWE:

```
x = np.random.normal(0, 1, 1000)
m = 5.
b = 2.
y = m*x + b + np.random.normal(0, 1, 1000)
scale = np.random.normal(0, 1, 1000) + 5
scale
y2 = y*scale
with pm.Model() as model:
m = pm.Normal('m', mu=0, sigma=1)
b = pm.Normal('b', mu=0, sigma=1)
error = pm.HalfNormal('error', sigma=1)
scale = pm.HalfNormal('scale', sigma=1)
y = pm.Normal('y', mu=m*x + b, sigma=error, observed=y)
y2 = pm.Normal('y2', mu=y*scale, sigma=1, observed=y2)
trace = pm.sample(1000, tune=1000, cores=4, chains=4, init="adapt_diag", return_inferencedata=True)
pm.summary(trace)
```

I appreciate your time and help! Thanks!