1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
\name{cdfMclust}
\alias{cdfMclust}
\alias{quantileMclust}
\title{
Cumulative Distribution and Quantiles for a univariate Gaussian mixture
distribution
}
\description{
Compute the cumulative density function (cdf) or quantiles from an estimated one-dimensional Gaussian mixture fitted using \code{\link{densityMclust}}.}
\usage{
cdfMclust(object, data, ngrid = 100, \dots)
quantileMclust(object, p, \dots)
}
\arguments{
\item{object}{a \code{densityMclust} model object.}
\item{data}{a numeric vector of evaluation points.}
\item{ngrid}{the number of points in a regular grid to be used as evaluation points if no \code{data} are provided.}
\item{p}{a numeric vector of probabilities.}
\item{\dots}{further arguments passed to or from other methods.}
}
\details{The cdf is evaluated at points given by the optional argument \code{data}. If not provided, a regular grid of length \code{ngrid} for the evaluation points is used.
The quantiles are computed using bisection linear search algorithm.
}
\value{
\code{cdfMclust} returns a list of \code{x} and \code{y} values providing, respectively, the evaluation points and the estimated cdf.
\code{quantileMclust} returns a vector of quantiles.
}
\author{Luca Scrucca}
\seealso{
\code{\link{densityMclust}},
\code{\link{plot.densityMclust}}.
}
\examples{
\donttest{
x <- c(rnorm(100), rnorm(100, 3, 2))
dens <- densityMclust(x, plot = FALSE)
summary(dens, parameters = TRUE)
cdf <- cdfMclust(dens)
str(cdf)
q <- quantileMclust(dens, p = c(0.01, 0.1, 0.5, 0.9, 0.99))
cbind(quantile = q, cdf = cdfMclust(dens, q)$y)
plot(cdf, type = "l", xlab = "x", ylab = "CDF")
points(q, cdfMclust(dens, q)$y, pch = 20, col = "red3")
par(mfrow = c(2,2))
dens.waiting <- densityMclust(faithful$waiting)
plot(cdfMclust(dens.waiting), type = "l",
xlab = dens.waiting$varname, ylab = "CDF")
dens.eruptions <- densityMclust(faithful$eruptions)
plot(cdfMclust(dens.eruptions), type = "l",
xlab = dens.eruptions$varname, ylab = "CDF")
par(mfrow = c(1,1))
}
}
\keyword{cluster}
\keyword{dplot}
|