Tools for working with random draws from a distribution, eg draws from a posterior distribution in a Bayesian analysis.
Details
An rvec holds multiple draws, but wherever possible
behaves like an ordinary R vector. For instance, if x
is an rvec holding 1000 draws from a distribution,
then 2 * x returns a new rvec where each draw has
been multiplied by 2.
To summarise across draws, use a function starting with draws.
For instance, to calculate a credible interval, use draws_ci().
Functions
Creating rvecs
rvec()Class depends on inputrvec_dbl()Doublesrvec_int()Integersrvec_lgl()Logicalrvec_chr()Characternew_rvec_dbl()Empty doublesnew_rvec_int()Empty integersnew_rvec_lgl()Empty logicalnew_rvec_chr()Empty charactercollapse_to_rvec()Data in data frame
Manipulating rvecs
if_else_rvec()if_else()whereconditionis rvecmap_rvec()map()for rvecsextract_draw()Single draw from rvecpool_draws()Combine samples
Probability distributions
dbeta_rvec()Betadbinom_rvec()Binomialdcauchy_rvec()Cauchydchisq_rvec()Chi-squaredexp_rvec()Exponentialdgamma_rvec()Gammadgeom_rvec()Geometricdhyper_rvec()Hypergeometricdlnorm_rvec()Lognormaldmultinom()Multinomialdnbinom_rvec()Negative binomialdnorm_rvec()Normaldpois_rvec()Poissondt_rvec()Student's Tdunif_rvec()Uniformdweibull_rvec()Weibull
Summarizing across draws
draws_all()Alldraws_any()Anydraws_min()Minimumdraws_max()Maximumdraws_median()Mediandraws_mean()Meandraws_mode()Modaldraws_sd()Standard deviationdraws_var()Variancesdraws_cv()Coefficients of variationdraws_ci()Credible intervalsdraws_quantile()Quantilesdraws_fun()Arbitrary functionn_draw()Number
Coercion, classes
as_list_col()Rvec or matrix to listexpand_from_rvec()Inverse ofcollapse_to_rvec()is_rvec()Object an rvec?
Weighted summaries
weighted_mad()Weighted mean absolute deviationweighted_mean()Weighted meanweighted_median()Weighted medianweighted_sd()Weighted standard deviationweighted_var()Weighted variances
Datasets
divorce()Divorce ratesreg_post()Regression coefficients
Author
Maintainer: John Bryant john@bayesiandemography.com
Other contributors:
Bayesian Demography Limited [copyright holder]