paul-buerkner / brms

brms R package for Bayesian generalized multivariate non-linear multilevel models using Stan
https://paul-buerkner.github.io/brms/
GNU General Public License v2.0
1.28k stars 184 forks source link

Credible intervals for group varying intercepts #94

Closed fkgruber closed 8 years ago

fkgruber commented 8 years ago

Hi if I run something like: fit = brm(count ~ log_Age_c + log_Base4_c * Trt_c + (1 | patient) + (1 | visit) + (1 | obs), data=epilepsy, family="poisson")

the summary function only shows the sd estimates and CI of the group intercepts (say patient level). How can I get the CI of the actual intercept estimates? Like for example why you get when you run the same model in stan_glmer

thanks F

paul-buerkner commented 8 years ago

When you just want the estimates of the group intercepts, you can use the ranef method. In order to extract the CIs, you have to do a bit of manual work, for instance:

ps <- posterior_samples(fit, pars = "^r_patient")
t(apply(ps, 2, quantile, probs = c(0.025, 0.975)))
fkgruber commented 8 years ago

thanks!