plot.Bolstad: Plot method for objects of type Bolstad

Description Usage Arguments Details Author(s) Examples

View source: R/plot.Bolstad.r

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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

1
2
3
4
5
6
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 documentation built on Jan. 8, 2021, 2:03 a.m.