Plot density of a 3D hyperdirichlet distribution

Description

Plot (log) density of a 3D hyperdirichlet distribution

Usage

1
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()

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.

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.

Author(s)

Robin K. S. Hankin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.