We use this function in our likelihood model, but it’s unavailable in the Stan function library. If someone needs this function in the meantime, this is a user-defined function for calculating it (where x is the vector of input values, m is the mu parameter, and s is the sigma parameter):
functions {
//custom function for lognormal inverse CDF
row_vector logncdfinv(row_vector x, real m, real s) {
int sz; //declaring size variable
sz = size(x); //calculating size variable
row_vector[sz] y; //declaring return variable
y = exp( s .* sqrt(2) .* inv_erfc( -2 .* x + 2 ) + m ); //calculating result
return y; //returning result
}
Note: can be fairly easily rewritten to accept real values instead of a row vector of values by declaring x as a real instead of a row vector in the input, getting rid of the two lines declaring and calculating sz, and declaring y as a real instead of a row vector.