Any one know is there any package or function to generate bivariate exponential distribution? I gusee there should be three parameters, two rate parameters and one correlation parameter. I just did not find any function available on R. Any suggestion is appreciated. -- View this message in context: http://r.789695.n4.nabble.com/How-to-generate-bivariate-exponential-distribution-tp3596944p3596944.html Sent from the R help mailing list archive at Nabble.com.
Petr Savicky
2011-Jun-15 07:33 UTC
[R] How to generate bivariate exponential distribution?
On Tue, Jun 14, 2011 at 08:40:00AM -0700, xuyongdeng wrote:> Any one know is there any package or function to generate bivariate > exponential distribution? I gusee there should be three parameters, two rate > parameters and one correlation parameter. I just did not find any function > available on R. Any suggestion is appreciated.Do you have a specific bivariate exponential distribution in mind? If not, then try the following n <- 1000 lambda1 <- 2 lambda2 <- 3 common <- 1 x1 <- rexp(n, rate=lambda1-common) x2 <- rexp(n, rate=lambda2-common) z <- rexp(n, rate=common) y1 <- pmin(x1, z) y2 <- pmin(x2, z) The variables y1, y2 have exponential distribution with rates lambda1, lambda2 and they are positively correlated, if 0 < common < min(lambda1, lambda2) The correlation increases with increasing "common". Petr Savicky.
Petr Savicky-2, thanks you. It seems the code works very well. I use rate=1, so "common" is between 0 to 1. Thanks again. -- View this message in context: http://r.789695.n4.nabble.com/How-to-generate-bivariate-exponential-distribution-tp3596944p3602539.html Sent from the R help mailing list archive at Nabble.com.