How to structure a model to plot multiple entities?

Hi all,

Relatively new to Pymc3 and i’m struggling to grok how I would build out what is likely a very simple model.

Lets say I have a dataframe similar to the following:

ent1 ent2 ent3 ent4
65 72 63 67
67 71 64 62
72 63 NaN 68
71 NaN NaN 70

I am wanting to do some fairly simple inference to get the posterior normal distribution for each entity, preferably to have each entity plotted seperately against the same x axis to show the uncertainty. Below is the model I have thus far (Don’t laugh, I know it’s crap!).

with pm.Model() as testmodel:
    mu_a = pm.Normal('mu_a', mu=0, sigma=5)
    sd_a = pm.HalfNormal('sd_a', sigma=1)
    mean = pm.Normal('mean', mu=mu_a, sd=sd_a, shape=len(newdf.columns)) 
    stdev = pm.HalfNormal('stdev', sigma=sd_a, shape=len(newdf.columns)) 
    obs = pm.Normal("obs", mu=mean, sigma=stdev, observed=newdf) # observations here.
    trace = pm.sample(draws=1000, tune=1000, return_inferencedata=True)

Any help would be appreciated, even just some guidance so I can start asking the right questions, as i’m not even sure how to properly google what it is I want to do.

Try this gist as an example: estimate-means-missing-gaussian · GitHub. You are almost right with the model you had. It was just missing some shape info, I think.