I am trying to fit my model with these versions
R version 4.0.2
Rstan 2.19.3
Platform: x86_64-w64-mingw32/x64 (64-bit)

In my case I am trying to looping the likelihood function(user defined function) over 1:25 with 3 chains. Initially, I tried to fit from 1 to 5 loops, and then 1: 10 loops…For those cases I could do sampling for all chains, but I failed for all loops (i.e. 1:25), it runs only chain 1 and 2 and for chain 3, it gives following error message,

SAMPLING FOR MODEL ‘585f9f35f8c48980a605c47c29c98779’ NOW (CHAIN 3).
Chain 3: Exception: integrate: error estimate of integral 7.80258e-16 exceeds the given relative tolerance times norm of integral

Could anyone help me here? I put seed =1234 in each cases.

The error says some integral is too small to estimate reliably. Assuming your relative tolerance is 1e-8 then the integral evaluates to less than 7.8e-8.
The error doesn’t necessarily prevent sampling. Does the model produce a fit result? Does it warn about divergent transitions?

@nhuurre I replaced the integral as what you have suggested here. Thank you.
But, I still same error is giving when I am trying to run my whole loop and it prevent the sampling. The error is something like that, (relative tolerance 1e-8 )

Chain 1: Exception: integrate: error estimate of integral 2.20131e-11 exceeds the given relative tolerance times norm of integral
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Exception: integrate: error estimate of integral 2.20131e-11 exceeds the given relative tolerance times norm of integral

It was fine when looping over some rows of my data table and in this case I was able to fit results, but it mentioned some divergent transitions too. I tried to work with defining initial parameter values, so then it’s a mess.

When the integrate_1d function fails, the thing to do first is figure out exactly what function it is failing to integrate.

Then we can work through if it is overflow/underflow, or some issue with the function.

The way to do this in Stan is add print statements near where your integrals are. See what values the parameters took when the integrate failed. Once we have the parameter values we can make plots of the functions and stuff and think about if it’ll ever be possible for the integrate to work.