Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compare.den

Compare several density estimates.


Description

Produces multiple density plots on a single axis, to compare the columns of a matrix or the elements of a list.

Usage

CompareDensities(x,
                 legend.text = NULL,
                 legend.location = "topright",
                 legend.title = NULL,
                 xlim = NULL,
                 ylim = NULL,
                 xlab = "parameter",
                 ylab = "density",
                 main = "",
                 lty = NULL,
                 col = "black",
                 axes = TRUE,
                 na.rm = TRUE,
                 ...)

Arguments

x

matrix or list of numeric vectors. A density plot is produced for each column of the matrix or element of the list.

legend.text

(optional) character vector giving names of each density plot.

legend.location

Entry that can be passed to legend.

legend.title

The legend title.

xlim

(optional) horizonal range of the plotting region. If omitted the region will be sized to fit all the observations in x.

ylim

(optional) vertical range of the plotting region. If omitted the region will be sized to fit all empirical density plots.

xlab

label to be placed on the horizontal axis

ylab

label to be placed on the vertical axis

main

main title for the plot

lty

The line types to use for the different densities. See par. If NULL then a different line type will be used for each density.

col

vector of colors for the densities to be plotted.

axes

Logical. Should axes and a box be drawn around the figure?

na.rm

Logical value indicating whether NA's should be removed.

...

Other graphical parameters passed to plot.density, and lines.

Value

Called for its side effect, which is to produce multiple density plots on the current graphics device.

Author(s)

Steven L. Scott

See Also

Examples

x <- t(matrix(rnorm(5000, 1:5, 1:5), nrow=5))
CompareDensities(x, legend.text=c("EJ", "TK", "JT", "OtherEJ", "TJ"),
                 col=rainbow(5), lwd=2)

Boom

Bayesian Object Oriented Modeling

v0.9.7
LGPL-2.1 | file LICENSE
Authors
Steven L. Scott is the sole author and creator of the BOOM project. Some code in the BOOM libraries has been modified from other open source projects. These include Cephes (obtained from Netlib, written by Stephen L. Moshier), NEWUOA (M.J.D Powell, obtained from Powell's web site), and a modified version of the R math libraries (R core development team). Original copyright notices have been maintained in all source files. In these cases, copyright claimed by Steven L. Scott is limited to modifications made to the original code. Google claims copyright for code written while Steven L. Scott was employed at Google from 2008 - 2018, but BOOM is not an officially supported Google project.
Initial release
2021-02-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.