dens: Density plots

View source: R/plotting.r

densR Documentation

Density plots

Description

Convenient interface for plotting density estimates.

Usage

dens( x , adj=0.5 , norm.comp=FALSE , main="" , show.HPDI=FALSE , show.zero=FALSE , rm.na=TRUE , add=FALSE , ...)

Arguments

x

Vector of values to construct density from, or data frame. If x is a data frame, then dens plots a grid of densities, one for each column in x.

adj

width of density kernal.

norm.comp

If TRUE, overlays normal density comparison.

show.HPDI

If a numeric value, displays HPDI of same width. For example, show.HPDI=0.95 shows a 95 percent HPDI inside the density.

show.zero

If TRUE, draws a vertical line at location of zero on horizonal axis.

rm.na

If TRUE, removes NAs before computing density

add

If TRUE, overlays density on an existing plot

...

Other parameters to pass to density, which constructs the density estimates.

Details

This function merely provides a convenient interface for plotting density estimates produced by density. It handles both single vectors and multiple vectors, contained within a data frame.

Highest Posterior Density Intervals (HPDI) are calculated by HPDinterval in the coda package.

Author(s)

Richard McElreath

See Also

density, HPDinterval


rmcelreath/rethinking documentation built on Aug. 26, 2024, 5:54 p.m.