使用 R (MICE) 轮询多级逻辑模型的乘法估算数据集的问题 - 缺失系数

Problems with pooling Multiply Imuputed datasets, of multilevel logistic models, using R (MICE) - missing coefficent

我在使用 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 可重现示例

使用的库

library(R2MLwiN)

library(mice)

数据子集 `

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

T_Day <- c(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, NA, NA, 0)

T_Light <- c(0, 0, NA, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, NA, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0)

T_Night <- c(0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,NA, 0, NA, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, NA, 0, 0)

T_Rain <- c(1, 0, 0, 1, 1, 0, 0, NA, 0, 1, 0, 0, 1, 0, 0, 0, 0, NA, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, NA, 0, 0, 0, 0, 1, 0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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 <- 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 <- mice(data,m=5,maxit=50,meth='pmm',seed=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