In one of my models, I estimate parameters for several subjects through the following way:
log_param_mean = pm.Bound(pm.Normal, lower=0)("log_param_mean", tt.log(3.5), 1) rfx = pm.Normal("rfx", 0, 1, shape=len(np.unique(subject_ids))) sigma_param = pm.HalfCauchy("sigma_param", 1) params = pm.Deterministic("params", tt.exp(log_param + rfx[np.unique(subject_ids)] * sigma_param))
If I were to sample the posterior predictive distribution with PyMC3, then I would get posterior samples for each of my subjects. What I’m really interested in is population level samples. So right now, this parameter has a log-normal distribution. How can I use PyMC3 to sample that log-normal distribution and get population level samples for my parameter (either when using
Could I do something like
rng = tt.shared_randomstreams.RandomStreams() sampled_param = pm.math.exp(log_param_mean + rng.normal()*sigma_param) pop_param = pm.Deterministic('pop_param', sampled_param)
I hope that is clear. If not, I can gladly add context.