Stan's integral estimates exceeds the given relative tolerance times norm of integral

In my stan program integrals are involved, and stan returns errors like

integrate: error estimate of integral 1.4822e-323 exceeds the given relative tolerance times norm of integral

I have tried to set rather loose relative tolerance, like 10^{-2}

integrate_1d(functionintegrand, 1e-6,x,{mu, lambda}, {1.0}, x_i,1e-2)

But then the error still exists, and this time the error estimate becomes larger, like

integrate: error estimate of integral 0.0018877 exceeds the given relative tolerance times norm of integral

Is this caused by looser relative tolerance causes Stan to execute Gauss–Kronrod algorithm also in a ‘looser‘ way and therefore producing larger error estimate? Would it be possible to use other ways to solve the error of error estimate of integral exceeding given relative tolerance times norm of integral?

Thanks in advance!

I believe, based on this source code, that Stan uses double-exponential quadrature for integrate_1d with implementation provided by Boost. Docs on those functions here: Overview

Can you share more of your code, particularly the function you are integrating and enough of the other blocks to deduce the values of the parameters and integration ranges.

I’m no expert, but the first error, with the error estimate at a ridiculously low number, indicates that either the relative tolerance was set ridiculously low, or the norm of the integral is essentially 0, for some reason.

2 Likes

Thanks! After checking the code, I found that the problem is caused by computing c.d.f. of inverse Gaussian distribution by integrating its p.d.f., instead of using the closed form c.d.f. . After I computed the c.d.f. by closed form directly the error disappeared.

1 Like