R:四舍五入时 MclustICL 函数错误

R: MclustICL function error when rounding

当运行 mclustICL (R package mclust 5.3) on data发生错误:

data <- c(-0.485152666666667, -0.457841666666667, -0.457841666666667, 
-0.457841666666667, -0.457841666666667, -0.457841666666667, -0.457841666666667, 
-0.457841666666667) 
> mclustICL(data, modelNames = "V")
fitting ...
  |=======================================================================================================| 100%
Error in if (sum((out$parameters$pro - colMeans(out$z))^2) > sqrt(.Machine$double.eps)) { : 
  missing value where TRUE/FALSE needed

四舍五入解决:

> mclustICL(round(data,5), modelNames = "V") # no error

但我需要在其他数据示例上使用函数 mclustICL,然后四舍五入不仅没有帮助,而且该函数仅在我不使用四舍五入时才起作用并抛出相同的错误当我这样做时:

data <- c(-0.241992333333333, -0.287035333333333, -0.33378, -0.272269333333333, 
-0.241992333333333, -0.287035333333333, -0.241992333333333, -0.241992333333333, 
-0.241992333333333, -0.287311, -0.287311, -0.287035333333333)

> mclustICL(data, modelNames = "V")# no error

> mclustICL(round(data,5), modelNames = "V")fitting ...
  |=======================================================================================================| 100%
Error in if (sum((out$parameters$pro - colMeans(out$z))^2) > sqrt(.Machine$double.eps)) { : 
  missing value where TRUE/FALSE needed

我应该如何对这两个数据使用该函数以及为什么会出现这种情况?提前致谢!

我没有遇到你的问题,正如你在下面的代码中看到的那样。
你有最新版本的包吗?
你看过你的数据了吗?
你能猜出为什么只能拟合单一混合物成分吗?

> library(mclust)
    __  ___________    __  _____________
   /  |/  / ____/ /   / / / / ___/_  __/
  / /|_/ / /   / /   / / / /\__ \ / /   
 / /  / / /___/ /___/ /_/ /___/ // /    
/_/  /_/\____/_____/\____//____//_/    version 5.3
Type 'citation("mclust")' for citing this R package in publications.

> data <- c(-0.485152666666667, -0.457841666666667, -0.457841666666667, 
+ -0.457841666666667, -0.457841666666667, -0.457841666666667, -0.457841666666667, 
+ -0.457841666666667)
> summary(data)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.4852 -0.4578 -0.4578 -0.4613 -0.4578 -0.4578 
> dotchart(data)

> mclustBIC(data, modelNames = "V")

Bayesian Information Criterion (BIC):
         V
1 48.44934
2       NA
3       NA
4       NA
5       NA
6       NA
7       NA
8       NA

Top 3 models based on the BIC criterion:
     V,1                   
48.44934       NA       NA 

> mclustICL(data, modelNames = "V")

Integrated Complete-data Likelihood (ICL) criterion:
         V
1 48.44934
2       NA
3       NA
4       NA
5       NA
6       NA
7       NA
8       NA

Top 3 models based on the ICL criterion:
     V,1                   
48.44934       NA       NA 

> data <- c(-0.241992333333333, -0.287035333333333, -0.33378, -0.272269333333333, 
+ -0.241992333333333, -0.287035333333333, -0.241992333333333, -0.241992333333333, 
+ -0.241992333333333, -0.287311, -0.287311, -0.287035333333333)
> summary(data)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.3338 -0.2871 -0.2797 -0.2710 -0.2420 -0.2420 
> dotchart(data)

> mclustBIC(data, modelNames = "V")

Bayesian Information Criterion (BIC):
         V
1 46.73079
2       NA
3       NA
4       NA
5       NA
6       NA
7       NA
8       NA
9       NA

Top 3 models based on the BIC criterion:
     V,1                   
46.73079       NA       NA 

> mclustICL(data, modelNames = "V")

Integrated Complete-data Likelihood (ICL) criterion:
         V
1 46.73079
2       NA
3       NA
4       NA
5       NA
6       NA
7       NA
8       NA
9       NA

Top 3 models based on the ICL criterion:
     V,1                   
46.73079       NA       NA 

> mclustICL(round(data,5), modelNames = "V")
Integrated Complete-data Likelihood (ICL) criterion:
         V
1 46.72944
2       NA
3       NA
4       NA
5       NA
6       NA
7       NA
8       NA
9       NA

Top 3 models based on the ICL criterion:
     V,1                   
46.72944       NA       NA 

升级到 R 3.4.1. 解决了这个问题。非常感谢 Luca Scrucca!