plot.Mix: 'plot' Method for 'Mix' Objects

Description Usage Arguments See Also Examples

View source: R/0_Mix_utils.R

Description

plot method for Mix objects visualizing the mixture density, with an option of showing the component densities.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## S3 method for class 'Mix'
plot(
  x,
  ylim,
  xlim = NULL,
  xout = NULL,
  n = 511,
  type = NULL,
  xlab = "x",
  ylab = "f(x)",
  main = attr(obj, "name"),
  lwd = 1.4,
  log = FALSE,
  components = TRUE,
  h0 = FALSE,
  parComp = list(col = NULL, lty = 3, lwd = 1),
  parH0 = list(col = NULL, lty = 3, lwd = 1),
  ...
)

Arguments

x

object of class Mix.

ylim

range of y values to use, if not specified (or containing NA), the function tries to construct reasonable default values.

xlim

range of x values to use, particularly important if xout is not specified. If not specified, the function tries to construct reasonable default values.

xout

numeric or NULL giving the abscissae at which to draw the density.

n

number of points to generate if xout is unspecified (for continuous distributions).

type

character denoting the type of plot, see e.g. lines. Defaults to "l" if the mixture distribution is continuous and to "h" if discrete.

xlab, ylab

labels for the x and y axis with defaults.

main

main title of plot, defaulting to the Mix object name.

lwd

line width for plotting, a positive number.

log

logical flag, if TRUE, probabilities/densities f are plotted as log(f). Only works if components is set to FALSE.

components

logical flag indicating whether the individual mixture components should be plotted, set to TRUE by default.

h0

logical flag indicating whether the line y = 0 should be drawn.

parComp

graphical parameters for drawing the individual components if components is set to TRUE.

parH0

graphical parameters for drawing the line y = 0 if h0 is set to TRUE.

...

further arguments passed to the function for plotting the mixture density.

See Also

Mix for the construction of Mix objects, dMix for the density/mass of a mixture.

Examples

1
2
3
4
5
6
7
8
# define 'Mix' object
normLocMix <- Mix("norm", discrete = FALSE, w = c(0.3, 0.4, 0.3), mean = c(10, 13, 17),
                  sd = c(1, 1, 1))
poisMix <- Mix("pois", discrete = TRUE, w = c(0.45, 0.45, 0.1), lambda = c(1, 5, 10))

# plot 'Mix' object
plot(normLocMix)
plot(poisMix)

mixComp documentation built on Feb. 25, 2021, 5:07 p.m.