Learn R Programming

LearnBayes (version 2.15.2)

Functions for Learning Bayesian Inference

Description

A collection of functions helpful in learning the basic tenets of Bayesian statistical inference. It contains functions for summarizing basic one and two parameter posterior distributions and predictive distributions. It contains MCMC algorithms for summarizing posterior distributions defined by the user. It also contains functions for regression models, hierarchical models, Bayesian tests, and illustrations of Gibbs sampling.

Copy Link

Version

Install

install.packages('LearnBayes')

Monthly Downloads

11,440

Version

2.15.2

License

GPL (>= 2)

Maintainer

Jim Albert

Last Published

January 31st, 2026

Functions in LearnBayes (2.15.2)

discint

Highest probability interval for a discrete distribution
discrete.bayes.2

Posterior distribution of two parameters with discrete priors
discrete.bayes

Posterior distribution with discrete priors
election

Florida election data
birthweight

Birthweight regression study
blinreg

Simulation from Bayesian linear regression model
cancermortality

Cancer mortality data
lbinorm

Logarithm of bivariate normal density
election.2008

Poll data from 2008 U.S. Presidential Election
careertraj.setup

Setup for Career Trajectory Application
hiergibbs

Gibbs sampling for a hierarchical regression model
dmnorm

The probability density function for the multivariate normal (Gaussian) probability distribution
donner

Donner survival study
dmt

Probability density function for multivariate t
histprior

Density function of a histogram distribution
logctablepost

Log posterior of difference and sum of logits in a 2x2 table
laplace

Summarization of a posterior density by the Laplace method
normal.normal.mix

Computes the posterior for normal sampling and a mixture of normals prior
mycontour

Contour plot of a bivariate density function
jeter2004

Hitting data for Derek Jeter
bradley.terry.post

Log posterior of a Bradley Terry random effects model
normnormexch

Log posterior of mean and log standard deviation for Normal/Normal exchangeable model
breastcancer

Survival experience of women with breast cancer under treatment
groupeddatapost

Log posterior of normal parameters when data is in grouped form
howardprior

Logarithm of Howard's dependent prior for two proportions
rdirichlet

Random draws from a Dirichlet distribution
calculus.grades

Calculus grades dataset
hearttransplants

Heart transplant mortality data
pbetat

Bayesian test of a proportion
logisticpost

Log posterior for a binary response model with a logistic link and a uniform prior
pbetap

Predictive distribution for a binomial sample with a beta prior
gibbs

Metropolis within Gibbs sampling algorithm of a posterior distribution
puffin

Bird measurements from British islands
footballscores

Game outcomes and point spreads for American football
logpoissgamma

Log posterior with Poisson sampling and gamma prior
marathontimes

Marathon running times
normpostpred

Posterior predictive simulation from Bayesian normal sampling model
reg.gprior.post

Computes the log posterior of a normal regression model with a g prior.
regroup

Collapses a matrix by summing over rows
mnormt.onesided

Bayesian test of one-sided hypothesis about a normal mean
poissgamexch

Log posterior of Poisson/gamma exchangeable model
logpoissnormal

Log posterior with Poisson sampling and normal prior
impsampling

Importance sampling using a t proposal density
poisson.gamma.mix

Computes the posterior for Poisson sampling and a mixture of gammas prior
blinregexpected

Simulates values of expected response for linear regression model
blinregpred

Simulates values of predicted response for linear regression model
mnormt.twosided

Bayesian test of a two-sided hypothesis about a normal mean
ordergibbs

Gibbs sampling for a hierarchical regression model
rmnorm

Random number generation for multivariate normal
normpostsim

Simulation from Bayesian normal sampling model
rmt

Random number generation for multivariate t
robustt

Gibbs sampling for a robust regression model
sluggerdata

Hitting statistics for ten great baseball players
rtruncated

Simulates from a truncated probability distribution
rejectsampling

Rejecting sampling using a t proposal density
rigamma

Random number generation for inverse gamma distribution
soccergoals

Goals scored by professional soccer team
strikeout

Baseball strikeout data
indepmetrop

Independence Metropolis independence chain of a posterior distribution
cauchyerrorpost

Log posterior of median and log scale parameters for Cauchy sampling
iowagpa

Admissions data for an university
stanfordheart

Data from Stanford Heart Transplanation Program
normal.select

Selection of Normal Prior Given Knowledge of Two Quantiles
chemotherapy

Chemotherapy treatment effects on ovarian cancer
normchi2post

Log posterior density for mean and variance for normal sampling
pdisc

Posterior distribution for a proportion with discrete priors
simcontour

Simulated draws from a bivariate density function on a grid
rwmetrop

Random walk Metropolis algorithm of a posterior distribution
schmidt

Batting data for Mike Schmidt
predplot

Plot of predictive distribution for binomial sampling with a beta prior
prior.two.parameters

Construct discrete uniform prior for two parameters
pdiscp

Predictive distribution for a binomial sample with a discrete prior
studentdata

Student dataset
weibullregpost

Log posterior of a Weibull proportional odds model for survival data
sir

Sampling importance resampling
triplot

Plot of prior, likelihood and posterior for a proportion
transplantpost

Log posterior of a Pareto model for survival data
bayes.influence

Observation sensitivity analysis in beta-binomial model
achievement

School achievement data
betabinexch

Log posterior of logit mean and log precision for Binomial/beta exchangeable model
betabinexch0

Log posterior of mean and precision for Binomial/beta exchangeable model
bfexch

Logarithm of integral of Bayes factor for testing homogeneity of proportions
beta.select

Selection of Beta Prior Given Knowledge of Two Quantiles
bayes.probit

Simulates from a probit binary response regression model using data augmentation and Gibbs sampling
bayes.model.selection

Bayesian regression model selection using G priors
bprobit.probs

Simulates fitted probabilities for a probit regression model
baseball.1964

Team records in the 1964 National League baseball season
bfindep

Bayes factor against independence assuming alternatives close to independence
bayesresiduals

Computation of posterior residual outlying probabilities for a linear regression model
bermuda.grass

Bermuda grass experiment data
ctable

Bayes factor against independence using uniform priors
birdextinct

Bird measurements from British islands
binomial.beta.mix

Computes the posterior for binomial sampling and a mixture of betas prior
darwin

Darwin's data on plants