Message-ID: <48CE7A4A.6020008@erasmusmc.nl>
Date: 2008-09-15T15:07:54Z
From: Dimitris Rizopoulos
Subject: How to plot contours for joint density of 2 independently distributed r.v.?
In-Reply-To: <19493126.post@talk.nabble.com>
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