plot_post: Plot posterior samples

Description Usage Arguments Examples

Description

This function mimics plotPost() from Kruschke's Doing Bayesian Data Analysis and provides a highly customized plot of a vector of posterior samples for a parameter. The options to save the plot to a file have been removed since there are other general purpose ways of doing this, and it isn't needed if you are working in R Markdown, which is recommended for reporting.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
plotPost(
  samples,
  center = c("mode", "median", "mean"),
  cenTend = center,
  comparison_value = NULL,
  compVal = comparison_value,
  ROPE = NULL,
  hdi_prob = 0.95,
  credMass = hdi_prob,
  hdi_text_place = 0.7,
  HDItextPlace = hdi_text_place,
  quietly = FALSE,
  xlab = "Param. Val.",
  xlim = NULL,
  yaxt = "n",
  ylab = "",
  main = "",
  cex = 1.4,
  cex.lab = 1.5,
  col = "skyblue",
  border = "white",
  showCurve = FALSE,
  breaks = NULL,
  ...
)

plot_post(
  samples,
  center = c("mode", "median", "mean"),
  cenTend = center,
  comparison_value = NULL,
  compVal = comparison_value,
  ROPE = NULL,
  hdi_prob = 0.95,
  credMass = hdi_prob,
  hdi_text_place = 0.7,
  HDItextPlace = hdi_text_place,
  quietly = FALSE,
  xlab = "Param. Val.",
  xlim = NULL,
  yaxt = "n",
  ylab = "",
  main = "",
  cex = 1.4,
  cex.lab = 1.5,
  col = "skyblue",
  border = "white",
  showCurve = FALSE,
  breaks = NULL,
  ...
)

Arguments

samples

a vector of (posterior) sampled values

cenTend

measure of central tendency to use. One of "mode", "median" or "mean".

comparison_value,

compVal number for "comparison value"

ROPE

a vector of length 2 giving the ends of the region of practical equivalence

hdi_prob, credMass

probability for HDI interval

hdi_text_place, HDItextPlace

location of HDI text on plot.

quietly

if TRUE, return summary invisibly.

xlab, xlim, yaxt, ylab, main, cex, cex.lab, col, border, showCurve, breaks

arguments for graphics::hist()

...

additional arguments passed along to graphics::hist()

Examples

1
2
3
4
5
samples <- rnorm(2000)    # fake a posterior sample
plot_post(samples)
plot_post(samples, hdi_prob = 0.90)
plot_post(samples, hdi_prob = 0.90, ROPE = c(-0.2, 0.2), comparison_value = 2)
plot_post(samples, hdi_prob = 0.90, ROPE = c(-0.2, 0.2), compVal = 2)

rpruim/CalvinBayes documentation built on April 12, 2021, 1:49 p.m.