Description Usage Arguments Details Examples
View source: R/plot_mix_comps.R
Plots a mixture component conditioned on a superimposed function
1 | plot_mix_comps(x, mu, sigma, lam)
|
x |
Input data |
mu |
Mean of component |
sigma |
Variance of component |
lam |
Mixture weight of component |
Allows for specifying a custom function to be superimposed when plotting a mixture component
1 2 3 4 5 6 7 8 9 10 11 12 | set.seed(1)
mixmdl <- mixtools::normalmixEM(faithful$waiting, k = 2)
x <- mixmdl$x
x <- data.frame(x)
ggplot2::ggplot(data.frame(x)) +
ggplot2::geom_density(ggplot2::aes(x), color="black", fill="black") +
ggplot2::stat_function(geom = "line", fun = plot_mix_comps,
args = list(mixmdl$mu[1], mixmdl$sigma[1], lam = mixmdl$lambda[1]),
colour = "red") +
ggplot2::stat_function(geom = "line", fun = plot_mix_comps,
args = list(mixmdl$mu[2], mixmdl$sigma[2], lam = mixmdl$lambda[2]),
colour = "blue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.