I am quite new to Pymc3 and currently trying to estimate the density of the below sales data distribution as a two-component mixture (two Mv Normals):
Everything runs fine and the model converges well after checking BFMI/GR stats.
When I sample from the posterior distribution and attempt to plot I, however, I end up with a very strange distribution. Is this something I am doing incorrectly, or is this because I have done a poor job of specifying my priors?
# Model N_SAMPLES = 2000 observed_sales = df.sales with pm.Model() as model: lam1 = pm.Exponential('lam1', lam=1) lam2 = pm.Exponential('lam2', lam=1) pois1 = pm.Poisson.dist(mu=lam1) pois2 = pm.Poisson.dist(mu=lam2) w = pm.Dirichlet('w', a=np.array([1, 1])) like = pm.Mixture('like', w=w, comp_dists=[pois1, pois2], observed=observed_sales) sales_demand_trace = pm.sample(N_SAMPLES, tune=2000, random_seed=SEED, cores=1) prior = pm.sample_prior_predictive() posterior_predictive = pm.sample_posterior_predictive(sales_demand_trace) # Draw posterior samples y_pred = pm.sample_posterior_predictive(sales_demand_trace, 10000, model) # Plot posterior data_ppc = az.from_pymc3( trace=sales_demand_trace[1000:], posterior_predictive=y_pred) az.plot_ppc(data_ppc, num_pp_samples=100, figsize=(12,6))
All help very much appreciated.