plot.mcmcOutput | R Documentation |
Plot the posterior probability distribution(s) for the nodes of a mmcmcOutput
object. postPlot
is equivalent to plot(mcmcOutput(object))
.
Note the new argument center
with options to display the mean, median or mode; this replaces the showMode
argument. The argument CRImass
replaces credMass
.
## S3 method for class 'mcmcOutput' plot(x, params, layout=c(3,3), center = c("mean", "median", "mode"), CRImass=0.95, compVal = NULL, ROPE = NULL, HDItextPlace = 0.7, showCurve = FALSE, shadeHDI = NULL, ...) postPlot(object, params, layout=c(3,3), center = c("mean", "median", "mode"), CRImass=0.95, compVal = NULL, ROPE = NULL, HDItextPlace = 0.7, showCurve = FALSE, shadeHDI = NULL, ...)
x |
An object of class |
object |
An object of any class that can be coerced to class |
params |
An optional vector of column numbers or names; names are partially matched, so |
layout |
a length-2 vector with the maximum number of rows and columns to display in the plotting frame. |
center |
the statistic to use to represent the central tendency. |
CRImass |
the probability mass to include in credible intervals; set this to NULL to suppress plotting of credible intervals. |
compVal |
a single value for comparison with those plotted; the same value will be used for all the plots. |
ROPE |
a two element vector, such as |
HDItextPlace |
a value in [0,1] that controls the horizontal position of the labels at the ends of the HDI bar. |
showCurve |
logical: if TRUE, the posterior density will be represented by a kernel density function instead of a histogram. |
shadeHDI |
specifies a colour to shade the area under the curve corresponding to the HDI; NULL for no shading. Ignored if |
... |
graphical parameters and the |
The data are plotted either as a histogram (above) or, if showCurve = TRUE
, as a fitted kernel density curve (below). The mean, median or mode of the distribution is displayed, depending on the parameter center
. The Highest Density Interval (HDI) is shown as a horizontal bar, with labels for the ends of the interval.
If a comparison value (compVal
) is supplied, this is shown as a vertical green dotted line, together with the probability mass below and above this value. If values for a ROPE are supplied, these are shown as dark red vertical dashed lines, together with the percentage of probability mass within the ROPE.
Returns nothing. Used for its plotting side-effect.
Mike Meredith, based on code by John Kruschke.
For details of the HDI calculation, see hdi
.
# Use the example data set data(mcmcListExample) mco <- mcmcOutput(mcmcListExample) plot(mco) plot(mco, "p") # plots p[1,1], p[2,2] and psi plot(mco, "p[") # plots p[1,1] and p[2,2], not psi # Generate some data normal <- rnorm(1e5, 2, 1) postPlot(normal) postPlot(normal, col='wheat', border='magenta') postPlot(normal, CRImass=0.8, compVal=0, ROPE=c(-0.2,0.2), xlab="Response variable") postPlot(normal, center="mode", showCurve=TRUE, compVal=5.5) # For integers: integers <- rpois(1e5, 12) postPlot(integers) # A severely bimodal distribution: bimodal <- c(rnorm(1e5), rnorm(5e4, 7)) postPlot(bimodal) # A valid 95% CrI, but not HDI postPlot(bimodal, showCurve=TRUE) # Correct 95% HDI postPlot(bimodal, showCurve=TRUE, shadeHDI='pink')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.