PyMC and arviz problem when trying to get summary statistics

25 views Asked by At

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 Traceback (most recent call last) in <cell line: 1>() ----> 1 summary = az.summary(trace) 2 print(summary)

2 frames /usr/local/lib/python3.10/dist-packages/arviz/data/converters.py in convert_to_inference_data(obj, group, coords, dims, **kwargs) 128 "cmdstanpy fit", 129 ) --> 130 raise ValueError( 131 f'Can only convert {", ".join(allowable_types)} to InferenceData, ' 132 f"not {obj.class.name}"

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

I have tried to find post with similar problem, but I haven't found the correction solution

0

There are 0 answers