Skip to content

convert CmdStan CSV output to R dump format input #511

@bob-carpenter

Description

@bob-carpenter

Moved from stan-dev/stan#544

In order to perform fake data simulation or posterior predictive checking, it would be nice to be able to convert the output of a Stan model from CSV format to the input for a Stan model in R dump format.

This should be structured as a command parallel to bin/print that does the conversion of an output CSV file. An alternative would be to have a model call argument that would produce R dump output.

The manual for CmdStan needs to be updated to show how to use this function. This will enable us to write a chapter in the manual on fake data and posterior predictive checks.

Be careful about type of the columns --- if there are integer generated quantities, the output can be integers.

For example, for the Bernoulli model in the introduction, a fake-data generator should look like:

data {
  int<lower=0> N;
  real<lower=0, upper=1> theta;
}
generated quantities {
  int<lower=0,upper=1> y[N];

  for (n in 1:N)
    y[n] <- bernoulli_rng(theta);
}

Related issues:

  • To run this, we need both the output of running the Bernoulli model and a value for N in order to provide input for this model
  • Doing proper posterior model generation will require empty parameters and model blocks, so update the parser so that this works (or link to a different issue); @betanalpha is working on a feature for this with a dummy sampler that can handle empty parameter vectors

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions