Skip to content

InferenceData from prior predictions without constant data  #5722

Closed
@TimOliverMaier

Description

@TimOliverMaier

constant_data missing after pm.sample_prior_predictive()

In some use-cases one might want to sample and plot prior predictions before sampling the posterior. For
this purpose, it would be nice to have "constant_data" group in the az.InferenceData object, that
pm.sample_prior_predictive() returns.

Please provide a minimal, self-contained, and reproducible example.

import pymc as pm
import numpy as np

x = np.arange(-10,10)
y = 2*x+1.4+np.random.normal(0,0.3,x.size)

with pm.Model() as model:
    x = pm.MutableData("x",x)
    y = pm.MutableData("y",y)
    a = pm.Normal("a",mu=1,sigma=2)
    b = pm.Normal("b",mu=0,sigma=2)

    mu = pm.Deterministic("mu",var=a*x+b)
    e = pm.Exponential("e",lam=10)

    obs = pm.Normal("obs",mu=mu,sigma=e,observed=y)

with model:
    prior_pred = pm.sample_prior_predictive(model=model)

In the example above prior_pred has following groups:
+prior
+prior_predictive
+observed_data

Versions and main components

  • PyMC/PyMC3 Version: d322f7 (current main branch v4)
  • Aesara/Theano Version: e5ebf2 (current main branch)
  • Python Version: 3.10.4
  • Operating system: Ubuntu 20.4
  • How did you install PyMC/PyMC3: (conda/pip) pip -e

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