plot.scdensity: Plot method for class 'scdensity'.

View source: R/scdensity.R

plot.scdensityR Documentation

Plot method for class scdensity.

Description

Creates a plot of a shape-constrained kernel density estimate. The amount of information in the plot is controlled by detail.

Usage

## S3 method for class 'scdensity'
plot(
  x,
  detail = 4,
  main = c("Density Estimate", "Q-Q Plot"),
  xlab = c(x$data.name, "Constrained KDE Quantiles"),
  ylab = c("Density", "Sample Quantiles"),
  type = c("l", "l", "p"),
  lty = c(1, 2, 0),
  pch = c(-1, -1, 1),
  col = c("black", gray(0.4), "black"),
  lwd = c(2, 1, 0),
  zero.line = TRUE,
  ...
)

Arguments

x

An object of S3 class scdensity.

detail

An integer from 1 to 4, indicating the level of information to include in the plot. 1: plot only the constrained estimate. 2: draw both the constrained and unconstrained estimates on the same plot. 3: add a rug showing the data points. 4: additionally plot a Q-Q plot of the observed data versus the constrained estimate in a second panel (for qualitative assessment of goodness-of-fit).

main

A string passed on to the main argument of the plot command. If detail == 4, pass a vector of two strings to specify titles for both subfigures.

xlab

A string passed on to the xlab argument of the plot command. If detail == 4, pass a vector of two strings to specify x labels for both subfigures.

ylab

A string passed on to the ylab argument of the plot command. If detail == 4, pass a vector of two strings to specify y labels for both subfigures.

type

A vector of up to 3 strings specifying the type of plot used for 1) the constrained estimate, 2) the unconstrained estimate, and 3) the Q-Q plot.

lty

A vector of up to length 3, specifying the lty arguments passed to the plot commands for 1) the constrained estimate, 2) the unconstrained estimate, and 3) the Q-Q plot. See the description of lty in graphics::par().

pch

A vector of up to 3 integers specifying the pch argument passed to the plot commands for 1) the constrained estimate, 2) the unconstrained estimate, and 3) the Q-Q plot. See graphics::points() for the integer codes.

col

A vector of up to 3 strings specifying the col argument passed to the plot commands for 1) the constrained estimate, 2) the unconstrained estimate, and 3) the Q-Q plot.

lwd

A vector of up to length 3 specifying the lwd argument passed to the plot commands for 1) the constrained estimate, 2) the unconstrained estimate, and 3) the Q-Q plot.

zero.line

A logical value indicating whether or not a horizontal line should be drawn through zero to aid visualization.

...

Extra parameters passed to the initial plot command for each subfigure.

Examples

# Basic usage:
x <- rlnorm(30)
scKDE <- scdensity(x)
plot(scKDE)

# Show only the constrained estimate
plot(scKDE, detail=1)

# Show the constrained and unconstrained estimates.  Change line color and width.
plot(scKDE, detail=2, col=c("red","blue"), lwd=c(3,2))

# Show the Q-Q plot, but change that plot's symbol and its size.
plot(scKDE, detail=4, pch=c(-1, -1, 3), cex=0.5)

scdensity documentation built on Sept. 12, 2024, 7:35 a.m.