简体   繁体   中英

R Error in if (nrow(emobj$Mu) != nclass || ncol(emobj$Mu) != p || nrow(emobj$LTSigma) != : missing value where TRUE/FALSE needed

I am getting the following error while using the EMCluster library in R:

Error in if (nrow(emobj$Mu) != nclass || ncol(emobj$Mu) != p || nrow(emobj$LTSigma) !=  : 
missing value where TRUE/FALSE needed

This is the code I wrote:

emcluster(iris[,-5], pi = NULL, Mu = NULL, LTSigma = NULL,
      lab = NULL, EMC = .EMC, assign.class = FALSE)

I am using the Iris dataset.

My goal is to run an EM clustering algorithm and describe my observations through plots, etc.

You need to provide the parameters, or you can initialize the EM and provide that:

library(EMCluster)

emobj <- simple.init(iris[,-5], nclass = 3)
mdl <- emcluster(iris[,-5], emobj = emobj, assign.class = TRUE)

table(mdl$class,iris$Species)
   
    setosa versicolor virginica
  1      0          0        15
  2      0         50        35
  3     50          0         0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM