plotBayes: Function for exploring Bayesian inference for the sample mean...

Description Usage Arguments Value Examples

View source: R/plotBayes_function.R

Description

This function plots the prior, likelihood, and posterior distribution of the sample mean. It reports the MAP (maximum a posteriori) and EAP (expected a posteriori) estimates of the mean as well as the 95% credible interval around the MAP.

Usage

1
2
plotBayes(data, prior.type = "normal", prior.parameters, min, max,
  points = 1000, credible = 0.95)

Arguments

data

A vector of data

prior.type

The type of distribution for the prior. Can be "uniform" or "normal"

prior.parameters

A vector of length two providing the parameter values for the prior. When prior.type="normal", the values are the mean and sd. When prior.type="uniform", the values are the min and the max.

min

The minimum possible value of mu to consider.

max

The maximum possible value of mu to consider.

points

The number of values of mu to be calculated, higher means more precision. Defaults to 1000.

credible

The width of the credible interval specified as a number between zero and one. Defaults to 0.95 for a 95% credible interval.

Value

Returns a list with the following components:

Examples

1
2
3
4
5
set.seed(1)
data <- rnorm(n=10, mean=1, sd=1)
plotBayes(data, prior.type="normal", prior.parameters=c(0, .5), min=-2, max=2) 
plotBayes(data, prior.type="uniform", prior.parameters=c(.7, 1.5), min=-2, max=2)
plotBayes(data, prior.parameters=c(.7, 1.5), min=-2, max=2, credible=.9)

mcbeem/plotBayes documentation built on Nov. 19, 2019, 8:15 a.m.