Generate the Uniform Distribution using it in multiple blocks

I think you can just replace this line

p[c] = inv_logit(beta0 + beta1 * x2[c] * lambda);

with

p[c] = inv_logit(beta0 + beta1 * ((pow(x[i], lambda) - 1)) ;

If lambda = 0 then beta1 * ((pow(x[i], lambda) - 1) = 0 as in the original code. You can then delete the transformed data block.

As side notes:

  • If you are not interested in saving the p estimates directly, the model will probably be faster without the loop and with binomal_logit . This would also get rid of the loop with y and the transformed parameter block.
y ~ binomial_logit(n, beta0 + beta * (pow(x, lambda) - 1));
  • If you have a uniform prior on lambda, you should declare it as
real <lower=-5, upper = 5> lambda;
1 Like