stan-dev / stan-dev/cmdstan

convert CmdStan CSV output to R dump format input

Open
#511 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
238
Forks
106
Avg merge
2h 29m
Merged PRs (30d)
6

Description

Moved from https://github.com/stan-dev/stan/issues/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the existing bin/print command and the CmdStan manual. Trace how CmdStan CSV output is represented, including integer generated quantities, and determine the command interface for producing R dump input. Done means the conversion works for the Bernoulli example and the manual documents its use for fake-data simulation and posterior predictive checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.