Use of data block to pass variables in order to control priors and generated quantities

I often use the data block to pass variables to stan in order to control priors (e.g. scale parameters) and generated quantities. This is advantageous for me since it avoids re-compiling and since some variables are easier to define in R than in stan (in order to define some generated quantities in my case). Until now this worked fine for me. However, I haven’t seen this use of the data block in what I read, and I am curious whether this can lead to problems in some situation, in particular when using functions like loo() that operation on stan fit object and need to understand in some way what the data is. Thank you very much for your suggestions!

1 Like

This should be fine. The loo package isn’t gonna mind what you do in the data block, as long as you’re following the instructions for generating the stuff it needs (