[R] bivariate normal

Rolf Turner rolf.turner at xtra.co.nz
Sat Jul 28 00:46:12 CEST 2012


On 28/07/12 05:45, Anders Holm wrote:
> Dear list members
>
>
>
> I need a function that calculates the bivariate normal distribution for each observation. It is part of a likelihood function and I have 1000's of cases. As I understand it I cannot use packages like "mvtnorm" because it requres a covariance matrix of the same dimension as the number of observations.

     Huh?  Where ever did you get that idea?  (Makes no sense at all,
     as far as I can see.)
> Basically what I need is a function that takes as arguments a n*2 matrix of bivariate values given a common mean and covariance matrix, where n is the number of cases and which returns a n*1 vector of the probabilities of the bivariate normal distribution of the n*2 vector of values.

     Sorry, I must be a bit dim, but I don't follow this at all.

     Anyhow, either dmnorm() from the "mnormt" package or
     dmvnorm() from the "mvtnorm" package should, properly applied,
     do everything that you want.

         cheers,

             Rolf



More information about the R-help mailing list