I have read arviz.plot_ppc
and pymc3.waic
(although it is out-of-date).
I still cannot understand the usage of ppc, and this is my code.
r_CH4_obs = r_2 + r_3 + r_4
r_CO_obs = - r_3 - r_4 + r_1
r_CO2_obs = - r_2 + r_4 - r_1
##Likelihood function
r_CH4_likehood = pm.Normal('r_CH4_likehood',mu = r_CH4_obs, sd = sigma, observed = r0_CH4)
r_CO_likehood = pm.Normal('r_CO_likehood',mu = r_CO_obs, sd = sigma, observed = r0_CO)
r_CO2_likehood = pm.Normal('r_CO2_likehood',mu = r_CO2_obs, sd = sigma, observed = r0_CO2)
Here is my likelihood.
from scipy import optimize
with Tk_PL_ab_3478:
map_estimate = pm.find_MAP()
print(map_estimate)
step = pm.NUTS()
#prior = pm.sample_prior_predictive()
trace_Tk_PL_ab_3478 = pm.sample(draws = 10000, tune = 10000, cores = 2, start = map_estimate, step = step)
#posterior_predictive = pm.sample_posterior_predictive(trace_PL_in_134)
prior_check = pm.sample_prior_predictive(samples = 500)
ppc = pm.sample_posterior_predictive(trace_Tk_PL_ab_3478, var_names=["r_CH4_likehood","r_CO_likehood","r_CO2_likehood"])
And here is my sampling codes.
import arviz as az
az.plot_ppc(Tk_PL_ab_3478, var_names=["r_CH4_likehood","r_CO_likehood","r_CO2_likehood"],group ={'posterior'})
When I use plot_ppc
,
TypeError: Data must include log_likelihood in sample_stats
occurred.
How can I deal with my codes?
Another question is about waic, used for model comparison. But in this case, I cannot run waic due to multi-likelihood. How can I use waic and loo with multi-likelihood?
Finally, in old version of pymc3, model comparsion method like dic is availble but now I cannot use it. Any other model comparison methods, like Baysian factors? or anything else?
Thank you!