# Random Effects Model

**URL:** <https://discourse.mc-stan.org/t/random-effects-model/14571>\
**Category:** Modeling\
**Tags:** mixed-model, specification, fitting-issues\
**Created:** [April 24, 2020, 3:46am UTC](https://discourse.mc-stan.org/t/random-effects-model/14571 "2020-04-24T03:46:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [April 24, 2020, 1:40pm UTC](https://discourse.mc-stan.org/t/random-effects-model/14571/3 "2020-04-24T13:40:11Z")

</div>

Seeing as N is much bigger than the other count variables, you can probably get speed-ups from computing only the unique combinations then indexing into that to define theta (see [example here](https://discourse.mc-stan.org/t/case-study-preview-speeding-up-stan-by-reducing-redundant-computation/14228)), but before you get too worried about performance you should pin down why this model is not recovering the data-generating parameters first. The fact that it takes so long suggests to me that something is awry in the first place, as this isn’t a particularly complicated model nor large data. First add an intercept (and a prior on said intercept) and see how that fares. Then if you’re still not getting good recovery, post your data-generating code here too as possibly the model is recovering the data-generating parameters accurately but you’re not generating the data in the way you think you are.

---

_[View the full topic](https://discourse.mc-stan.org/t/random-effects-model/14571)._
