Hi, in the reference for available distributions there is no docs for the log-logistic distribution. In this forum there is only thread about this and it was self-written. Do we have an official one exist somewhere? Thanks.
If itās not in the docs and thatās the only forum reference you found, itās probably not there.
If you need a custom distribution that isnāt included in Stan, there are workarounds. Check: https://mc-stan.org/docs/2_18/stan-users-guide/user-defined-probability-functions.html and https://mc-stan.org/docs/2_18/reference-manual/increment-log-prob-section.html
Going from the Wikipedia definition of the log-logistic (for p(x | \alpha, \beta)), you could probably do something like:
target += log(beta) - log(alpha) + (beta - 1) * (log(x) - log(alpha)) - 2 * log1p(pow(x / alpha, beta))
Thanks, I could get these likelihood done, but as mentioned in the title, the main concern is the random sampling function *_rng
for use in generated quantities
block. Not sure how to implement that?
Actually, āsampling functionā isnāt as clear as youād hope itād be, since the likelihood is also known as the āsampling modelā.
With regard to the random variate generation, hereās a hint from Wikipedia [if you canāt take it from here Iāll try and help out more later]:
If X \sim \text{log-logistic}(\alpha, \beta) then \log(X) \sim \text{logistic}(\log(\alpha), 1/\beta). To generate a logistic random variate Y with parameters a and b, we can generate U \sim \text{uniform}(0, 1) and then make Y = a + b (\log(U) ā \log(1 ā U)). Setting a = \log(\alpha) and b = 1/\beta and letting X = \exp(Y) should get you what you need. Please check the calculations as I havenāt had time to do so.