我正在尝试使用 PyMC3 运行基本测试模型,但我发现 ArviZplot_trace
函数无法正确显示我的跟踪。
代码
from scipy import stats
import arviz as az
import numpy as np
import matplotlib.pyplot as plt
import pymc3 as pm
import seaborn as sns
import pandas as pd
from theano import shared
from sklearn import preprocessing
if __name__ == "__main__":
with basic_model:
# Priors for unknown model parameters
alpha = pm.Normal('alpha', mu=0, sigma=10)
beta = pm.Normal('beta', mu=0, sigma=10, shape=2)
sigma = pm.HalfNormal('sigma', sigma=1)
# Expected value of outcome
mu = alpha + beta[0]*X1 + beta[1]*X2
# Likelihood (sampling distribution) of observations
Y_obs = pm.Normal('Y_obs', mu=mu, sigma=sigma, observed=Y)
# draw 500 posterior samples
trace = pm.sample(5000)
az.plot_trace(trace, compact = False)
该beta
参数是多维的,并且同时具有beta[0]
和beta[1]
,但 ArviZ 迹线仅显示beta[0]
:
轨迹图
如果我将跟踪图运行为az.plot_trace(trace, compact = True)
,那么我确实会看到beta
正确叠加的两个维度。我仅在尝试使用compact = False
.
版本
- 阿维兹:0.6.1
- 麻木:1.18.1
- 科学:1.4.1
- xarray:0.15.0
- Matplotlib:3.1.3