Learn R Programming

berryFunctions (version 1.11.0)

betaPlot: Beta density plot

Description

Quick and nice plot of beta density distribution based on just alpha and beta

Usage

betaPlot(shape1 = 1.5, shape2 = 5, lines = NA, fill = rgb(0, 0.3, 0.8, 0.4), cumulative = TRUE, mar = c(2, 3, 3, 3), keeppar = FALSE, las = 1, main = paste("Beta density with\nalpha =", signif(shape1, 3), "and beta =", signif(shape2, 3)), ylim = lim0(y), xlim = 0:1, ylab = "", xlab = "", type = "l", lty = 1, col = par("fg"), ...)

Arguments

shape1
Alpha value as in dbeta. DEFAULT: 1.5
shape2
Beta value. DEFAULT: 5
lines
Quantiles at which vertical lines should be plotted. DEFAULT: NA
fill
Color passed to polygon. DEFAULT: rgb(0,0.3,0.8, 0.4)
cumulative
Should cumulative density distribution be added? DEFAULT: TRUE
mar
Margins for plot passed to par. DEFAULT: c(2,3,3,3)
keeppar
Should margin parameters be kept instead of being restored to previous value? DEFAULT: FALSE
las
Label orientation, argument passed to plot. DEFAULT: 1
main
main as in plot. DEFAULT: paste("Beta density with\nalpha =", shape1, "and beta =", shape2)
ylim, xlim
limit for the y and x axis. DEFAULT: lim0(y), 0:1
ylab, xlab
labels for the axes. DEFAULT: ""
type, lty, col
arguments passed to plot and lines.
...
further arguments passed to plot like lwd, xaxs, cex.axis, etc.

Value

None. Used for plotting.

Details

This function very quickly plots a beta distribution by just specifying alpha and beta.

See Also

betaPlotComp, normPlot, dbeta, http://cran.r-project.org/package=denstrip, http://cran.r-project.org/web/views/Distributions.html

Examples

Run this code

betaPlot()
betaPlot(2,1) 
betaPlot(0.5, 2)

# beta distribution is often used for proportions or probabilities
# overview of parameters
# alpha = number of successes + 1.  beta = number of failures + 1
betaPlotComp()
# a bigger: HDI (Highest Density Interval) further to the right (1)
# b bigger: HDI more to the left (0)
# both bigger: narrower HDI, stronger peak

Run the code above in your browser using DataLab