我正在对我认为是伽马分布的数据进行建模,因此我编写了一个 PyMC3 模型,如下所示。
import pymc3 as pm
import arviz as az
with pm.Model() as model2:
alpha = pm.Exponential('alpha', 5)
beta = pm.Exponential('beta', 5)
p_factor = pm.Gamma('p_factor', alpha = alpha, beta = beta, observed = d.productivity_factor)
prior_checks = pm.sample_prior_predictive(samples=100, random_seed= seed)
trace2 = pm.sample(2000, tune=2000)
然后我绘制一个后验预测检查
with model2:
ppc2 = pm.sample_posterior_predictive(trace2, var_names=["alpha", "beta",'p_factor'], random_seed=seed)
idata = az.from_pymc3(trace2, posterior_predictive=ppc2)
az.plot_ppc(idata)
但观察到的曲线与我的预期不符。有什么我做错了吗?