Observed data not read by arvis.from_pystan

The observed data is not read into arviz from pystan

data={'N':N, 'y':y, 'N_cluster':N_cluster, 'cluster':cluster}

fit_obj = az.from_pystan(
    posterior=fit, 
    posterior_predictive='y_tilde',
    observed_data=['y'],
    log_likelihood=["log_lik"]
    )

The observed_data is not showing in the InferenceData and no error is given.

The documentation of from_pystan says:

observed_data str or a list of str
observed data used in the sampling. Observed data is extracted from the posterior.data. PyStan3 needs model object for the extraction. See posterior_model.

I am not sure what does that mean. The code shown has been working in the past for me on Google Colab. Any ideas it might not be the case. Thank you for helping out!

1 Like

Just solve my own problem by writing this post. You need to assign the posterior model. Hope it helps people with similar issues.

model = stan.build(model_code,data=data) 

fit_obj = az.from_pystan(
    ...
    posterior_model=model,
    ...
    )
1 Like