A function for plotting of Mix objects. It is called
via the generic function plot
.
# S3 method for mix
plot(x, mixpar = NULL, dist = "norm", root = FALSE, ytop = NULL,
clwd = 1, main, sub, xlab, ylab, bty, BW = FALSE, …)
an object of class "mix"
, usually, the results
returned by the model fitting function mix
.
NULL
or a data frame containing the values for
parameters of component distributions, which are, in order, the
proportions, means, and standard deviations.
the distribution of components, it can be
"norm"
, "lnorm"
, "gamma"
, "weibull"
,
"binom"
, "nbinom"
and "pois"
.
if TRUE
, a hanging rootogram will be displayed.
a scalar which determines the top of the y-axis.
a positive number denoting line width, defaulting to 1
.
an overall title for the plot.
a subtitle for the plot.
a title for the x-axis.
a title for the y-axis.
A character string which determined the type of box which is
drawn about plots. If bty
is one of "o"
,
"l"
, "7"
, "c"
, "u"
, or "]"
the resulting box resembles the corresponding upper case letter.
A value of "n"
suppresses the box.
logical; if TRUE the plot will be drawn in black and white.
additional arguments to the function plot.default
.
If the argument x
gives an object of class
"mix"
, the plot will be a histogram for the grouped
data which come from the element mixdata
of x
.
Although the leftmost (first) and rightmost (mth) intervals are
always open-ended, on the histogram the first interval is shown
as being twice the width of the second interval and the mth is
shown as being twice the width of the m - 1st interval. When the
fitted distribution is one of "lnorm"
, "gamma"
and
"weibull"
, the left boundary of the first interval will be
taken zero since negative values and zeroes are not allowed for
these distribution. For the distributions "binom"
, "nbinom"
and "pois"
negative data are not permitted, so the left
boundary of the first interval is taken -0.5. The component
distributions weighted by their respect proportions and the
mixture distribution are computed by the estimated parameter
values from the element parameters
of x
, and
superimposed on the histogram. The distribution of components
will be taken the value of the element distribution
. If sub
,
xlab
, ylab
and bty
are not specified, the default
values will be used. The positions of the means are indicated with
triangles. When the argument root
is TRUE
, a hanging
rootogram will be displayed, that is, if only grouped data are
given, this option plots the histogram with the square root of
relative frequency on the y-axis. If there is a model as well as
data, not only is the y-axis the square root of relative frequency,
also the bars of the histogram, instead of rising from 0, are
shifted up or down so that the mid-point of the top of the bar
is exactly on the curve indicating the mixture distribution
and the bottom of the bar may therefore be above or below the
x-axis. If the bar goes below the x-axis, the portion below is
shown as a blue rectangle. If the bar does not reach the x-axis,
the space between the bottom of the bar and the x-axis is shown
as a blue rectangle. If the blue rectangles are almost above or
below in an area of the x-axis, we may say that the mixture
curve around that area is not fitting well.
mixparam
for organizing the parameter values, mix
for fitting mixture model, plot.mixdata
for plotting
Mixdata objects, plot.default
for additional arguments.
# NOT RUN {
data(pike65)
data(pikepar)
fit1 <- mix(pike65, pikepar, "lnorm",
constr = mixconstr(consigma = "CCV"), emsteps = 3)
plot(fit1)
plot(fit1, root = TRUE)
data(bindat)
data(binpar)
fit2 <- mix(bindat, binpar, "binom",
constr = mixconstr(consigma = "BINOM", size = c(20, 20, 20, 20)))
plot(fit2)
plot(fit2, root = TRUE)
# }
Run the code above in your browser using DataLab