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)
ChrisMM
10.1k20 gold badges41 silver badges60 bronze badges
asked Apr 11, 2020 at 0:16
Guilherme Parreira
1,07112 silver badges33 bronze badges
-
I'm thinking that asking at the github/TMB (also) about this and reporting back the results here would help others that want to template their particular distribution would be helpful.Chris– Chris2020年04月11日 04:03:56 +00:00Commented Apr 11, 2020 at 4:03
-
Tks, I just posted it there as well groups.google.com/forum/#!topic/tmb-users/3_ElYPKPoJ4Guilherme Parreira– Guilherme Parreira2020年04月13日 17:48:54 +00:00Commented Apr 13, 2020 at 17:48
-
In the last paragraph of kaskr.github.io/adcomp/_book/Tutorial.html it says how. And in the TMB group (link above), they also answered.Guilherme Parreira– Guilherme Parreira2020年05月11日 21:01:48 +00:00Commented May 11, 2020 at 21:01
lang-r