Can't sample posterior predictive, if model uses no covariates

Hi. I am trying to simulate data using the numpyro implementation of the stochastic volatility model, described in the docs. However, when I try to get posterior predictive samples, it just returns observed values. For clarity, here’s the model function below:

def model(returns):
    step_size = numpyro.sample("sigma", dist.Exponential(50.0))
    s = numpyro.sample(
        "s", dist.GaussianRandomWalk(scale=step_size, num_steps=jnp.shape(returns)[0])
    nu = numpyro.sample("nu", dist.Exponential(0.1))
    return numpyro.sample(
        "r", dist.StudentT(df=nu, loc=0.0, scale=jnp.exp(s)), obs=returns

So, when I try to predict after fitting the model:

predictive = Predictive(model=model, posterior_samples=mcmc.get_samples())
samples_predictive = predictive(random.PRNGKey(42), returns)

I just get my observed returns back.

Am I doing something wrong? Is there a way to actually forward sample it? Thank you!

“r” in the trace should have your predicted values

What variable do you want to simulate?

Do you maybe want this

def model(returns=None):
  if returns:
   numpyro.sample("r", ..., obs=returns)

Hi @dirknbr. Appreciate your reply. Yes, I also raised this question on github and the guys there helped me out. Long story short, I needed to make the observed data a kwarg and set it to None.