R/ddiri.R

Defines functions ddiri

Documented in ddiri

################################
#### Dirichlet distribution parameters
#### Tsagris Michail 3/2012
#### mtsagris@yahoo.gr
################################
ddiri <- function(x, a, logged = TRUE) {
  ## x is the compositional data
  ## a is a vector with the parameters
  if ( is.null(dim(x)[1]) ) {
    f <- lgamma( sum(a) ) - sum( lgamma(a) ) + sum( log(x) * (a - 1) )
  } else  f <- lgamma( sum(a) ) - sum( lgamma(a) ) + as.vector( log(x) %*% (a - 1) )

  if ( logged ) {
    f <- f
  } else   f <- exp(f)

  f
}

Try the Compositional package in your browser

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

Compositional documentation built on Oct. 9, 2024, 5:10 p.m.