RE: [R] how to estimate conditional density

2004-11-17 Thread Ted Harding
On 17-Nov-04 Yulei He wrote:
 Hi, there.
 
 Suppose I have a bivariate data set y1 and y2. Can anybody
 tell me how to estimate the conditional density of f(y1|y2)
 and vice versa? Thanks.
 
 Yulei

In the absence of a parametric model for the distribution,
a simple-minded approach could be the following:

1. Use 'f-kde2d(...)' from the MASS library to generate a
   kernel density estimate of the bivariate distribution,
   ensuring that your (y1,y2) grid includes the value of y2
   at which you want to get f(y1|y2). Suppose that different
   values of y2 correspond to different rows of the matrix
   f$z in the returned result (see ?kde2d).

2. For the row [i] corresponding to the conditioning value
   of y2, normalise the values so that sum(f$z[i,]*dy1)=1,
   where dy1 is the step between different values of y1 in
   the grid used in (1).

The resulting normalised row of values is then an estimate
of f(y1|y2), for each such value of y2.

Similarly, applying (2) to the columns of f$z, you can get
an estimate of f(y2|y1).

[Note: for each single value of y2, you don't need to estimate
 the density of y2, i.e. for this purpose you can forget about
 the definition f(y1,y2)/f(y2) of f(y1|y2).]

Hoping this helps,
Ted.



E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 17-Nov-04   Time: 09:37:20
-- XFMail --

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] how to estimate conditional density

2004-11-16 Thread Yulei He
Hi, there.

Suppose I have a bivariate data set y1 and y2. Can anybody tell me how to
estimate the conditional density of f(y1|y2) and vice versa? Thanks.

Yulei


$$$
Yulei He
1586 Murfin Ave. Apt 37
Ann Arbor, MI 48105-3135
[EMAIL PROTECTED]
734-647-0305(H)
734-763-0421(O)
734-763-0427(O)
734-764-8263(fax)
$$

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html