rlearner309
2008-Sep-15 13:37 UTC
[R] How to plot contours for joint density of 2 independently distributed r.v.?
X and Y are independently distributed random variables. I would like to study the contours of the joint density of these two variables. Any function to call? Thank you very much! -- View this message in context: http://www.nabble.com/How-to-plot-contours-for-joint-density-of-2-independently-distributed-r.v.--tp19493126p19493126.html Sent from the R help mailing list archive at Nabble.com.
Dimitris Rizopoulos
2008-Sep-15 15:07 UTC
[R] How to plot contours for joint density of 2 independently distributed r.v.?
do you know the probability density functions for these random variable? If yes, then you need something like the following: x <- seq(-5, 5, len = 50) y <- seq(0.001, 10, len = 50) z <- outer(x, y, function(x, y){ dnorm(x) * dgamma(y, 5) }) contour(x, y, z) where you replace dnorm() and dgamma() with your pdf's. If you just have a sample from X and Y, then you could use kernel density estimation, for instance, check help("bkde2D", package = "KernSmooth") I hope it helps. Best, Dimitris rlearner309 wrote:> X and Y are independently distributed random variables. > I would like to study the contours of the joint density of these two > variables. > Any function to call? > > Thank you very much!-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014