Implementing DS(G,m) custom prior for STAN


#1

@deepstan and I respectfully request any assistance in implementing a custom prior distribution in STAN.

I have attached a one-page description of the model for the rat tumor example, along with relevant R scripts. We were successful in implementing the beta-binomial model but having some issues to make it work for our DS(G,m) prior model ( https://www.nature.com/articles/s41598-018-28130-5), which is an extension of the vanilla beta prior.

Thank you for your time and consideration. Please let us know if we can provide any additional information or insights into our request.

ModelDescription.pdf (112.7 KB)
LP.basis.R (696 Bytes)
RatTumorExample.r (1.3 KB)


#2

Just code it up manually! Check chapter 23, “Custom Probability Functions” of the users manual (edit: this is the 2.17.0 manual – things are changing soon).

You’ll probably have to just code in all m Legendre polynomials that you want and that’ll be very manual, but it souldn’t be too bad.


#3

Thanks Ben. Just to clarify, do you mean to code those Legendre polynomials in C++? We have very little expertise in that. It would be really helpful to have some function inside Stan that can compute Legendre polynomials.


#4

No need to code C++. See the chapter 23 and a case study http://mc-stan.org/users/documentation/case-studies/gpareto_functions.html


#5

The easiest way to get this working might just be to manually code up however many Legende polynomials you need. Just find the eqs. somewhere and copy them down. No need to make things too fancy. Like @avehtari said you should be able to code these as functions in your Stan model.


#6

Thank you @avehtari and @bbbales2 for your time and assitance! Very much appreciated! I will work on implementing your suggestions.