How to include a different probability distribution in TMB in R?

111 views Asked by At

I am using the TMB package in R, and I want to use a density distribution which is not available in the R style distribution.

How should I include it? I didn't find anything in the documentation.

For example, I want to use Simplex distribution, which I have already written in R:

dsimplex <- function(y, mu, sigma, log=TRUE){
  dis <- (y-mu)^2 / (y*(1-y)*mu^2 *(1-mu)^2)
  dsim <- -0.5*log(2*pi) -0.5*log(sigma) -
    (3/2)*log(y*(1-y)) - (1/(2*sigma))*dis
  if(log == FALSE){dsim <- exp(dsim)}
  return(dsim)
}

and it is available in simplexreg and Stan packages.

  • What is the best approach to deal with it? (I would like to have an external file which contains this density, and call it from the file that I am writing my log likelihood)
0

There are 0 answers