Non-negative constrained optimization?



Hi all,
I have a question regarding the non-negative constrained parameters in general and for optimization in particular. Based on page 34 in the 2.15.0 version of user manual, it is written under 'constrained real" that non-negative constrained are supported. Also, I understand that Stan do the work in unconstrained space then do inverse transform for comply to the constraints. So, I want to make sure of the following:

  1. for optimization, the optimizers (which are basically for unconstrained optimization, as I understand), can work as constrained optimizers and can give me a minimum satisfying the non-negative constraints (x>=0)
  2. for sampling, also the obtained values of parameters are satisfying the imposed non-negatively constraints?

Thanks and best regards


If you have parameters with declared constraints then under the hood Stan will transform them to be unconstrained but the results you get at the end will satisfy the constraints. The particular transformation used depends on the constraints. They’re all described in Chapter 33 (in the manual for v2.15). But for the optimization case in particular, I also recommend taking a look at section 34.4 in the manual, which has some tips on constrained optimization problems and why sometimes you might not want to declare the constraints.


I answered this on our old list. @Mohammed_Effat: please don’t cross-post. We wind up wasting our time answering you twice.


Noted. Thanks so much, and sorry for that. Will not do again.


No problem! It’s a bit confusing that there are two stan forums at the
moment. We’re trying to phase out the google Group while also not leaving
anyone hanging so we end up responding on both. From now on you can just
post here on this forum when you have a question and we’ll definitely see




Thank you so much Drs. @jonah @Bob_Carpenter