plot_mm | R Documentation |
Generates a ggplot of data densities with overlaid mixture components from fit mixture models.
plot_mm(m, k = NULL, data = NULL)
m |
A mixture model object |
k |
Optional. The number of components specified in the mixture model, |
data |
Name of data object required only for |
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.
Wickham, H., 2016. ggplot2: elegant graphics for data analysis. Springer.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.