[R] What function in R is to estimate the marginal denstiy f

(Ted Harding) ted.harding at nessie.mcc.ac.uk
Sat Mar 17 23:33:39 CET 2007


On 17-Mar-07 22:14:54, junjun deng wrote:
> I have 10000 bivarate samples (x1, x2), and I want to estimate the
> marginal density of x2. I searched the R manual but couldn't find a
> function that can do this job. It seems "density" only works for
> single-variate samples. Can anybody help me with it? Thanks a lot!
> 
> Best,
> J. Deng

Suppose your bivariate data are in (say) a matrix with 10000 rows
and two columns (col 1 for x1, col 2 for x2).

If you are happy to use "density" to estimate the density of
a univariate variable, then what is wrong with

  density(x[,2])?

Provided the points (x1,x2) are a sample from the bivariate
distribution of x1 and x2, the values of x1 are irrelevant to
the marginal distribution of x1.

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 17-Mar-07                                       Time: 22:33:09
------------------------------ XFMail ------------------------------



More information about the R-help mailing list