Metropolis rejection proposal due to incorrect numerical values for derived parameter

Hi,
I am a beginner to Stan and have an issue with fitting a simple beta binomial model.
Here is the warning message I get:-

“Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception:validate transform params : beta is -nan, but must be greater than on equal to zero. If this warning occurs often then your model is ill conditioned or mis-specified.”

Here is the pySTAN code:

code="""data {

 int<lower=2> J;          // number of coins

 int<lower=0> y[J];       // heads in respective coin trials

 int<lower=0> n[J];       // total in respective coin trials

}

parameters {

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

 real<lower = 0> kappa;

}

transformed parameters {

real<lower=0> alpha;

real<lower=0> beta;

alpha = kappa * mu;

beta = kappa - alpha;

}

model {

mu ~ uniform(0, 1);

kappa ~ exponential(0.05); // uniform(1,100);

y ~ beta_binomial(n, alpha, beta);

}
“”"
Thanks,
Meera

Do you get the warning more than once? Is it only during initialization/warmup or does it appear during sampling?

Hi Sakrejda

I get this message once during warm-up every time and never again during sampling.

This is common and not a problem, the algorithm explores a large range of values in the warm-up phase and often triggers numerical problems that go away. You might want to read the manual section on warm-up to understand this better. It should not affect sampling

1 Like

Thanks a lot for the quick response!