# Example of hierarchical model in Turing

**URL:** <https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554>\
**Category:** General Usage\
**Created:** [January 12, 2019, 10:35am UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554 "2019-01-12T10:35:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [January 12, 2019, 10:35am UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/1 "2019-01-12T10:35:34Z")

</div>

Hi all-

I have been looking for an example of a hierarchical model in Turing.jl but have not found one. I was wondering if anyone has an example or could show me how to implement a simple example, such as a [hierarchical binomial model](https://github.com/jhoupt/DBDA2Estan/blob/master/Ydich-XnomSsubj-MbinomBetaOmegaKappa.stan). Thanks.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 12, 2019, 3:06pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/2 "2019-01-12T15:06:12Z")

</div>

Hi Chris,

Have you looked at the [models](https://github.com/StanJulia/StatisticalRethinking.jl/tree/master/chapters/12) Richard Torkar did from StatisticalRethinking in chapter 12?

Best, Rob

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [January 12, 2019, 4:48pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/3 "2019-01-12T16:48:04Z")

</div>

Hi Rob-

Thanks for your response. It looks like the link is broken. Only chapters 1-5 are available. Is chapter 12 private?

Thanks

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [January 12, 2019, 7:54pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/4 "2019-01-12T19:54:14Z")

</div>

I’m not sure what happened. The material appears to have been recently made available. Thanks for the info. This is exactly what I was looking for and might be useful to other people using Turing. Do you think they should include a link to your repository?

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 12, 2019, 8:12pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/5 "2019-01-12T20:12:20Z")

</div>

Hi Chris,

Yes, Richard and I are still working hard to get this all ‘under control’. All chapter versions and notebook versions are generated via Literate.jl. For Turing that does not always work because of constraints on Travis, so I need to do those by hand and occasionally I forget that after an update.

In the scripts directory all (completed, up to chapter 13) models are available, typically at the moment as scripts/08/m8.1.jl, but in the future I’ll rename those to m8.1t.jl as I will add the Stan versions as m8.1s,jl.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [January 12, 2019, 9:29pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/6 "2019-01-12T21:29:13Z")

</div>

Excellent. Thanks again, Rob. These examples are really useful.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 12, 2019, 6:57pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/7 "2019-01-12T18:57:04Z")

</div>

Should be fixed now.

Rob J Goedman  
[goedman@icloud.com](mailto:goedman@icloud.com)

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [December 25, 2022, 8:59pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/8 "2022-12-25T20:59:14Z")

</div>

Is there an updated link? Seems to be broken. @goedman

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [December 25, 2022, 9:57pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/9 "2022-12-25T21:57:26Z")

</div>

[https://statisticalrethinkingjulia.github.io/TuringModels.jl/#models](https://statisticalrethinkingjulia.github.io/TuringModels.jl/#models)

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [December 26, 2022, 2:46pm UTC](https://discourse.julialang.org/t/example-of-hierarchical-model-in-turing/19554/10 "2022-12-26T14:46:51Z")

</div>

Another option is [here](https://github.com/Shmuma/rethinking-2ed-julia).

Edit: or [above repo using Pluto](https://github.com/StatisticalRethinkingJulia/SR2TuringPluto.jl).
