我在R中使用MICE包时出现问题,特别是汇集了推算数据集。
我正在运行多级二项式逻辑回归,其中Level1 - 主题(参与者对不同主题的10个问题的响应,例如Darkness,Day)嵌套在Level2 - 个体中。
使用R2MLwiN创建模型,公式为
> fit1 <-runMLwiN( c(probit(T_Darkness, cons), probit(T_Day, cons), probit(T_Light, cons), probit(T_Night, cons), probit(T_Rain, cons), probit(T_Rainbows, cons), probit(T_Snow, cons), probit(T_Storms, cons), probit(T_Waterfalls, cons), probit(T_Waves, cons)) ~ 1, D=c("Mixed", "Binomial", "Binomial","Binomial","Binomial", "Binomial", "Binomial", "Binomial", "Binomial", "Binomial" ,"Binomial"), estoptions = list(EstM = 0), data=data)
不幸的是,所有Level1(主题)响应中都缺少数据。
我一直在使用mice
包([CRAN] [1])来乘以错误的值。
我可以使用公式> fitMI <- (with(MI.Data, runMLwiN( c(probit(T_Darkness, cons), probit(T_Day, cons), probit(T_Light, cons), probit(T_Night, cons), probit(T_Rain, cons), probit(T_Rainbows, cons), probit(T_Snow, cons), probit(T_Storms, cons), probit(T_Waterfalls, cons), probit(T_Waves, cons)) ~ 1, D=c("Mixed", "Binomial", "Binomial","Binomial","Binomial", "Binomial", "Binomial", "Binomial", "Binomial", "Binomial" ,"Binomial"), estoptions = list(EstM = 0), data=data)))
但是,当我使用调用代码> pool(fitMI)
汇总分析时,它会失败,并显示错误:
Error in pool(with(tempData, runMLwiN(c(probit(T_Darkness, cons), probit(T_Day, :
Object has no coef() method.
我不确定为什么它说没有系数,因为对各个MI数据集的分析提供了固定部分(系数)和随机部分(协方差)
对于出现问题的任何帮助都将非常感激。
我应该警告你,这是我第一次尝试使用R和多级建模。 另外我知道有一个MlwiN软件包([REALCOM] [2])可以做到这一点,但我没有使用MLwiN软件的背景。
感谢 约翰尼
更新 - R可重复的示例
使用的库
库(R2MLwiN)
库(小鼠)
数据子集 `
T_Darkness&lt; - c(0,1,0,0,0,0,0,1,0,0,NA,0,0,0,NA,1,0,NA,NA,1,0 ,0,0,1,0,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,0,1,1,0,0,0,0,0,NA,0,0,0)
T_Storms&lt; - c(0,0,0,1,1,1,0,1,0,1,NA,0,0,0,0,1,0,NA,0,0,1 ,0,0,NA,1,1,NA,0,0,NA,0,1,0,NA,1,0,1,0,0,0,0,0,0,0,0,0 ,1,0,0,0,1,0,NA,1,0,NA,0,0,0,1,1,0,1,NA,NA,1)
T_Waterfalls&lt; - c(0,0,0,0,0,0,0,NA,0,0,0,0,0,0,0,NA,0,0,0,0,1 ,0,0,0,0,0,0,0,NA,0,0,0,0,0,1,0,0,0,1,0,0,NA,0,0,0 ,0,0,NA,0,1,0,NA,1,0,1,0,0,0,NA,0,0,0,NA,NA,0)
T_Waves&lt; - c(0,1,0,1,1,0,1,NA,0,0,NA,0,0,0,NA,1,0,0,0,0,1 ,0,NA,0,NA,0,0,NA,0,0,0,0,0,NA,1,0,0,0,0,0,0,NA,0,1,0 ,0,0,0,0,1,1,NA,1,1,NA,0,0,0,NA,0,0,0,NA,0,0)
数据&lt; - data.frame(T_Darkness,T_Day,T_Light,T_Night,T_Rain,T_Rainbows,T_Snow,T_Storms,T_Waterfalls,T_Waves)
数据$ cons&lt; - 1
`
使用
鼠标估算数据MI.Data&lt; - mice(data,m = 5,maxit = 50,meth ='pmm',seed = 500)
答案 0 :(得分:0)
这似乎是由于R2MLwiN中的某些模型提取方法未正确找到,应该已在最近发布的0.8-2版本的软件包中修复。用这个运行你的例子给我以下结果:
> pool(fitMI)
Call: pool(object = fitMI)
Pooled coefficients:
FP_Intercept_T_Darkness FP_Intercept_T_Day FP_Intercept_T_Light FP_Intercept_T_Night FP_Intercept_T_Rain
-0.9687210917 -1.0720602274 -0.9584792256 -1.1816471815 -0.7082406878
FP_Intercept_T_Rainbows FP_Intercept_T_Snow FP_Intercept_T_Storms FP_Intercept_T_Waterfalls FP_Intercept_T_Waves
-0.0455361903 -0.7537600398 -0.3883027434 -1.2365225554 -0.6423609257
RP1_var_bcons_1 RP1_cov_bcons_1_bcons_2 RP1_var_bcons_2 RP1_cov_bcons_1_bcons_3 RP1_cov_bcons_2_bcons_3
1.0000000000 0.0508168936 1.0000000000 0.2744663656 0.1625871509
RP1_var_bcons_3 RP1_cov_bcons_1_bcons_4 RP1_cov_bcons_2_bcons_4 RP1_cov_bcons_3_bcons_4 RP1_var_bcons_4
1.0000000000 0.0013987361 0.0576194786 0.0201622359 1.0000000000
RP1_cov_bcons_1_bcons_5 RP1_cov_bcons_2_bcons_5 RP1_cov_bcons_3_bcons_5 RP1_cov_bcons_4_bcons_5 RP1_var_bcons_5
-0.0220604800 0.1620389074 0.0956511647 -0.0242812764 1.0000000000
RP1_cov_bcons_1_bcons_6 RP1_cov_bcons_2_bcons_6 RP1_cov_bcons_3_bcons_6 RP1_cov_bcons_4_bcons_6 RP1_cov_bcons_5_bcons_6
0.2644620836 0.0555731133 0.1911445856 0.2584619522 0.1523280591
RP1_var_bcons_6 RP1_cov_bcons_1_bcons_7 RP1_cov_bcons_2_bcons_7 RP1_cov_bcons_3_bcons_7 RP1_cov_bcons_4_bcons_7
1.0000000000 0.1877118051 0.0872156173 0.2800109982 0.1433261335
RP1_cov_bcons_5_bcons_7 RP1_cov_bcons_6_bcons_7 RP1_var_bcons_7 RP1_cov_bcons_1_bcons_8 RP1_cov_bcons_2_bcons_8
-0.0006230903 0.1582182944 1.0000000000 -0.0749104023 0.1435756236
RP1_cov_bcons_3_bcons_8 RP1_cov_bcons_4_bcons_8 RP1_cov_bcons_5_bcons_8 RP1_cov_bcons_6_bcons_8 RP1_cov_bcons_7_bcons_8
0.0537744537 0.2291038185 0.2553031743 0.2716509402 0.1914017051
RP1_var_bcons_8 RP1_cov_bcons_1_bcons_9 RP1_cov_bcons_2_bcons_9 RP1_cov_bcons_3_bcons_9 RP1_cov_bcons_4_bcons_9
1.0000000000 0.1936145425 0.2835071683 0.0144172618 0.3326070011
RP1_cov_bcons_5_bcons_9 RP1_cov_bcons_6_bcons_9 RP1_cov_bcons_7_bcons_9 RP1_cov_bcons_8_bcons_9 RP1_var_bcons_9
0.1372590512 0.2854030728 0.0750594735 0.2545967996 1.0000000000
RP1_cov_bcons_1_bcons_10 RP1_cov_bcons_2_bcons_10 RP1_cov_bcons_3_bcons_10 RP1_cov_bcons_4_bcons_10 RP1_cov_bcons_5_bcons_10
0.3137466609 0.3498021364 0.2846792042 0.1126367375 0.2416045219
RP1_cov_bcons_6_bcons_10 RP1_cov_bcons_7_bcons_10 RP1_cov_bcons_8_bcons_10 RP1_cov_bcons_9_bcons_10 RP1_var_bcons_10
0.2137401104 0.1849118918 0.2134640366 0.6101759672 1.0000000000
Fraction of information about the coefficients missing due to nonresponse:
FP_Intercept_T_Darkness FP_Intercept_T_Day FP_Intercept_T_Light FP_Intercept_T_Night FP_Intercept_T_Rain
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
FP_Intercept_T_Rainbows FP_Intercept_T_Snow FP_Intercept_T_Storms FP_Intercept_T_Waterfalls FP_Intercept_T_Waves
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_var_bcons_1 RP1_cov_bcons_1_bcons_2 RP1_var_bcons_2 RP1_cov_bcons_1_bcons_3 RP1_cov_bcons_2_bcons_3
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_var_bcons_3 RP1_cov_bcons_1_bcons_4 RP1_cov_bcons_2_bcons_4 RP1_cov_bcons_3_bcons_4 RP1_var_bcons_4
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_1_bcons_5 RP1_cov_bcons_2_bcons_5 RP1_cov_bcons_3_bcons_5 RP1_cov_bcons_4_bcons_5 RP1_var_bcons_5
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_1_bcons_6 RP1_cov_bcons_2_bcons_6 RP1_cov_bcons_3_bcons_6 RP1_cov_bcons_4_bcons_6 RP1_cov_bcons_5_bcons_6
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_var_bcons_6 RP1_cov_bcons_1_bcons_7 RP1_cov_bcons_2_bcons_7 RP1_cov_bcons_3_bcons_7 RP1_cov_bcons_4_bcons_7
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_5_bcons_7 RP1_cov_bcons_6_bcons_7 RP1_var_bcons_7 RP1_cov_bcons_1_bcons_8 RP1_cov_bcons_2_bcons_8
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_3_bcons_8 RP1_cov_bcons_4_bcons_8 RP1_cov_bcons_5_bcons_8 RP1_cov_bcons_6_bcons_8 RP1_cov_bcons_7_bcons_8
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_var_bcons_8 RP1_cov_bcons_1_bcons_9 RP1_cov_bcons_2_bcons_9 RP1_cov_bcons_3_bcons_9 RP1_cov_bcons_4_bcons_9
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_5_bcons_9 RP1_cov_bcons_6_bcons_9 RP1_cov_bcons_7_bcons_9 RP1_cov_bcons_8_bcons_9 RP1_var_bcons_9
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_1_bcons_10 RP1_cov_bcons_2_bcons_10 RP1_cov_bcons_3_bcons_10 RP1_cov_bcons_4_bcons_10 RP1_cov_bcons_5_bcons_10
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367
RP1_cov_bcons_6_bcons_10 RP1_cov_bcons_7_bcons_10 RP1_cov_bcons_8_bcons_10 RP1_cov_bcons_9_bcons_10 RP1_var_bcons_10
0.5714367 0.5714367 0.5714367 0.5714367 0.5714367