Brian Newquist wrote:
> I keep on receiving the message below after submitting the following line
> using the mclust package. m2 is a 99 X 1 column vector.
>
>
>
> * em(modelName = "E", m2, mu = c(25, 50), sigmasq=10, pro =
c(0.4,
> 0.6))
>
>
>
> Error in as.double.default(data) : (list) object cannot be coerced to
> double.
>
>
>
> Why do I receive this error?
>
Brian,
Are you sure m2 is a vector and not a data.frame or list? I can
replicate your error message as follows:
library(mclust)
# from ?em
data(iris)
irisMatrix <- as.matrix(iris[, 1:4])
irisClass <- iris[, 5]
msEst <- mstep(modelName = "EEE", data = irisMatrix,
z = unmap(irisClass))
iris.em1 <- em(modelName = msEst$modelName, data = irisMatrix,
mu = msEst$mu, Sigma = msEst$Sigma, pro = msEst$pro)
# not from ?em
iris.em2 <- em(modelName = msEst$modelName, data = iris[, 1:4],
mu = msEst$mu, Sigma = msEst$Sigma, pro = msEst$pro)
The second call to em produces:
Error in as.double.default(data) : (list) object cannot be coerced to double
That said, it shouldn't matter that `data' is a data.frame since the
help page says explicitly that data.frames are allowed as long as the
variables are not categorical. The first for columns of iris are `numeric'.
R-2.0.0Patched with MCLUST 2.1-6
--sundar