cdfMclust: Cumulative Distribution and Quantiles for a univariate...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/densityMclust.R

Description

Compute the cumulative density function (cdf) or quantiles from an estimated one-dimensional Gaussian mixture fitted using densityMclust.

Usage

1
2
cdfMclust(object, data, ngrid = 100, ...)
quantileMclust(object, p, ...)

Arguments

object

a densityMclust model object.

data

a numeric vector of evaluation points.

ngrid

the number of points in a regular grid to be used as evaluation points if no data are provided.

p

a numeric vector of probabilities.

...

further arguments passed to or from other methods.

Details

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 interpolating splines on an adaptive finer grid.

Value

cdfMclust returns a list of x and y values providing, respectively, the evaluation points and the estimated cdf.

quantileMclust returns a vector of quantiles.

Author(s)

Luca Scrucca

See Also

densityMclust, plot.densityMclust.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
x <- c(rnorm(100), rnorm(100, 3, 2))
dens <- densityMclust(x)
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(dens.waiting)
plot(cdfMclust(dens.waiting), type = "l", 
     xlab = dens.waiting$varname, ylab = "CDF")
dens.eruptions <- densityMclust(faithful$eruptions)
plot(dens.eruptions)
plot(cdfMclust(dens.eruptions), type = "l", 
     xlab = dens.eruptions$varname, ylab = "CDF")
par(mfrow = c(1,1))

Example output

Package 'mclust' version 5.3
Type 'citation("mclust")' for citing this R package in publications.
-------------------------------------------------------
Density estimation via Gaussian finite mixture modeling 
-------------------------------------------------------

Mclust E (univariate, equal variance) model with 2 components:

 log.likelihood   n df       BIC       ICL
      -423.2397 200  4 -867.6726 -895.7996

Clustering table:
  1   2 
140  60 

Mixing probabilities:
       1        2 
0.685091 0.314909 

Means:
        1         2 
0.4079899 4.2651792 

Variances:
      1       2 
1.52995 1.52995 
List of 2
 $ x: num [1:100] -3.6 -3.48 -3.35 -3.22 -3.1 ...
 $ y: num [1:100] 0.000407 0.000579 0.000815 0.001137 0.001571 ...
       quantile  cdf
[1,] -2.2895514 0.01
[2,] -0.8956196 0.10
[3,]  1.1551263 0.50
[4,]  4.8533915 0.90
[5,]  6.5604061 0.99

mclust documentation built on Nov. 5, 2021, 5:07 p.m.