Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Integration in R with integrate function

$
0
0
library(pbivnorm)

rho <- 0.5
f1 <- function(x, y) {
  pbivnorm(log(x)-10, log(y)-10, rho)*(exp(-(log(x)-10)^2/2)/(sqrt(2*pi)*x))*(exp(-(log(y)-10)^2/2)/(sqrt(2*pi)*y))
}
integration1 <- round(integrate(function(y) {
  sapply(y, function(y) {
    integrate(function(x) f1(x,y), 0, Inf, rel.tol = 1e-12)$value
  })
}, 0, Inf, rel.tol = 1e-12)$value, 10)

This integration should be around 0.3, but R gives 0. Could anyone point out the problem? What is the best function for integral in R? Many thanks.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>