Hierarchical model with different priors for some child variables

I’m trying to use a hierarchical model.

As an example I’m trying to modify the code from the Partial pooling model#

For some of the child variables I have a measurement available (this is quite expensive, so is only available for a few of the child variables)- hence I’d like to make a different, much tighter prior than for the others.

I can do this via something like

measured_mus = {0: 0.5, 1: 0.5} # indexed on county_idx
with pm.Model(coords=coords) as partial_pooling_fixed_some_mus:
    county_idx = pm.MutableData("county_idx", county, dims="obs_id")

    mu_a = pm.Normal("mu_a", mu=0.0, sigma=10)
    sigma_a = pm.Exponential("sigma_a", 1)
    
    mus = [mu_a if i not in measured_mus else measured_mus[i] for i in range(len(coords['county']))]
    # can do the same for the sigmas
    alpha = pm.Normal("alpha", mu=mus, sigma=sigma_a, dims="county")

    sigma_y = pm.Exponential("sigma_y", 1)
    y_hat = alpha[county_idx]
    y_like = pm.Normal("y_like", mu=y_hat, sigma=sigma_y, observed=log_radon, dims="obs_id")

This however doesn’t use the valuable measurments to tune the parent distribution for mu_a.

How could I do that?

Quick response from my phone… You can build up a vector with Basic Tensor Functionality — PyTensor dev documentation

Or perhaps easier, you can provide vectors for mu and sigma for pm.Normal for mu_a

Thanks for checking the question!

As far as I understand your suggestion, this is what I currently do (though with a python list instead of a tensor). It works, the only problem is that the measured values in measured_mus don’t inform the posterior of the mu_a.