Getting overflow (nans) in genearted quantities

if generated quantities encounters an error, processing stops for that block.
the variables declared in the block are output and those variables have been initialized to NaNs.
no error is raised, and the sampler continues to the next iteration.

this is because the computation done in generated quantities doesn’t change the parameter estimates for the draw; the sampler produced a valid draw of the parameter values from the posterior, therefore you have a valid sample. if some computation in the generated quantities block is invalid due to bad data, well, c’est la vie.