MixEm产生太长的尾巴

时间:2016-07-12 16:36:12

标签: r ggplot2 statistics normal-distribution

我运行了以下在此帖子中找到的代码

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)

normalmixEM的结果显示很长的尾巴,见下图。 如何调整代码以便仅显示y高于某个概率的分布?我也想了解为什么normalmixEM会产生如此长的估计尾部?

enter image description here

0 个答案:

没有答案
相关问题