2

我有一个零膨胀的 y 变量。

您能否确认我的解决方案将 brms 障碍对数正态后验值转换为有意义的估计值作为 y 变量单位(对数正态部分)或零概率(障碍部分)。

模型

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

后变量

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__" 

计算每个县的平均值的解决方案

我必须添加“b_Intercept”和“r_county[,Intercept]”,然后取 exp() 吗?在代码中:

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

计算每个县的零概率(y = 0)的解决方案

我必须添加“b_hu__Intercept”和“r_county__hu[,Intercept]”,并将其放入 inv_logit_scaled() 函数中?在代码中:

m %>%
  spread_draws(b_hu_Intercept, r_county__hu[county,]) %>%
  median_qi(condition_mean = inv_logit_scaled(b_hu_Intercept + r_county__hu))
4

0 回答 0