plotComb {wiqid} | R Documentation |
Display a posterior probability distribution from the comb method
Description
Plot the posterior probability distribution for a single parameter calculated using the comb method described by Kruschke (2015).
Usage
plotComb(x, y, credMass = 0.95, plot = TRUE, showMode = FALSE, shadeHDI = NULL, ...)
Arguments
x |
A vector of equally-spaced possible values for the parameter. The range should cover all values of the parameter with non-negligible probability. (To restrict the range displayed in the plot, use |
y |
A vector of probabilities corresponding to the values in |
credMass |
the probability mass to include in credible intervals; set to NULL to suppress plotting of credible intervals. |
plot |
logical: if TRUE, the posterior is plotted. |
showMode |
logical: if TRUE, the mode is displayed instead of the mean. |
shadeHDI |
specifies a colour to shade the area under the curve corresponding to the HDI; NULL for no shading. Use |
... |
additional graphical parameters. |
Details
The function calculates the Highest Density Interval (HDI). A multi-modal distribution may have a disjoint HDI, in which case the ends of each segment are calculated. No interpolation is done, and the end points correspond to values of the parameter in x
; precision will be determined by the resolution of x
.
If plot = TRUE
, the probability density is plotted together with either the mean or the mode and the HDI.
Value
Returns a matrix with the upper and lower limits of the HDI. If the HDI is disjoint, this matrix will have more than 1 row. It has attributes credMass
and height
, giving the height of the probability curve corresponding to the ends of the HDI.
Author(s)
Mike Meredith
See Also
For details of the HDI calculation, see hdi
.
Examples
# Generate some data:
N <- 0:100
post <- dpois(N, 25)
# Do the plots:
plotComb(N, post)
plotComb(N, post, showMode=TRUE, shadeHDI='pink', xlim=c(10, 50))
# A bimodal distribution:
post2 <- (dnorm(N, 28, 8) + dnorm(N, 70, 11)) / 2
plotComb(N, post2, credMass=0.99, shade='pink')
plotComb(N, post2, credMass=0.80, shade='grey')