Bad initial energy and no clue for debugging a non-finite log-probability


I am running a model that you can find here:

It originates from genomics and I will be more than willing to explain the details of it, but I am not sure it is necessary at first.

As stated in the title, I encounter the Bad initial energy error. I read quite a bunch of threads here, like this one:

I started to follow the guidelines and I discovered a non-finite log-probability for Y_obs:

In [112]: Basic_model.check_test_point()                                                                              
alpha_interval__    -20.79
beta_interval__     -20.79
gamma_interval__    -20.79
delta_interval__    -20.79
eta_interval__      -27.73
sigma              -303.25
Y_obs                 -inf
Name: Log-probability of test_point, dtype: float64

The problem is that I don’t know what to do next. I checked that Y_obs is positive:

In [113]: Y_obs.tag.test_value[Y_obs.tag.test_value==0.]                                                              
Out[113]: array([], dtype=float64)

but then I am left with no idea as to why this is happening.

Any help would be much appreciated.

I got it to run with no errors or warnings using

sigma = pm.Normal('sigma', mu = mu_flat, sd = 1.)
Y_obs = pm.Normal('Y_obs', mu = sigma, sd = sigma, observed = measures_flat)
trace = pm.sample(1000, init='adapt_diag')

I’m pretty new to pymc3, and I’m not entirely sure what you’re trying to do, but it looks to me like your parameter priors aren’t linked to anything - should they be?

I think the problem is here: Variances can not be negative, try with a HalfNormal prior.

1 Like

Thanks a lot @twiecki! I tried with a HalfNormal prior and it ran fine (and very quickly). I have to investigate the results to see if they make sense. I’ll report here.