I am unsure if I should add pm.Deterministic to my model or not? Here is the code for my exisiting model:
with pm.Model() as newmodel:
mu_alpha = pm.Normal("mu_alpha", mu=0, sigma=0.1)
sigma_alpha = pm.HalfCauchy("sigma_alpha", beta=0.5)
mu_beta = pm.Normal("mu_beta", mu=0, sigma=0.1)
sigma_beta = pm.HalfCauchy("sigma_beta", beta=0.5)
alpha = pm.Normal("intercept", mu=mu_alpha, sigma=sigma_alpha, shape=2)
beta = pm.Normal("beta", mu=mu_beta, sigma=sigma_beta, shape=2)
noise = pm.Exponential("noise", 10)
mu_obs = beta[cat_1_data] * x + alpha[cat_2_data]
obs = pm.Normal("obs", mu=mu_obs, sigma=noise, observed=observed_data)
idata = pm.sample_prior_predictive(samples=50, random_seed=rng)
az.plot_ppc(idata, group='prior', observed=True)
idata.extend(pm.sample(6000, tune=2000, random_seed=rng))
az.plot_trace(idata)
pm.sample_posterior_predictive(idata, extend_inferencedata=True, random_seed=rng)
az.plot_ppc(idata, num_pp_samples=500, group = "posterior")
print(pm.summary(idata))
Am I supposed to add following line to my code as well?
mu_obs_det = pm.Deterministic("mu_obs_det", mu_obs)
obs = pm.Normal("obs", mu=mu_obs_det, sigma=noise, observed=observed_data)
Apologies for the newbie question!
I am currently seeking help with above model. The posterior predictive checks show that my model is not fitting the bserved data well and I need to make some tweaks. If anyone has expertise in Bayesian model (and has little bit of extra time) and can offer further guidance, I would greatly appreciate it. Please feel free to DM me for more details. Thank you in advance for your help!