# Translating/comparing brms parameter estimates to rstan estimates

**URL:** <https://discourse.mc-stan.org/t/translating-comparing-brms-parameter-estimates-to-rstan-estimates/14570>\
**Category:** brms\
**Tags:** rstan\
**Created:** [April 24, 2020, 3:18am UTC](https://discourse.mc-stan.org/t/translating-comparing-brms-parameter-estimates-to-rstan-estimates/14570 "2020-04-24T03:18:46Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![JLC](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jlc/32/12520_2.png) [@JLC](https://discourse.mc-stan.org/u/JLC)\
**Post date:** [April 24, 2020, 2:51pm UTC](https://discourse.mc-stan.org/t/translating-comparing-brms-parameter-estimates-to-rstan-estimates/14570/5 "2020-04-24T14:51:12Z")

</div>

I am see the relationship between the betas (all specified in the design matrix), but I can’t see where the r\_\* parameters in the BRMS model are coming from and those are the essential ones.

```
 BRMS_Mod[["exclude"]]
 [1] "ordered_Intercept" "fixed_Intercept" "theta"            
 [4] "chol_cor" "bQ" "hs_global"        
 [7] "hs_local" "hs_slab" "zb"               
[10] "hs_localsp" "zbsp" "Intercept"        
[13] "first_Intercept" "merged_Intercept" "zcar"             
[16] "nszcar" "zerr" "z_1"              
[19] "L_1" "Cor_1" "r_1"              
[22] "z_2" "L_2" "Cor_2"            
[25] "r_2"              
attr(,"save_ranef")
[1] TRUE
attr(,"save_mevars")
[1] FALSE
attr(,"save_all_pars")
[1] FALSE

```

`exclude` suggests all that r\_1, r\_2, z\_1, and z\_2 are excluded, but `tidybayes` returns the important variables prefixed by `r_`

```
get_variables(BRMS_Mod)
 [1] "b_Intercept"                                             
 [2] "b_ConditionIntervention"                                 
 [3] "b_Session_TypeInitial_Homecare"                          
 [4] "b_Session_TypeInitial_Debrief"                           
 [5] "b_Session_TypeFollowMup_Homecare"                        
 [6] "b_Session_TypeFollowMup_Debrief"                         
 [7] "b_FacilitatorFacilitator2"                               
 [8] "b_ConditionIntervention:Session_TypeInitial_Homecare"    
 [9] "b_ConditionIntervention:Session_TypeInitial_Debrief"     
[10] "b_ConditionIntervention:Session_TypeFollowMup_Homecare"  
[11] "b_ConditionIntervention:Session_TypeFollowMup_Debrief"   
[12] "b_Session_TypeInitial_Homecare:FacilitatorFacilitator2"  
[13] "b_Session_TypeInitial_Debrief:FacilitatorFacilitator2"   
[14] "b_Session_TypeFollowMup_Homecare:FacilitatorFacilitator2"
[15] "b_Session_TypeFollowMup_Debrief:FacilitatorFacilitator2" 
[16] "sd_Condition__Intercept"                                 
[17] "sd_Condition:Group__Intercept"                           
[18] "r_Condition[Control,Intercept]"                          
[19] "r_Condition[Intervention,Intercept]"                     
[20] "r_Condition:Group[Control_10,Intercept]"                 
[21] "r_Condition:Group[Control_12,Intercept]"                 
[22] "r_Condition:Group[Control_20,Intercept]"                 
[23] "r_Condition:Group[Control_36,Intercept]"                 
[24] "r_Condition:Group[Control_4,Intercept]"                  
[25] "r_Condition:Group[Control_40,Intercept]"                 
[26] "r_Condition:Group[Control_6,Intercept]"                  
[27] "r_Condition:Group[Control_8,Intercept]"                  
[28] "r_Condition:Group[Intervention_1,Intercept]"             
[29] "r_Condition:Group[Intervention_13,Intercept]"            
[30] "r_Condition:Group[Intervention_17,Intercept]"            
[31] "r_Condition:Group[Intervention_19,Intercept]"            
[32] "r_Condition:Group[Intervention_29,Intercept]"            
[33] "r_Condition:Group[Intervention_3,Intercept]"             
[34] "r_Condition:Group[Intervention_33,Intercept]"            
[35] "r_Condition:Group[Intervention_41,Intercept]"            
[36] "prior_Intercept"                                         
[37] "prior_b"                                                 
[38] "prior_sd_Condition__Intercept"                           
[39] "prior_sd_Condition:Group__Intercept"                     
[40] "lp__"                                                    
[41] "accept_stat__"                                           
[42] "stepsize__"                                              
[43] "treedepth__"                                             
[44] "n_leapfrog__"                                            
[45] "divergent__"                                             
[46] "energy__" 

```

I see the betas in the stan model variables, but the indexing looks quite different and that’s what I’m struggling with.

```
get_variables(Stan_Fit)
 [1] "b[1]" "b[2]" "b[3]"           
 [4] "b[4]" "b[5]" "b[6]"           
 [7] "b[7]" "b[8]" "b[9]"           
[10] "b[10]" "b[11]" "b[12]"          
[13] "b[13]" "b[14]" "Intercept"      
[16] "sd_1[1]" "z_1[1,1]" "z_1[1,2]"       
[19] "sd_2[1]" "z_2[1,1]" "z_2[1,2]"       
[22] "z_2[1,3]" "z_2[1,4]" "z_2[1,5]"       
[25] "z_2[1,6]" "z_2[1,7]" "z_2[1,8]"       
[28] "z_2[1,9]" "z_2[1,10]" "z_2[1,11]"      
[31] "z_2[1,12]" "z_2[1,13]" "z_2[1,14]"      
[34] "z_2[1,15]" "z_2[1,16]" "r_1_1[1]"       
[37] "r_1_1[2]" "r_2_1[1]" "r_2_1[2]"       
[40] "r_2_1[3]" "r_2_1[4]" "r_2_1[5]"       
[43] "r_2_1[6]" "r_2_1[7]" "r_2_1[8]"       
[46] "r_2_1[9]" "r_2_1[10]" "r_2_1[11]"      
[49] "r_2_1[12]" "r_2_1[13]" "r_2_1[14]"      
[52] "r_2_1[15]" "r_2_1[16]" "b_Intercept"    
[55] "prior_b" "prior_Intercept" "prior_sd_1_1"   
[58] "prior_sd_2_1" "lp __" "accept_stat__"  
[61] "stepsize __" "treedepth__" "n_leapfrog__"   
[64] "divergent __" "energy__"  

```

Is something behind the scenes in BRMS combining r\_1\_1 and r\_2\_1 parameters to create r\_\* variables indexed from r\_variable[r\_1\_1, r\_2\_1] ?

I realize this is like a basic/pedestrian series of questions, but I’m not sure where to look to get an understanding of the stan code.

---

_[View the full topic](https://discourse.mc-stan.org/t/translating-comparing-brms-parameter-estimates-to-rstan-estimates/14570)._
