How to find the details of why sampling is not working in some special cases

I am fitting a model with stan, but get the following error messages:

In validityMethod(object) :
The following variables have undefined values: effpi[1],The following variables have undefined values: effpi[2],The following variables have undefined values: toxpi[1],The following variables have undefined values: toxpi[2],The following variables have undefined values: desri[1],The following variables have undefined values: desri[2],The following variables have undefined values: dose_j. Many subsequent functions will not work correctly.

Some of the generated quantities are NaN. The corresponding posterior parameters are generated without problems. How can I find out what is causing this?

Are the gq with NaN values integers? The issue can be caused by simulating values that are too large to be held by int’s

Yes, that appears to be the problem. I’ve modified it and solved the issue. Thanks!