There were 6 divergences after tuning. Increase `target_accept` or reparameterize

with pm.Model() as model_5_7:
a = pm.Normal(‘a’, mu=10, sd=100)
bn = pm.Normal(‘bn’, mu=0, sd=1, shape=2)
sigma = pm.Uniform(‘sigma’, lower=0, upper=1)
mu = pm.Deterministic(‘mu’, a + bn[0] * dcc[‘neocortex.perc’] + bn[1] * dcc[‘log_mass’])
kcal = pm.Normal(‘kcal’, mu=mu, sd=sigma, observed=dcc[‘kcal.per.g’])
trace_5_7 = pm.sample(1000, tune=1000)

[Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [sigma, bn, a]
Sampling 2 chains: 100%|███████████████████████████████████████████████████████| 4000/4000 [00:20<00:00, 198.18draws/s]
There were 6 divergences after tuning. Increase target_accept or reparameterize.
There was 1 divergence after tuning. Increase target_accept or reparameterize.]

the result tell me " Increase target_accept or reparameterize.",what shold I do in my model? thank you !

Hi, you could use more informative priors. For example, reducing the sd in the normal distribution of a and using a HalfCauchy or HalfNormal instead of a uniform distribution for sigma.

Hope it helps!

Thanks for your advice, it’s divergence due to the bad priors? I am the newer to pymc , studying the text " Statistical-Rethinking"。 I try run the pymc code ,but some meet divergence warning。

I would say it is. You can also test if increasing the number of tuning steps helps (you are currently using 1000, you can increase to 3000 for instance).

1 Like

thank you!~

I had the same issue.
I fixed it with changing slope bn to HalfNormal and increasing sd

bn = pm.Normal(‘bn’, mu=0, sd=1, shape=2)

You can change sd to 10 first then if it still not working - move to HalfNormal