HPD {BayesTwin} | R Documentation |
This function calculates the Bayesian highest posterior density interval (HPD) based on a parameters' posterior sample.
HPD(sample, cred_int = 0.95)
sample |
A vector representing draws from the target distribution of the paramter of interest, as produced by the main function |
cred_int |
The desired accuracy of the HPD. Default value is 0.95 for 95%. |
The highest posterior density interval (HPD, see e.g. Box & Tia, 1992) contains the required mass such that all points within the interval have a higher probability density than points outside of the interval.
The function expects as input a vector representing draws from the target distribution of the paramter of interest, such as produced by the main function IRT_twin
of this package.
The result is a vector consisiting of two values, the first value representing the lower bound of the HPD and the second value representing the upper bound.
A vector of length 2 with the lower (first value) and upper (second value) bound of the HPD.
Inga Schwabe
Box, G., & Tiao, G. (1992). Bayesian inference in statistical analysis. New York: John Wiley & Sons.
data(results)
#Obtain the 95% HPD for additive genetic variance
HPD(results$samples_var_a)
#Obtain the 90% HPD for all item difficulty parameters
apply(results$samples_item_b, 1, function (x) HPD(x, 0.90))