View source: R/densityMclustBounded.R
cdfDensityBounded | R Documentation |
Compute the cumulative density function (cdf) or quantiles of a one-dimensional density for bounded data estimated via transformation-based approach for Gaussian mixtures using densityMclustBounded
.
cdfDensityBounded(object, data, ngrid = 100, ...) quantileDensityBounded(object, p, ...)
object |
a |
data |
a numeric vector of evaluation points. |
ngrid |
the number of points in a regular grid to be used as evaluation points if no |
p |
a numeric vector of probabilities. |
... |
further arguments passed to or from other methods. |
The cdf is evaluated at points given by the optional argument data
. If not provided, a regular grid of length ngrid
for the evaluation points is used.
The quantiles are computed using bisection linear search algorithm.
cdfDensityBounded
returns a list of x
and y
values providing, respectively, the evaluation points and the estimated cdf.
quantileDensityBounded
returns a vector of quantiles.
Luca Scrucca
densityMclustBounded
,
plot.densityMclustBounded
.
# univariate case with lower bound x <- rchisq(200, 3) dens <- densityMclustBounded(x, lbound = 0) xgrid <- seq(-2, max(x), length=1000) cdf <- cdfDensityBounded(dens, xgrid) str(cdf) plot(xgrid, pchisq(xgrid, df = 3), type = "l", xlab = "x", ylab = "CDF") lines(cdf, col = 4, lwd = 2) q <- quantileDensityBounded(dens, p = c(0.01, 0.1, 0.5, 0.9, 0.99)) cbind(quantile = q, cdf = cdfDensityBounded(dens, q)$y) plot(cdf, type = "l", col = 4, xlab = "x", ylab = "CDF") points(q, cdfDensityBounded(dens, q)$y, pch = 19, col = 4) # univariate case with lower & upper bounds x <- rbeta(200, 5, 1.5) dens <- densityMclustBounded(x, lbound = 0, ubound = 1) xgrid <- seq(-0.1, 1.1, length=1000) cdf <- cdfDensityBounded(dens, xgrid) str(cdf) plot(xgrid, pbeta(xgrid, 5, 1.5), type = "l", xlab = "x", ylab = "CDF") lines(cdf, col = 4, lwd = 2) q <- quantileDensityBounded(dens, p = c(0.01, 0.1, 0.5, 0.9, 0.99)) cbind(quantile = q, cdf = cdfDensityBounded(dens, q)$y) plot(cdf, type = "l", col = 4, xlab = "x", ylab = "CDF") points(q, cdfDensityBounded(dens, q)$y, pch = 19, col = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.