Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.Bolstad

Plot method for objects of type Bolstad


Description

A unified plotting method for plotting the prior, likelihood and posterior from any of the analyses in the book

Usage

## S3 method for class 'Bolstad'
plot(
  x,
  overlay = TRUE,
  which = c(1, 3),
  densCols = c("red", "green", "blue")[which],
  legendLoc = "topleft",
  scaleLike = FALSE,
  xlab = eval(expression(x$name)),
  ylab = "",
  main = "Shape of prior and posterior",
  ylim = c(0, max(cbind(x$prior, x$likelihood, x$posterior)[, which]) * 1.1),
  cex = 0.7,
  ...
)

Arguments

x

A S3 object of class Bolstad

overlay

if FALSE then up to three plots will be drawn side-by-side

which

Control which of the prior = 1, likelihood = 2, and posterior = 3, are plots. This is set to prior and posterior by default to retain compatibility with the book

densCols

The colors of the lines for each of the prior, likelihood and posterior

legendLoc

The location of the legend, usually either "topright" or "topleft"

scaleLike

If TRUE, then the likelihood will be scaled to have approximately the same maximum value as the posterior

xlab

Label for x axis

ylab

Label for y axis

main

Title of plot

ylim

Vector giving y coordinate range

cex

Character expansion multiplier

...

Any remaining arguments are fed to the plot command

Details

The function provides a unified way of plotting the prior, likelihood and posterior from any of the functions in the library that return these quantities. It will produce an overlay of the lines by default, or separate panels if overlay = FALSE.

Author(s)

James Curran

Examples

x = rnorm(20,-0.5,1)
## find the posterior density with a N(0,1) prior on mu
b = normnp(x,sigma=1)
plot(b)
plot(b, which = 1:3)
plot(b, overlay = FALSE, which = 1:3)

Bolstad

Functions for Elementary Bayesian Inference

v0.2-41
GPL (>= 2)
Authors
James Curran [aut, cre]
Initial release
2020-09-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.