plot.densEstBayes: Plot the Bayesian density estimate from a 'densEstBayes()'...

View source: R/plot.densEstBayes.r

plot.densEstBayesR Documentation

Plot the Bayesian density estimate from a densEstBayes() fit

Description

The estimated density function obtained via densEstBayes is plotted.

Usage

## S3 method for class 'densEstBayes'
plot(x,plotIt=TRUE,credLev=0.95,gridSize=1001,varBand=TRUE,
                         shade=TRUE,estCol="darkgreen",varBandCol=NULL,
                         axisCol="slateblue",add=FALSE,lwd=2,xlab=NULL,ylab=NULL,...)

Arguments

x

A densEstBayes() fit object.

plotIt

Boolean flag:
TRUE = plot the density estimate and return nothing (the default)
FALSE = do not plot the density estimate and, instead, return a list containing an equally-spaced grid of abscissae values and three grids of ordinate values corresponding to the estimate and lower and uppwer limits of pointwise (100*credLev)% sets.

credLev

The number between 0 and 1 such that the credible interval band has (100*credLev)% approximate pointwise coverage. The default value is 0.95.

gridSize

The number of grid points used to display the density estimate curve and the pointwise credible interval band. The default value is 1001.

varBand

Boolean flag:
TRUE = add a pointwise approximate (100*credLev)% credible set variability band (the default)
FALSE = only plot the density estimate, without a variability band.

shade

Boolean flag:
TRUE = display the variability band using shading (the default)
FALSE = display the variability band using dashed curves.

estCol

Colour of the density estimate curve. The default value is "darkgreen".

varBandCol

Colour of the pointwise credible interval variability band. If shade=TRUE then the default value is "palegreen". If shade=FALSE then the default value is estCol.

axisCol

colour of the horizontal axis. The default value is "slateblue".

add

Boolean flag:
TRUE = add the density estimate curve(s) to an existing plot
FALSE = create a new plot for display of the density estimate (the default).

lwd

A positive integer indicating the line width of plotted curves. The default value is 2.

xlab

A character string spedifying the horizontal axis label.

ylab

A character string specifying the vertical axis label.

...

Place-holder for other graphical parameters.

Value

If plotIt=TRUE then a plot is produced on the current device and no numerical values are returned. If plotIt=FALSE then a list is returned with the following components:

xg

numerical vector of abscissae values

densEstg

numerical vector of ordinate values corresponding to the density estimate

densLowg

numerical vector of ordinate values corresponding to the lower limits of the pointwise approximate (100*credLev)% credible set variability band

densUppg

numerical vector of ordinate values corresponding to the upper limits of the pointwise approximate (100*credLev)% credible set variability band

Author(s)

Matt P. Wand matt.wand@uts.edu.au

Examples

library(densEstBayes) ; data(OldFaithful2011)

# Obtain a density estimate for the `OldFaithful2011' data:

dest <- densEstBayes(OldFaithful2011,method = "SMFVB")

# Plot the density estimate using default settings:

plot(dest,xlab = "time interval between geyser eruptions (minutes)")
rug(jitter(OldFaithful2011,amount=0.2),col = "dodgerblue")

# Plot the density estimate with some user-specified settings:

plot(dest,credLev = 0.999,estCol = "purple",
     varBandCol = "pink",axisCol = "navy",
     xlab = "time interval between geyser eruptions (minutes)")
rug(jitter(OldFaithful2011,amount= 0.2),col = "darkkhaki")

# Plot the density estimate as a black and white line plot:

plot(dest,estCol = "black",shade = FALSE,axisCol = "black",
     xlab = "time interval between geyser eruptions (minutes)")
rug(jitter(OldFaithful2011,amount = 0.2))

densEstBayes documentation built on March 31, 2023, 11:52 p.m.