Helen Broome
2012-May-21 17:17 UTC
[R] Erratic error with adaptIntegrate in cubature package
Hi everyone, I have been using adaptIntegrate from the cubature package for a multidimensional integral that has infinite variance (and so not appropriate for Monte Carlo techniques). Most of the time it works but sometimes (though not always) when I slightly increase the accuracy I want, or increase the bounds of integration I get the following error: REAL() can only be applied to a 'numeric', not a 'pairlist' For instance if the calculation works with absError=1e-3 and takes approximately 10 seconds then asking for absError=1e-4 I get the error about REAL() within one second. So even though the computation should take longer it doesn't seem to be starting. However later on when I ask for absError=1e-4 it works. The error is quite erratic so I don't understand what is going wrong or how to prevent it happening. There are three parameters that I sometimes change and each can cause this error all of a sudden (but most of the time it doesn't so there doesn't seem to be any consistency!) - absError (a parameter from the adaptIntegrate function) I write this as absError = 1e-x for some natural number x - upperBound / lowerBound (a parameter from the adaptIntegrate function) I write these as upperBound = c(a,b) for some real numbers a,b. - a parameter that I pass to my function that is being integrated and is just a real number Once I defined a variable A<-10 and then passed A to the function and got an error but when I tried the exact same call but wrote 10 directly instead of using A it worked fine. However later on using A again there was no problem. Most of the time the error occurs when I slightly increase the desired accuracy or the domain of integration. Is this a known bug? Thanks for any suggestions! [[alternative HTML version deleted]]