[R] Bivariate normal integral

juliane0212 stephanmi1 at web.de
Thu Apr 19 16:08:57 CEST 2012


hello,

I'm trying to improve the speed of my calculation but didn't get to a
satisfying result.

It's about the numerical Integration of a bivariate normal distribution.

The code I'm currently using
 
          x <- 
qnorm(seq(.Machine$double.xmin,c(1-2*.Machine$double.eps),by=0.01),
mean=0,sd=1)
          rho <- 0.5

 integral <-   function(rho,x1){
                           m1 <- length(x1)-1
                           integral <- matrix(0,ncol=m1,nrow=m1)
                           for (i in c(1:m1)){
                                for (j in c(1:m1)){
                                     integral[i,j] <-
pmvnorm(lower=c(x1[i],x1[j]), upper=c( x1[c(i+1)], x1[c(j+1)]),
corr=matrix(c(1,rho,rho,1),ncol=2))
                                } }
                            return(integral)}

     integral(rho,x)

I need all these values separated as in my calculation, but currently it's
much too slow...

Has anyone an idea how to improve it?

Thanks
Juliane



--
View this message in context: http://r.789695.n4.nabble.com/Bivariate-normal-integral-tp4571018p4571018.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list