# Sampling from multilevel multivariable regression model is very slow

**URL:** <https://discourse.pymc.io/t/sampling-from-multilevel-multivariable-regression-model-is-very-slow/5091>\
**Category:** Questions\
**Created:** [May 14, 2020, 9:09pm UTC](https://discourse.pymc.io/t/sampling-from-multilevel-multivariable-regression-model-is-very-slow/5091 "2020-05-14T21:09:24Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![mishooax](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@mishooax](https://discourse.pymc.io/u/mishooax)\
**Post date:** [May 18, 2020, 10:56am UTC](https://discourse.pymc.io/t/sampling-from-multilevel-multivariable-regression-model-is-very-slow/5091/10 "2020-05-18T10:56:29Z")

</div>

> [@junpenglao](#):
>
> So use non-centered parameterization instead, and also get rid of the for-loop:
> 
> ```auto
> # group slopes
> beta_base = pm.Normal('beta_base', 0., 1., shape=(n_predictors, n_groups))
> beta = pm.Deterministic('beta', mu + pm.math.dot(L_Omega, beta_base))
> 
> ```

@junpenglao Gotcha - thanks!! However, the sampling is still slow even with the vectorised + QR + non-centered param version. One chain with 2000 samples takes about 10 hrs to draw. I reckon this has to do with the complicated shape of the posterior - any ideas on how to speed this code up further? I’ve tried to increase the no. of cores when calling `pm.sample()` but then I run into [another issue](https://discourse.pymc.io/t/pm-sample-gets-stuck-after-init-with-cores-1/5017/16).

---

_[View the full topic](https://discourse.pymc.io/t/sampling-from-multilevel-multivariable-regression-model-is-very-slow/5091)._
