plot.Bolstad {Bolstad} | R Documentation |
A unified plotting method for plotting the prior, likelihood and posterior from any of the analyses in the book
## 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,
...
)
x |
A S3 object of class Bolstad |
overlay |
if |
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 |
scaleLike |
If |
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 |
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
.
James Curran
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)