R/ldmult.R

Defines functions ldmult

Documented in ldmult

###########################################################################
# log density function of multinomial count vector y with parameter theta #
###########################################################################

ldmult<-function(y,theta){
  if (any(is.nan(theta)) || any(theta==0)) {
#      stop ("The theta parameter cannot have a zero component.")
     out = -Inf
   }
   else {
     if (length(y)==length(theta)+1)
       theta=c(theta,1-sum(theta))
     out=lgamma(1+sum(y)) - sum(lgamma(1+y)) + sum(y*log(theta))
   }
   out
}

Try the mixtools package in your browser

Any scripts or data that you put into this service are public.

mixtools documentation built on Dec. 5, 2022, 5:23 p.m.