Thank you, Paul. That worked in the sense that I now have revised the function to a) only use update() and b) to use stanvars to change the priors. That is, the ‘loop’ now never requires recompiling. However, the function still crashes. I think it might be due to the repeated calls to the bridgesampler. Any idea why that might be happening?