[R] puzzle with integrate over infinite range

Thomas Lumley tlumley at u.washington.edu
Tue Sep 21 19:00:27 CEST 2010


On Tue, 21 Sep 2010, baptiste Auguié wrote:

> Thanks, I'll do that too from now on.
> It strikes me that in a case such as this one it may be safer to use a truncated, finite interval around the region where the integrand is non-zero, rather than following the advice of ?integrate to use Inf as integration limit. At least one wouldn't risk to get an entirely wrong result depending on a choice of rel.tol. Regarding this parameter, is there a simple interpretation of how it affected the result in the context of my example?
>

Not really.

If you know where the integrand is non-zero then you can shift it so that integrate() can handle it.  If you don't know then you can't get the truncated interval right.

The truncation approach works well for the Normal density because it it is non-negative, symmetric, and has nearly bounded support. The truncation error goes down extremely fast and if the mode of the density is in the center of the interval then all the mass can easily be found.   If you have a function with multiple modes and heavier tails it is harder to get an interval that is large enough to make the truncation error small, and still allows the integrate() function to find all the mass.

     -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle


More information about the R-help mailing list