Extracting step size per chain in cmdstanr

I would like to extract the warmed up / sampling parameters using cmdstanr, in particular the step size. (I already have the inverse metric using fit$inv_metric()). After browsing Function reference • cmdstanr, I couldn’t find any function to get the sampler parameters.

I know how to do this with rstan, but I’d rather only use one package.

@jonah @rok_cesnovar

Ah, here it is

fit$metadata()

which included the adapted step size!

1 Like

Indeed, fit$metadata() includes everything that is inside the result CSV (even if you modify cmdstan and print some additional info in the CSV by yourself), apart from inv_metric which has its own method.

1 Like

Make sure to see here for ongoing exploration of a bug associated with using those values to re-start a chain:

Will check out and I’ll compare restarting the chain and just running the full chain (with rstan, I didn’t see any difference between the two).

Related question: when using fit$sample(), are the samples ordered? I know they’re not with rstan, unless I include the warmup.

They appear in the same order as in the CSV output.

I found it was sensitive to the model and data, try it with the data/model generated by the gist near the end.

For posterity, the bug was worked out, and I also posted some code that achieves things properly.

1 Like