can brms calculate Highest Probability Density Intervals ?

912 views
Skip to first unread message

Jannik Vindeløv

unread,
Jan 13, 2017, 6:10:28 AM1/13/17
to brms-users
When reading the documentation, I understand that the default credible intervals reported by brms are posterior quantiles, but is it possible to report higest density intervals instead?
Could this be a feature request, including whether to report mean, median, or mode as point estimates of the posterior?

Regards

Jannik

Paul Buerkner

unread,
Jan 13, 2017, 9:44:20 AM1/13/17
to brms-users
You can use the HPD interval implementation of the coda package via

coda::HPDinterval(as.mcmc(fit, combine_chains = TRUE))

With respect to the point estimates: Do you mean reporting them in the summary method? When using the fixef or ranef methods, for instance, you can compute the median instead of the mean.
Also, methods such as predict use the median when setting argument robust = TRUE.
The mode is a bit tricky since it depends on the amount of smoothing you do to the samples and I am not really sure if I want to feature the mode.

Jannik Vindeløv

unread,
Jan 13, 2017, 5:32:24 PM1/13/17
to brms-users
Thanks Paul for pointing this outl! The package is new to me, so I was not aware of these details. Mean and median cover my needs.
It appears easy to get the hpdi's for the posteriors of the parameters, but how would you go about it for fits and predictions?

Thanks you for creating such a nice package!

Paul Buerkner

unread,
Jan 13, 2017, 7:18:44 PM1/13/17
to brms-users
The following should do:

library(coda)
pr
<- as.mcmc(predict(fit, summary = FALSE))
HPDinterval(pr)

Generally, if you have a matrix with your parameters / predicted responses or similar as columns and posterior samples as rows, you can do coda::as.mcmc and then apply coda::HPDinterval.
Reply all
Reply to author
Forward
0 new messages