now that we’ve got standalone generated quantities merged into core Stan, we need to add hooks into the interfaces.
from this issue:
Allow users to generate additional quantities of interest (i.e., non-parameter variables which depend on the data and/or fitted parameters), after having fit a model to a specific dataset
and saved the sample to a file. After instantiating the model, for each draw in the sample, run the generated quantities block using parameter values in that draw.
The standalone_generate function requires as inputs:
the model
the dataset used to fit it
the set of draws from the posterior.
For cmdstan, the generated csv file contains the draws and can be read back in using existing methods in stan/io. It should also be possible to read in an R dumpfile which contains a the matrix of draws.
FWIW, the rstan interface will presumably input constrained parameters and convert them to unconstrained ones internally before calling the standalone generated quantities block. I think we can compile the standalone generated quantities block with the existing infrastructure.