[R] Meaning of Positive LogLikelihood
Gundala Viswanath
gundalav at gmail.com
Fri Jul 11 16:53:10 CEST 2008
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
More information about the R-help
mailing list