1

I have run the following code that I have found on this post

Any suggestions for how I can plot mixEM type data using ggplot2

    wait2 <- normalmixEM(df$minutes,k=11,ECM=TRUE,maxit=10000)
    gg.mixEM <- function(EM) {
      require(ggplot2)
      x       <- with(EM,seq(min(x),max(x),len=1000))
      pars    <- with(EM,data.frame(comp=colnames(posterior), mu, sigma,lambda))
      em.df   <- data.frame(x=rep(x,each=nrow(pars)),pars)
      em.df$y <- with(em.df,lambda*dnorm(x,mean=mu,sd=sigma))
      ggplot(data.frame(x=EM$x),aes(x,y=..density..)) + 
      geom_histogram(fill=NA,color="black")+
      geom_polygon(data=em.df,aes(x,y,fill=comp),color="grey50", alpha=0.5)+
      scale_fill_discrete("Component\nMeans",labels=format(em.df$mu,digits=3))+
      theme_bw()
    }

gg.mixEM(wait2)

The results of the normalmixEM are showing very long tails, see picture below. How can I adjust the code in order to show only the distribution where y is above a certain probability? I also would like to understand why normalmixEM would produce such long estimated tails?

enter image description here

Community
  • 1
  • 1
user4797853
  • 71
  • 1
  • 9

0 Answers0