[R] How to compute loglikelihood of Lognormal distribution

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Thu, 17 Jul 2008 18:33:57 +0900


I am trying to learn lognormal mixture models with EM. I was wondering how does one compute the log likelihood.

The current implementation I have is as follows, which perform really bad in learning the mixture models.


 # compute probably density of lognormal.  dens <- function(lambda, theta, k){



        for(j in 1:k){
          # each being lognormal distribution


  old.obs.ll <- sum(log(apply(dens(lambda, theta, k),1,sum)))

  # this is prior likelihood
  lognorm.ll <- function(theta, z,lambda, k) - sum(z*log(dens(lambda,theta,k)))

It is based on a slight modification of our earlier Gamma version, which works really well. The full code of Gamma version can be found here:



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 Jul 2008 - 09:37:55 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 Thu 17 Jul 2008 - 10:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive