[R] How to plot contours for joint density of 2 independently distributed r.v.?
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Mon Sep 15 17:07:54 CEST 2008
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
More information about the R-help
mailing list