Cannot find special function lambert_w0


I’m unable to find the special function lambert_w0 in my pystan/rstan program.

See doc and stan math pr.

I’m assuming here that stan-math functions should just eventually appear for use in rstan/pystan; though this might not be well-founded.

    int signum(real y)
        return y > 0 ? 1 : -1;
    int N;
    real y[N];
    real<lower=0> d;
transformed parameters
    real z;
    z = sign(y) * lambert_w0(d * y^2) / d; // doesn't work as lambert_w0 not found
    d ~ gamma(1, 2);
    z ~ normal(0, 1);
    // todo jacobian adjustment since i'm putting a prior on a transformed parameter

I get a compile error and also

> rstan::lookup('rep')
      StanFunction       Arguments ReturnType
579 rep_row_vector (real x, int n) row_vector
580     rep_vector (real x, int m)     vector
> rstan::lookup('lambert')
[1] "no matching Stan functions"

The current CRAN rstan is a few versions behind, and so doesn’t have the function available.

Try the preview of the next rstan version, restart R (making sure that rstan doesn’t get loaded) and run:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("", getOption("repos")))
install.packages("rstan", repos = c("", getOption("repos")))