Skip to content

sample method - proper handling of models with no parameters #425

@docsteveharris

Description

@docsteveharris

Summary:

I get the following error when trying to use the generated quantities block to do prior predictive checks.

/opt/homebrew/Caskroom/miniforge/base/envs/stan-base/lib/python3.8/site-packages/cmdstanpy/utils.py in scan_metric(fd, config_dict, lineno)
    714     lineno += 1
    715     if not line == '# Adaptation terminated':
--> 716         raise ValueError(
    717             'line {}: expecting metric, found:\n\t "{}"'.format(lineno, line)
    718         )

ValueError: line 1045: expecting metric, found:
	 "#"

I think I am following this advice in the Stan users' guide.

data {
  int<lower = 0> N;
  vector[N] x;
}
generated quantities {
  real alpha = normal_rng(0, 1);
  real beta = normal_rng(0, 1);
  real y_sim[N] = poisson_log_rng(alpha + beta * x);
}

I have asked for help on the Stan user's forum without success so far. I wonder though if this is to do with the CmdStanPy implementation since the error is arising from utils.scan_metric?

Description:

Full details and a MWE are provided on the stan forums.
See https://discourse.mc-stan.org/t/implementing-prior-predictive-checks-in-stan/23815

Additional Information:

I can get a similar model to compile using the transformed parameters block instead.
I'm posting here since there are fewer Python than R users there are on the Stan forum, and if this is not a problem with CmdStanPy then I can go back to those forums confirming that I've checked here.

Current Version:

Python implementation: CPython
Python version       : 3.8.10
IPython version      : 7.25.0

matplotlib: 3.4.2
seaborn   : 0.11.1
cmdstanpy : 0.9.76
pandas    : 1.3.1
arviz     : 0.11.2
numpy     : 1.21.1

Many thanks

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions