r - Graphical output of density for the function gammamixEM (package mixtools) -


i'm using function gammamixem package mixtools. how can return graphical output of density in function normalmixem (i.e., second plot in plot(...,which=2)) ?

update:

here reproducible example function gammamixem:

x <- c(rgamma(200, shape = 0.2, scale = 14), rgamma(200,       shape = 32, scale = 10), rgamma(200, shape = 5, scale = 6)) out <- gammamixem(x, lambda = c(1, 1, 1)/3, verb = true) 

here reproducible example for function normalmixem:

data(faithful) attach(faithful) out <- normalmixem(waiting, arbvar = false, epsilon = 1e-03) plot(out, which=2) 

enter image description here

i obtain graphical output of density function gammamixem.

here go.

out <- normalmixem(waiting, arbvar = false, epsilon = 1e-03)  x          <- out  whichplots <- 2 density = 2 %in% whichplots loglik  = 1 %in% whichplots  def.par    <- par(ask=(loglik + density > 1), "mar") # ask , mar changed mix.object <- x   k    <- ncol(mix.object$posterior) x    <- sort(mix.object$x)    <- hist(x, plot = false) maxy <- max(max(a$density), .3989*mix.object$lambda/mix.object$sigma) 

i had dig source code of plot.mixem

so, gammamixem:

x <- c(rgamma(200, shape = 0.2, scale = 14), rgamma(200,                                                      shape = 32, scale = 10), rgamma(200, shape = 5, scale = 6)) gammamixem.out <- gammamixem(x, lambda = c(1, 1, 1)/3, verb = true)    mix.object <- gammamixem.out  k    <- ncol(mix.object$posterior) x    <- sort(mix.object$x)    <- hist(x, plot = false) maxy <- max(max(a$density), .3989*mix.object$lambda/mix.object$sigma)  main2 <- "density curves" xlab2 <- "data"  col2  <- 2:(k+1)   hist(x, prob = true, main = main2, xlab = xlab2,       ylim = c(0,maxy))   (i in 1:k) {   lines(x, mix.object$lambda[i] *            dnorm(x,                  sd = sd(x))) } 

enter image description here

i believe should pretty straight forward continue example bit, if want add labels, smooth lines, etc. here's source of plot.mixem function.


Comments

Popular posts from this blog

PHP while loop dynamic rowspan -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

Spring Boot + JPA + Hibernate: Unable to locate persister -