简体   繁体   English

尽管没有缺失值,但仍获得NA / NaN错误消息(使用R:tidyLPA)

[英]Getting NA/NaN error message despite having no missing values (using R: tidyLPA)

I'm using tidyLPA in R. I followed the example given here . 我在R中使用tidyLPA。我按照此处给出的示例进行操作。 The example code they give is the following: 他们给出的示例代码如下:

library(tidyLPA)
library(dplyr)
library(mclust)    
data(pisaUSA15)

pisaUSA15[1:100, ] %>%
  select(broad_interest, enjoyment, self_efficacy) %>%
  single_imputation() %>%
  estimate_profiles(3)

This runs fine and gives me the following results: 运行正常,并给我以下结果:

tidyLPA analysis using mclust: 

 Model Classes AIC     BIC     Entropy prob_min prob_max n_min n_max BLRT_p
 1     3       630.957 667.430 0.885   0.903    0.973    0.130 0.680 0.010

However, when I run it with my own data using the following code: 但是,当我使用以下代码使用自己的数据运行它时:

data[1:100, ] %>%
  select(V1, V2, V3, V4) %>%
  single_imputation() %>%
  estimate_profiles(3)

I get the following error message: 我收到以下错误消息:

Error in mdpwst[i]:mdpwfin[i] : NA/NaN argument

I'm confused as to why I'm getting an NA/NaN message when I deleted all observations with missing values with: 当我使用以下命令删除所有缺少值的观测值时,为什么会收到NA / NaN消息,我感到困惑:

data = data[complete.cases(data),]

This has never happened to me with any other package and sifting through similar questions here on stackoverflow provided no answers. 对于其他任何软件包,这从未发生过,并且在此处对stackoverflow上的类似问题进行筛选没有提供任何答案。 I'm not sure how to address this and just looking at the datasets show no immediately identifiable reasons as to why one dataset is working and one is not. 我不确定如何解决这个问题,仅查看数据集就无法立即确定为什么一个数据集有效而另一个数据集无效的原因。

I'm answering my own question here, The issue came from the single_imputation() %>% command. 我在这里回答我自己的问题,该问题来自single_imputation() %>%命令。 As stated here on Github , the command is used when there are missing values. Github上所述 ,当缺少值时使用该命令。 Since I removed all my missing values, the command is not needed and is actually causing an error! 由于我删除了所有缺少的值,因此该命令不是必需的,实际上会导致错误!

Once I removed it to have: 一旦我删除它有:

data[1:100, ] %>%
  select(V1, V2, V3, V4) %>%
  estimate_profiles(3)

The code ran fine! 代码运行良好!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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