How to specify variable parameter constraints based on other model parameters

Agreed. Might be easiest to do this manually with a for loop, transformed parameters, and manual Jacobian adjustment.

Something like (from pages 404-405 of the 2.17.0 manual):

parameters {
  real<lower=0> main_effect1[5];
  real<lower=0> main_effect2[5];
  real interaction_unconstrained[5];
}

// Transform from unconstrained to constrained space
transformed parameters {
  real interaction[5];
  for(i in 1:5) {
    interaction[i] = exp(interaction_unconstrained[i]) - min(main_effect1[i], main_effect2[i]);
  }
}

model {
  // Add in Jacobian adjustment
  for(i in 1:5) {
    target += interaction_unconstrained[i];
  }
  ...
}
5 Likes