Inequality constraints on linear combinations of parameters

I see - I misunderstood your use of “hard” and “soft”.

1 Like

These are sometimes tricky and different bounds will give nicer or nastier posteriors. The issue with both the soft and the hard that you have coded are that there’s a difference if b1 > b2 or if b1 < b2. You need to assume or find out if b1 > b2 as the additional piece of information to pin this posterior down.

If I assume that b1 < b2 I can write the parameters block as

parameters {
  real b0;
  real b11;
  real b22;
  real b12;
  real b1;
  real<lower=b1, upper=max(b12 * (x2 - x1) + b11 * x1 - b22 * x2 + b1) > b2;
  real<lower=0> sigma;
}

You can then lower adapt_delta to 0.8 and forego the parameter inits. Everything samples fine.

2 Likes