What I’m trying to do: I’m producing a few large vectors (call them Mu1, Mu2 … MuN) so I can take advantage of vectorized sampling. I don’t really want to save these vectors, but (for reasons we can get into if necessary) I would like to know the variance of the vectors (e.g. var(Mu1) for each draw).

Currently, I define the vectors in the transformed parameters block and I compute the variance in the generated quantities block, but this leads to saving the vectors on each draw.

I could declare the vectors within the model block, and then they would not be saved to disk. I believe (realizing as I write that I haven’t tested this assumption) that variables defined in the model block are out of scope in the generated quantities block, so I could not compute the variances.

To answer the obvious question why I don’t want to save the vectors: It isn’t that big of a deal to save them. The drawbacks are that they are filling up my hard drive, they make loading the fit from disk take a long time, and they make the cmdstan ‘diagnose’ utility take a long time to run. Once my model is 100% working great, that’s not such a big deal, but it’s a bit inconvenient as I work to develop the model.