使用R(MICE)合并多级逻辑模型的乘积虚拟数据集的问题-缺失系数

霍尔斯

我在R中的MICE程序包时遇到了问题,特别是在合并估算的数据集时。

我正在运行多级二项式逻辑回归,将Level1-主题(参与者对10个关于不同主题的问题的回答,例如,黑暗,白天)嵌套在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_Dar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,1,0,1,1,0,0,0,0,0,NA,0,0,0)

T_Storms <-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,1,0,0,1,0 ,0,0,1,0,NA,1,0,NA,0,0,0,1,1,1,0,1,NA,NA,1)

T_Waterfalls <-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,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 <-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,0,NA,1,0,0,0,1,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)

数据<-data.frame(T_Darkness,T_Day,T_Light,T_Night,T_Rain,T_Rainbows,T_Snow,T_Storms,T_Waterfalls,T_Waves)

data $ cons <-1

`

使用鼠标推算的数据

MI.Data <-鼠标(数据,m = 5,maxit = 50,meth ='pmm',种子= 500)

克里斯

这似乎是由于未正确找到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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档