Re: [R] from a normal bivariate distribution to the marginal one

From: David Winsemius <>
Date: Wed, 23 Jan 2008 15:02:47 +0000 (UTC)

Elisabetta Petracci <> wrote in

> Hello,
> I'm quite new with R and so I would like to know if there is a
> command to calculate an integral.
> In particular I simulated a bivariate normal distribution using
> these simple lines:
> rbivnorm <- function(n, # sample size
> mux, # expected value of x
> muy, # expected value of Y
> sigmax, # standard deviation of X
> sigmay, # standard deviation of Y
> rho){ # correlation coefficient
> x <- rnorm(n,mux,sigmax)
> y <- rnorm(n,muy+rho*sigmay*(x-mux)/sigmax,
> sigmay*sqrt(1-rho2))
> cbind(x,y)
> }
> In this way I've sampled from a normal bivariate distribution and
> I've obtained two vectors of values:x and y..
> Now, I would like to find the marginal distribution of y from the
> bivariate distribution.

> Is there a command to do this?

It appears you left out a "^" between rho and 2.

There is an integrate() function but it requires a function (not a finite set of points). I think that what you may want is density(). Try:



If you want the cdf rather than an estimate of the pdf, then look at ecdf().

David Winsemius

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 23 Jan 2008 - 15:26:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jan 2008 - 15:30:07 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive