plot_mm {plotmm}R Documentation

Tidy Visualization of Mixture Models

Description

Generates a ggplot of data densities with overlaid mixture components from fit mixture models.

Usage

plot_mm(m, k = NULL, data = NULL)

Arguments

m

A mixture model object

k

Optional. The number of components specified in the mixture model, m

data

Name of data object required only for EMCluster objects

Details

This is the core function in the package, returning a ggplot object for a fit mixture model. The plot includes the data density with overlaid mixture components.

References

Wickham, H., 2016. ggplot2: elegant graphics for data analysis. Springer.

Examples


if(require(mixtools)){
mixmdl1 <- mixtools::normalmixEM(faithful$waiting, k = 2)
}
plot_mm(mixmdl1, 2)

if(require(mixtools)){
x <- c(rgamma(200, shape = 50, scale = 11), rgamma(200, shape = 28, scale = 6))
mixmdl2 <- mixtools::gammamixEM(x, lambda = c(1, 1)/2)
}
plot_mm(mixmdl2)



[Package plotmm version 0.1.1 Index]