Divergences in a simple uniform distribution

Hi everyone, some guidance on the following problem would be appreciated.
When trying to sample from a model like the one below (which seems innocent to me), I get some divergences that lead to very bad estimates.

parameters {
    real a;
    real b;

transformed parameters {
    real shifted_a;
    shifted_a = 100 + 80 * a;

model {
    a ~ uniform(0, 1);
    b ~ normal(shifted_a, 7);

The problem goes away when I put explicit constraints when declaring a:

real<lower=0, upper=1> a;

So that’s great news. But I’m not sure why this is happening. I imagine it has something to do with the transformations stan does under the hood in order to sample on an unconstrained space, but that’s as far as I can get.

Can someone give a few suggestions on what to read to understand the issue?

Many thanks!



1 Like

Super helpful, thank you Michael!

1 Like