3

I have a zero-inflated y-variable.

Could you please confirm that my solutions for converting brms hurdle lognormal posterior values into meaningful estimates as y-variable units (lognormal part) or zero probabilities (hurdle part).

Model

model = brm(br(y ~ (1 | county), hu ~ (1 | county), data = data, family = hurdle_lognormal())

Posterior variables

get_variables(model)

 [1] "b_Intercept"                  
 [2] "b_hu_Intercept"               
 [3] "sd_county__Intercept"         
 [4] "sd_county__hu_Intercept"      
 [5] "sigma"     
                   
 [6] "r_county[A,Intercept]"     
 [7] "r_county[B,Intercept]"    
 [8] "r_county[C,Intercept]"    
 [9] "r_county[D,Intercept]"  
   
[10] "r_county__hu[A,Intercept]"  
[11] "r_county__hu[B,Intercept]"  
[12] "r_county__hu[C,Intercept]"  
[13] "r_county__hu[D,Intercept]" 

[14] "lp__"                         
[15] "accept_stat__"                
[16] "stepsize__"                   
[17] "treedepth__"                  
[18] "n_leapfrog__"                 
[19] "divergent__"                  
[20] "energy__" 

Solution for calculating mean y value for each county

I have to add "b_Intercept" and "r_county[ ,Intercept]", and take exp() of that? In code:

model %>%
  spread_draws(b_Intercept, r_county[county,]) %>%
  median_qi(condition_mean = exp(b_Intercept + r_county))

Solution for calculating zero probability (y = 0) for each county

I have to add "b_hu__Intercept" and "r_county__hu[ ,Intercept]", and put it into inv_logit_scaled() function? In code:

m %>%
  spread_draws(b_hu_Intercept, r_county__hu[county,]) %>%
  median_qi(condition_mean = inv_logit_scaled(b_hu_Intercept + r_county__hu))
st4co4
  • 445
  • 3
  • 10

0 Answers0