Init for cmdstanr

The sample method in cmdstanr allows users to specify an init argument, see https://mc-stan.org/cmdstanr/reference/model-method-sample.html.

But the options seem limited:

  • pass a scalar x, and have the init be sampled between [-x, x]
  • pass 0
  • pass the path to a file with init values

The latter is fine provided we can pass a different file for each chain. Would it be possible to implement something a la RStan, where the user specifies a function init()? Under the hood, the function is ran N times, where N is the number of chains, and each run outputs an Rdump file that’s then called by cmdstan.

Maybe this is already an available feature?

Yeah, you need to specify N paths to files for N chains.

Do you have a simple example on the use with RStan? We would probably do this with Json as the json parser in cmdstan is faster and cmdstanr only provides functions to write json files.

@jonah what do you think about such a feature?