[R] Question on computing mv-norm density

Tong Wang wangtong at usc.edu
Tue Feb 6 05:24:08 CET 2007


Hi, 
    I am trying to figure out how to evaluate the density function of multivariate normal efficiently for a large data set, the 
data set should look like this (take d=2 for example): 
          
           data                                        mean                                      sigma

       2.131, 3.000                       1.000,1.000                                     1   0
                                                                                                                0   1

       1.231,5.141                        2.000,2.000                                      .5  -.1
            .............                                 .............                                          -.1 .4
                                                                                                                 .........

that is , I need   SUM_i (log(dmvnorm(d[i], mu[i], sigma[i])).     tried to rewrite the dmvnorm function from mvtnorm 
package, but could not find a satisfactory method to avoid using loops.  ( using those "apply" functions seem to be slower
than loops) .  May I get some suggestion on this ? Thanks a lot in advance. 

best



More information about the R-help mailing list