lines.Distribution: Superimpose Distribution Functions Plots for a distr6 Object

View source: R/lines.R

lines.DistributionR Documentation

Superimpose Distribution Functions Plots for a distr6 Object

Description

One of six plots can be selected to be superimposed in the plotting window, including: pdf, cdf, quantile, survival, hazard and cumulative hazard.

Usage

## S3 method for class 'Distribution'
lines(x, fun, npoints = 3000, ...)

Arguments

x

distr6 object.

fun

vector of functions to plot, one or more of: "pdf","cdf","quantile", "survival", "hazard", and "cumhazard"; partial matching available.

npoints

number of evaluation points.

...

graphical parameters.

Details

Unlike the plot.Distribution function, no internal checks are performed to ensure that the added plot makes sense in the context of the current plotting window. Therefore this function assumes that the current plot is of the same value support, see examples.

Author(s)

Chengyang Gao, Runlong Yu and Shuhan Liu

See Also

plot.Distribution for plotting a distr6 object.

Examples

plot(Normal$new(mean = 2), "pdf")
lines(Normal$new(mean = 3), "pdf", col = "red", lwd = 2)

## Not run: 
# The code below gives examples of how not to use this function.
# Different value supports
plot(Binomial$new(), "cdf")
lines(Normal$new(), "cdf")

# Different functions
plot(Binomial$new(), "pdf")
lines(Binomial$new(), "cdf")

# Too many functions
plot(Binomial$new(), c("pdf", "cdf"))
lines(Binomial$new(), "cdf")

## End(Not run)


distr6 documentation built on March 28, 2022, 1:05 a.m.