I need to save the model output for each iteration, but the intermediate calculations consist of large matrices, so I can’t have all that in the
transformed parameters block without blowing up all the RAM many times over.
Computing them again from the primitive parameters in the
generated quantities block should duplicate the long calculations and hurt performance.
The only other thing I could think of was writing a new function that uses the intermediate functions, and outputs only the quantities I need in the
transformed parameters block, but that could make the stan model quite unreadable.
EDIT: there’s an additional problem with this last approach, because some “transformed parameters” are computed once per iteration and used to produce multiple outputs, so this would also increase the number of calculations.
Is there a simple way of pulling quantities in the model block for the
generated quantities besides those?
Alternatively, is it possible to store only some of the