# There were 12 divergences after tuning. Increase \`target\_accept\` or reparameterize

**URL:** <https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945>\
**Category:** Questions\
**Created:** [August 26, 2021, 1:15am UTC](https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945 "2021-08-26T01:15:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanko](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/vanko/32/4509_2.png) [@vanko](https://discourse.pymc.io/u/vanko)\
**Post date:** [August 26, 2021, 1:15am UTC](https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945/1 "2021-08-26T01:15:38Z")

</div>

I hope someone can help me please.  
I’m fitting Bayesian Multiple Linear Regression with 7 features.  
Some of the features are very low correlated with target variable.

repo is here : [https://github.com/vanitoz/Bet-Awards/blob/main/EDA\_Modeling.ipynb](https://github.com/vanitoz/Bet-Awards/blob/main/EDA_Modeling.ipynb)

with pm.Model() as model\_mlr\_normal:  
# Intercept  
alpha = pm.Normal(‘alpha’, mu=0, sd=25)

```
# Slope
beta = pm.Normal('beta', mu=0, sd=25, shape= len(data.columns[:-1]))

# Error term
eps = pm.HalfCauchy('eps', 25)

# Expected value of outcome (MLR with vectors)
mu = alpha + pm.math.dot(x, beta)

# Likelihood
tune_in_i = pm.Normal('tune_in_i', mu= mu, sd= eps, observed= y)

# posterior/create the race
trace_normal = pm.sample(chains= 4)

```

I already tried to change mu,sd for Slope and Intercept with diff. variations. Also changed tune to 3000 and more and I still getting DIVERGENCES. is it bad thing to get divergences ???

100.00% [8000/8000 02:58\<00:00 Sampling 4 chains, 8 divergences]  
Sampling 4 chains for 1\_000 tune and 1\_000 draw iterations (4\_000 + 4\_000 draws total) took 226 seconds.  
There were 2 divergences after tuning. Increase `target_accept` or reparameterize.  
There were 4 divergences after tuning. Increase `target_accept` or reparameterize.  
There were 2 divergences after tuning. Increase `target_accept` or reparameterize.

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [August 26, 2021, 1:55am UTC](https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945/2 "2021-08-26T01:55:54Z")

</div>

Did you try increasing `target_accept`? If not, I would suggest doing so, like this:

```python
trace_normal = pm.sample(target_accept = 0.9)

```

If that doesn’t help, then you might reinspect the priors (the scales/“widths” in particular), but I haven’t looked at your data.

If you still have issues, then you may have to dig into the sampling process a bit. [This notebook](https://docs.pymc.io/pymc-examples/examples/diagnostics_and_criticism/Diagnosing_biased_Inference_with_Divergences.html) goes pretty deep, but I would definitely try

---

<div class="post-metadata">

**Author:** ![vanko](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/vanko/32/4509_2.png) [@vanko](https://discourse.pymc.io/u/vanko)\
**Post date:** [August 26, 2021, 2:26am UTC](https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945/3 "2021-08-26T02:26:04Z")

</div>

It works !!! Thank you for your help 😃  
trace\_normal = pm.sample(target\_accept = 0.9)

I saw it on forums before but didn’t pay attention that much.

Have another question if you familiar :  
I have 2 features that highly correlated (0.82 - corr). Does Multicollinearity effects the model and should I exclude one of the feature that highly corr? (This is what I remember from Regular Linear Regression but don’t know if it is the same with pyMC3)

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [August 26, 2021, 3:35am UTC](https://discourse.pymc.io/t/there-were-12-divergences-after-tuning-increase-target-accept-or-reparameterize/7945/4 "2021-08-26T03:35:11Z")

</div>

> [@vanko](#):
>
> Does Multicollinearity effects the model…

Multicollinearity will certainty effect the inference you make. However, unlike in frequentist settings, the sampling process will not blow up. Instead, the ambiguity inherent in estimating coefficients of collinear predictors will show up as dependence in the posterior. See [here](https://nbviewer.jupyter.org/github/cluhmann/DBDA-python/blob/master/Notebooks/Chapter%2018.ipynb#18.1.4---Redundant-predictors) for an example in which 1 predictor is entered into a model twice (e.g., yielding 2 maximally collinear predictors). Estimation goes just fine, but there’s lots of ambiguity about the values of these parameters (as there should be).
