Hello. I am trying to run a constrained optimization in rstan. My model looks something like y ~ B0 + B1X1 + B2X2. I already built a model to find the posterior estimates for B0, B1, and B2. Now I want to find the optimal values of X1 and X2 in order to maximize y (given some constraints on how big or small the X’s can be).

Can someone point me to some example code on how to do this? Much appreciated.

Thanks!