Constrain one variable to be greater than another

Note to future self
Yes, you can use a transformation (as pointed out by @junpenglao) with example here. Initially it looks a bit ARGH, but it’s pretty simple:

  • initially I had two variables k1 and k2 and wanted them to be ordered.
  • solution 1 was to reparameterize so that k2=k1+b where b>0. This seemed to work judging by some posterior predictive plots, but the chains were in fact all over the place.
  • so solution 2 was to use the ordered transform in the link above. It’s pretty simple… just add the Ordered class, then add something like , transform=Ordered(), testval=[0.1, 0.2] into the definition of the PyMC3 stochastic variable

More details at #2 on the repo

2 Likes