hyperdirichlet (version 1.5-1)

triplot: Plot density of a 3D hyperdirichlet distribution

Description

Plot (log) density of a 3D hyperdirichlet distribution

Usage

triplot(HD, l = 100, do_image=TRUE, do_contour=TRUE, discard = 0.05, labels=NULL, ...)

Arguments

HD
Either a function of a three-element vector, or a hyperdirichlet object
l
Size of plot; larger values look much better but take longer
do_image,do_contour
Boolean, indicating whether to plot the image and contour respectively
discard
Numeric; default 0.05 means to disregard densities less than the fifth percentile (i.e. quantile 0.05). This makes the contour plot intervals prettier
labels
Length three character vector for corner labels with default NULL meaning to use pnames(HD)
Further arguments passed to image() and contour()

Value

The function returns (invisibly) an l-by-l matrix holding the support as a function of the two independent variables, with NA outside the domain.

Details

If argument HD is not a function it is interpreted as a hyperdirichlet object. If HD is a function, triplot() will pass it a three-element vector.

If argument HD is a hyperdirichlet object, then triplot() plots contours of the log of the density (ie support). If you want likelihood instead, see examples section for how to do this.

Labels will be printed at the appropriate corners; use par(xpd=TRUE) to suppress clipping.

Examples

Run this code

a <- dirichlet(1:3)
triplot(a,l=20)

old.par <- par(no.readonly=TRUE);par(xpd=TRUE)   # (needed for labels)


pnames(a) <- letters[1:3]
triplot(a,l=33)

f <- function(p){1-p[1]+p[2]+8*p[2]^2*p[3]}
triplot(f,labels=LETTERS[1:3])

g <- function(p){dhyperdirichlet(p, a, log=FALSE)}
triplot(g,l=20)



par(old.par)

Run the code above in your browser using DataCamp Workspace