When running mclust on my test dataset, I get the following error:
Error in cdensEEV(data = data, logarithm = TRUE, parameters = parameters, : NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: In cdensEEV(data = data, logarithm = TRUE, parameters = parameters, : NAs introduced by coercion
My code is below:
library(ISLR)
attach(Auto)
library(mclust)
library(MASS)
library(class)
attach(Weekly)
Auto$mpg01 <- ifelse(Auto$mpg > median(Auto$mpg),1,0)
odd <- seq(from = 1, to = nrow(Auto), by = 2)
even <- seq(from = 2, to = nrow(Auto), by = 2)
X.train <- Auto[odd, -10]
Class.train <- Auto[odd, 10]
X.test <- Auto[even, -10]
Class.test <- Auto[even, 10]
AutoMclustDA <- MclustDA(X.train, Class.train)
summary(AutoMclustDA, parameters = TRUE)
summary(AutoMclustDA, newdata = X.test, newclass = Class.test)
When running the initial summary, everything works fine, but when I run the second summary, and specifically the newclass = Class.test portion, I get that error. I don't have any NA values in the dataset, and when I did it previously for the Weekly dataset, I had no issues.
Can anyone help? Thank you in advance.
Adam