plotComb: Display a posterior probability distribution from the comb...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Plot the posterior probability distribution for a single parameter calculaed using the comb method described by Krushke (2015).

Usage

1
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-negligable probability. (To restrict the range dispayed in the plot, use xlim.)

y

A vector of probabilities corresponding to the values in x.

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. Usecolours() to see a list of possible colours.

...

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.

plotPost2.jpg

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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')


Search within the wiqid package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.