Quantile function from algebra solver

Hello,
I have a CDF function and I would like to find its quantile function so that it can be used to generate Random Numbers in Stan to perform posterior predictive check. Since it is non-linear so could not find its inverse ie quantile function. Hence I convert CDF to another form so that it can be solved to get the quantile function using an algebra solver. I have read the stan users guide to learn algebra solver many times but my problem is a little bit different from the example given in the user guide. Is it possible to get a quantile function from the algebra solver so that it can be used in generated quantities block to generate RNG?
My CDF is like this

F(x){\text{ }} = {\text{ }}1 - \frac{1} {{(1 - e^{ - \lambda } )}}\left[ {1 - \exp \left\{ { - \lambda \left( {1 - e^{ - \beta /x} } \right)\exp ( - \alpha e^{ - \beta /x} )} \right\}} \right]{\text{ }}

and I converted it to this form

{\text{log(}}1 - e^{ - \beta /x} ) - \alpha e^{ - \beta /x} - \log (1 - z) = 0

here \alpha, \beta and \lambda are parameters and I wanted to solve it for x using algebra solver and its root is quantile function that can be used in generated quantities block to generate RNG

where,{\text{ }}z = 1 + \frac{1} {\lambda }\log \left\{ {1 - (1 - e^{ - \lambda } )(1 - p)} \right\};{\text{ }}0 < p < 1

Thank You

Yes, Stan’s algebraic solver can be used to implicitly evaluate a quantile function so long as all of those parameters are fixed – you just define F(x) - p = as the objective function. In practice you may have to be careful with setting initial conditions to ensure reasonably robust convergence of the numerical solver, especially if p is closer to zero or one.

How to find a root of the above function and where I have to write this program in functions block or elsewhere. Please elaborate how to get a root as a function. That can be call from generated quantities block.

I won’t be able to put together a new example for you but see Some Ruminations on Containment Prior Modeling for some existing examples.

Thank you

1 Like