Hi,

I am I trying to learn mixture models of gamma distributions.
However sometime the calculation of the log-likelihood it gives is
positive instead of the usual negative, in particular when
the number of samples are small.

My questions are:
1. Is it possible that a loglikelihood is positive?
2. If so, what can we say about the samples that gives the positive
    loglikelihood as oppose to the one that gives
    negative loglikelihood?

This is the snippet of my code that does it:

__BEGIN__
lmbd <-  1
thet <- c(0.2375062,12.2172144)

dens <- function(lambda, theta, k,x){
    temp<-NULL

    alpha=theta[1:k]
    beta=theta[(k+1):(2*k)]

    for(j in 1:k){
        # each being gamma distribution
        temp=cbind(temp,dgamma(x,shape=alpha[j],scale=beta[j]))
    }

    temp=t(lambda*t(temp))
    temp

}

for (try in 1:10) {
    w=c(rgamma(30,shape=.2,scale=14))
    ll <- sum(log(apply(dens(lmbd, thet,1,w),1,sum)))
    cat("Try", try, " - LL", ll, "\n")
}

__END__
- Gundala Viswanath
Jakarta - Indonesia

______________________________________________
R-help@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.

Reply via email to