[R] multivariate integral with ADAPT when the parameter is close to boundary

Muhtar Osman mjosman at gmail.com
Sun Oct 19 06:52:25 CEST 2008


Dear All,

There is one problem I encountered when I used ADAPT to compute some
2-D integral w.r.t beta density.

For example, when I try to run the following comments:

fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))}
int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4)

It seems it will take very long time to run. Acturally, I stopped the
program after it was running for like 20 minutes.

I thought this might be due to the inclusion of the lower and upper in
to the integral computation, so I tried to change the lower and upper
limits:

fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))}
int.fun2<-adapt(ndim=2,lo = c(0.0001,0.0001), up =
c(0.9999,0.9999),functn = fun2,eps = 1e-4)

It only took few seconds to run, but it gave me the wrong result:
int.fun2= 0.00202210665273673, whereas the correct result should be int.fun2=1.

I guess the reason for this is beta(0.005,0.005) has very high density
close to the boundary (theta=0).
So even letting  "lo = c(0.0001,0.0001)" will cause some loss of
probability mass in the integral computation.

I was wondering if anybody has encountered the similar problem before.
Any comments are appreciated.
Thanks.

Muhtar Osman
Dept.of Stats
NCSU



More information about the R-help mailing list