Skip to content

Include "transformed data" to argument of az.from_pystan() #2423

@HJA24

Description

@HJA24

Hi,

One of the arguments for the function az.from_pystan() is "observed_data". According to the docs "observed data" is extracted from the posterior.data.
My Stan model uses the "transformed data"-section extensively and I would like to extract variables defined here intoaz.InferenceData-object.

Is it possible to make sure that also the data from "transformed data" can be selected for "observed data"?

The corresponding error-log:

File "/Users/HJA/PycharmProjects/ufc/scripts/sample.py", line 58, in sample
    return az.from_pystan(
  File "/Users/HJA/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/arviz/data/io_pystan.py", line 1079, in from_pystan
    ).to_inference_data()
  File "/Users/HJA/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/arviz/data/io_pystan.py", line 609, in to_inference_data
    obs_const_dict = self.observed_and_constant_data_to_xarray()
  File "/Users/HJA/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/arviz/data/base.py", line 65, in wrapped
    return func(cls)
  File "/Users/HJA/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/arviz/data/base.py", line 65, in wrapped
    return func(cls)
  File "/Users/HJA/opt/anaconda3/envs/ufc/lib/python3.10/site-packages/arviz/data/io_pystan.py", line 573, in observed_and_constant_data_to_xarray
    vals = np.atleast_1d(posterior_model.data[key])
KeyError: 'y1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions