# Phylogenetic varying slopes and intercepts model

**URL:** <https://discourse.mc-stan.org/t/phylogenetic-varying-slopes-and-intercepts-model/10916>\
**Category:** brms\
**Created:** [September 10, 2019, 2:07am UTC](https://discourse.mc-stan.org/t/phylogenetic-varying-slopes-and-intercepts-model/10916 "2019-09-10T02:07:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oscar\_Inostroza](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/oscar_inostroza/32/5842_2.png) [@Oscar\_Inostroza](https://discourse.mc-stan.org/u/Oscar_Inostroza)\
**Post date:** [September 10, 2019, 2:07am UTC](https://discourse.mc-stan.org/t/phylogenetic-varying-slopes-and-intercepts-model/10916/1 "2019-09-10T02:07:59Z")

</div>

I’m trying to fit a phylogenetic model to model the relationship between x and y. (eg. y~x +(1|species). However, species are grouped into major categories (families, orders, etc). What is the correct way to account for this hierarchical structure, while estimating slopes and random intercepts for one of those categories? For example, if I want the estimates of slopes and intercepts for each level of the family category:  
is  
a) y~x+(1|species)+(1+x|family),  
b) y~x+(1+x|species/family), or I have to add the family category as a fixed effect  
c) y~x+family(1+family|species)

Thank you very much in advance

Please also provide the following information in addition to your question:

- Operating System: Ubuntu 18.04
- brms Version:2.9.0

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [September 16, 2019, 7:27pm UTC](https://discourse.mc-stan.org/t/phylogenetic-varying-slopes-and-intercepts-model/10916/2 "2019-09-16T19:27:59Z")

</div>

Welcome to discourse and sorry for my late reply.

If you just want x to have a varying effect across family but not over species (which seems to be what you want), I would go for option (a).

---

<div class="post-metadata">

**Author:** ![Oscar\_Inostroza](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/oscar_inostroza/32/5842_2.png) [@Oscar\_Inostroza](https://discourse.mc-stan.org/u/Oscar_Inostroza)\
**Post date:** [October 1, 2019, 5:06pm UTC](https://discourse.mc-stan.org/t/phylogenetic-varying-slopes-and-intercepts-model/10916/3 "2019-10-01T17:06:54Z")

</div>

Sorry for delay!, Thank you very much for you help!
