Shreyas Chaturvedi
Shreyas Chaturvedi

Reputation: 15

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.

Upvotes: 1

Views: 61

Answers (1)

StupidWolf
StupidWolf

Reputation: 46888

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

Upvotes: 0

Related Questions