Error when trying to get summary statistics, trace plot and posterior plot

Hello,
I am building a Bayesian Regression model (see the code bellow) using the PyMC library. When trying to get summary statistics, trace plot and posterior plot I get an error.

I am using Google Colab. Here is the version I am using of PyMC and arviz:
Name: pymc
Version: 5.7.2
Name: arviz
Version: 0.15.1

Code:

with pm.Model() as model:
    #priors for unknown model parameters
    alpha = pm.Normal('alpha', mu=global_mean_performance, sigma=global_std_performance)
    beta = pm.Normal('beta', mu=0, sigma=10)
    sigma = pm.HalfNormal('sigma', sigma=10)

    #expected value of outcome
    mu = alpha + beta * X

    #likelihood (sampling distribution) of observations
    Y_obs = pm.Normal('Y_obs', mu=mu, sigma=sigma, observed=Y)
  
    #model fitting
    trace = pm.sample(100, return_inferencedata=False)

Error:

ValueError: Can only convert xarray dataarray, xarray dataset, dict, netcdf filename, numpy array, pystan fit, emcee fit, pyro mcmc fit, numpyro mcmc fit, cmdstan fit csv filename, cmdstanpy fit to InferenceData, not MultiTrace

If you remove return_inferencedata=False, it works. See for instance:

import pymc as pm
import numpy as np 
import arviz as az
X = np.linspace(-10, 10, 100)
Y = 1*X + 5 + np.random.normal(0, 1, X.shape)

with pm.Model() as model:
  #priors for unknown model parameters
  alpha = pm.Normal("alpha", mu=0, sigma=1)
  beta = pm.Normal("beta", mu=0, sigma=10)
  sigma = pm.HalfNormal("sigma", sigma=10)
  
  #expected value of outcome
  mu = alpha + beta * X
  
  #likelihood (sampling distribution) of observations
  Y_obs = pm.Normal('Y_obs', mu=mu, sigma=sigma, observed=Y)
  
  #model fitting
  trace = pm.sample(1000)

summary = az.summary(trace)
az.plot_posterior(trace)
2 Likes

Thank you iavicenna, it is really appreciated =)!