R(小鼠)runMI-本征错误(VarCov,对称= TRUE,仅.values = TRUE):'x'中的值无限或缺失

时间:2018-10-18 14:23:55

标签: r r-mice r-lavaan

当我使用semTools中的 sem 函数使用缺少值的数据集运行模型时,一切工作正常。当我使用mouses包来估算缺失值时,估算工作可以得到5个没有缺失数据的数据集。

使用的sem函数如下所示:

sem_full <- sem(model=full_model, data=my_data, ordered=c("r01","r02","r03","r04","r05","r06","r07","r08","r09","r10","r11","r12","r13","r14","r17","r15","r16","r19","r20","r21","r22","r23","r24","q01","q02","q03","q04","q05","q09","q11","q13","q15","q22","q23","q24","q17","q18","q20","q10","q12","q14","q19","q21","q25","q26","q27"))

,并且模型是这样指定的:

 full_model <- '
 first_one =~ NA*r01 + r02 + r03 + r04 + r05 + r06 + r07 + + r08 + r09 + r10 + r11 + r12 + r13 + r14 + r17
 first_two =~ NA*r13 + r14 + r15 + r16 + r19 + r20 + r21 + r22 + r23 + r24
 f1 =~ NA*q01 + q02 + q03 + q04 + q05
 f2 =~ NA*q09 + q11 + q13 + q15
 f3 =~ NA*q22 + q23 + q24
 f4 =~ NA*q17 + q18 + q20
 f5 =~ NA*q10 + q12 + q14
 f6 =~ NA*q19 + q21
 f7 =~ NA*q25 + q26 + q27
 first_one + first_two ~ f1
 first_one + first_two ~ f2
 first_one + first_two ~ f3
 first_one + first_two ~ f4
 first_one + first_two ~ f5
 first_one + first_two ~ f6
 first_one + first_two ~ f7
 first_one + first_two ~ sex
 first_one + first_two ~ age
 first_one + first_two ~ freq
 first_one + first_two ~ sat
 f1 ~~ 1*f1
 f2 ~~ 1*f2
 f3 ~~ 1*f3
 f4 ~~ 1*f4
 f5 ~~ 1*f5
 f6 ~~ 1*f6
 f7 ~~ 1*f7
 first_one ~~ 1*first_one
 first_two ~~ 1*first_two'

现在使用

sem_mice <- runMI(full_model, data=mice_sem.imp,fun="sem", ordered=c("r01","r02","r03","r04","r05","r06","r07","r08","r09","r10","r11","r12","r13","r14","r17","r15","r16","r19","r20","r21","r22","r23","r24","q01","q02","q03","q04","q05","q09","q11","q13","q15","q22","q23","q24","q17","q18","q20","q10","q12","q14","q19","q21","q25","q26","q27"), meanstructure = TRUE)

要获得所有估算数据集的结果,我会收到一条错误消息:

特征值错误(VarCov,对称= TRUE,仅值= TRUE):   'x'中的无穷或缺失值

我在做什么错?在所有估算数据集中都没有缺失值,当我在每个估算数据集上分别运行sem函数时,它可以正常工作(但是我没有得到合并结果)。

除性别(数字)和年龄(数字)外,所有变量均为整数类型。 除性别,年龄和频率外,其他所有内容均包含有序值1 2 3 4。

似乎性别预测变量(编码为虚拟0、1)引起了一些问题。但是我不明白为什么它在计算单个模型而不是通过runMI函数合并模型时可以很好地工作。

0 个答案:

没有答案