尝试合并多个填充值时出现的错误消息

huangapple go评论64阅读模式
英文:

Error message when trying to pool multiple imputations

问题

我已经在R中完成了关于小鼠的多重插补(MI)并按照在RDocumentation上找到的步骤进行了结果汇总。我认为我理解了为什么我已经完成了线性回归,现在我正在尝试汇总结果,但我一直收到一个错误消息,上面写着:

No tidy method for objects of class qr

我已经尝试安装了tidyverse、broom和broom.mixed,但这些都没有消除错误消息...

我在想,是否在插补后计算总分使我的工作变得更加困难,但这是我用于线性回归的必需品...

这是我的代码,以防有什么非常明显的地方我忽略了...

# 插补数据
imp <- mice(df_2, m = 5, seed = 2023)

df_imp <- complete(imp, "long", include = FALSE)

df_3 <- df_imp %>%
  mutate(
    DASS_stress = DASS_1 + DASS_6 + DASS_8 + DASS_11 + DASS_12 + DASS_14 + DASS_18,
    DASS_anxiety = DASS_2 + DASS_4 + DASS_7 + DASS_9 + DASS_15 + DASS_19 + DASS_20,
    DASS_depression = DASS_3 + DASS_5 + DASS_10 + DASS_13 + DASS_16 + DASS_17 + DASS_21,
    DASS_total = DASS_stress + DASS_anxiety + DASS_depression,
    IBQ_surgency = sum(IBQ_1 + IBQ_2 + IBQ_7 + IBQ_8, IBQ_13 + IBQ_14 + IBQ_15 + IBQ_20 + IBQ_21 + IBQ_26 + IBQ_27 + IBQ_36 + IBQ_37),
    COPE_approach_Eis = COPE_2 + COPE_7 + COPE_5 + COPE_15 + COPE_10 + COPE_23 + COPE_12 + COPE_17 + COPE_14 + COPE_25 + COPE_20 + COPE_24,
    COPE_avoidant_Eis = COPE_1 + COPE_19 + COPE_3 + COPE_8 + COPE_4 + COPE_11 + COPE_5 + COPE_15 + COPE_6 + COPE_16 + COPE_9 + COPE_21 + COPE_13 + COPE_26,
    COPE_total = COPE_1 + COPE_2 + COPE_3 + COPE_4 + COPE_5 + COPE_6 + COPE_7 + COPE_8 + COPE_9 + COPE_10 + COPE_11 + COPE_12 + COPE_13 + COPE_14 + COPE_15 + COPE_16 + COPE_17 + COPE_18 + COPE_19 + COPE_20 + COPE_21 + COPE_22 + COPE_23 + COPE_24 + COPE_25 + COPE_26 + COPE_27 + COPE_28,
    ISEL_appraisal = ISEL_2 + ISEL_4 + ISEL_6 + ISEL_11,
    TIPS_total = TIPS_1 + TIPS_2 + TIPS_3 + TIPS_4 + TIPS_5 + TIPS_6 + TIPS_7 + TIPS_8 + TIPS_9 + TIPS_10 + TIPS_11 + TIPS_12 + TIPS_13 + TIPS_14
  )

fit_imp <- with(df_3, exp = lm(DS_score ~ DASS_total + IBQ_surgency + COPE_total + ISEL_appraisal + TIPS_total))

##summary(pool(fit_imp))

##pool_imp <- pool(fit_imp)

我尝试了使用这两个注释掉的代码行进行汇总,但都导致了错误消息。

英文:

I have completed a MI with mice in R and have followed the steps for pooling the results that I found on RDocumentation. I think I understand why I have completed the linear regression and now I am trying to pool the results but I keep getting an error message that says :

No tidy method for objects of class qr

I have tried installing tidyverse, broom, broom.mixed but none of these make the error message go away...

I am wondering if I have made it more difficult for myself by computing total scores after the imputation, but this is what I need for the lm...
Attaching my code here in case there is something really obvious that I have missed...

#Imputing data 
imp &lt;- mice(df_2,  m = 5, seed = 2023)

df_imp &lt;- complete(imp, &quot;long&quot;, include = FALSE)

df_3 &lt;- df_imp %&gt;% mutate(
  DASS_stress = DASS_1 + DASS_6 + DASS_8 + DASS_11 + DASS_12 + DASS_14 + DASS_18,
  DASS_anxiety = DASS_2 + DASS_4 + DASS_7 + DASS_9 + DASS_15 + DASS_19 + DASS_20,
  DASS_depression = DASS_3 + DASS_5 + DASS_10 + DASS_13 + DASS_16 + DASS_17 + DASS_21,
  DASS_total = DASS_stress + DASS_anxiety + DASS_depression,
  IBQ_surgency = sum(IBQ_1 + IBQ_2+ IBQ_7 + IBQ_8, IBQ_13 + IBQ_14 + IBQ_15 + IBQ_20 + IBQ_21 + IBQ_26 + IBQ_27 + IBQ_36 + IBQ_37),
  COPE_approach_Eis = COPE_2 + COPE_7 + COPE_5 + COPE_15 + COPE_10 + COPE_23 + COPE_12 + COPE_17 + COPE_14 + COPE_25 + COPE_20 + COPE_24,
  COPE_avoidant_Eis = COPE_1 + COPE_19 + COPE_3 + COPE_8 + COPE_4 + COPE_11 + COPE_5 + COPE_15 + COPE_6 + COPE_16 + COPE_9 + COPE_21 + COPE_13 + COPE_26,
  COPE_total = COPE_1 + COPE_2 + COPE_3 + COPE_4 + COPE_5 + COPE_6 + COPE_7 + COPE_8 + COPE_9 + COPE_10 + COPE_11 + COPE_12 + COPE_13 + COPE_14 + COPE_15 + COPE_16 + COPE_17 + COPE_18 + COPE_19 + COPE_20 + COPE_21 + COPE_22 + COPE_23 + COPE_24 + COPE_25 + COPE_26 + COPE_27 + COPE_28,
  ISEL_appraisal = ISEL_2 + ISEL_4 + ISEL_6 + ISEL_11,
  TIPS_total = TIPS_1 + TIPS_2 + TIPS_3 + TIPS_4 + TIPS_5 + TIPS_6 + TIPS_7 + TIPS_8 + TIPS_9 + TIPS_10 + TIPS_11 + TIPS_12 + TIPS_13 + TIPS_14
)

fit_imp &lt;- with(df_3, exp = lm(DS_score ~ DASS_total + IBQ_surgency + COPE_total + ISEL_appraisal + TIPS_total))

##summary(pool(fit_imp))

##pool_imp &lt;- pool(fit_imp)

I have tried to pool with both of those hashtag/commented codes but both of them result in the error message.

答案1

得分: 1

如果您查看mice文档,这并不是获得多重插补推断的方法。您不应该“完成”数据。mice的结果具有特殊类别,并且一些回归模型(例如lmglm等)具有处理该类别的签名方法 - 它为每个插补模型拟合,并且输出具有特殊类别。然后,您可以直接在该输出上使用pool来获得这些回归模型的Rubin's Rules推断。

缺失值应被视为随机值。“完成”存在的两个原因之一是为了查看敏感性分析的结果 - 请注意action=对结果有非常不同的影响,而默认值很长(如果Stef从1L更新默认值将会很好)。第二个原因是在默认值尚未添加到mice中时(例如GEEs、最大似然等),手动进行回归分析和应用Rubin's Rules。

英文:

If you look through the mice documentation, this is not how you obtain multiply imputed inference at all. You should not "complete" the data. The mice result has a special class, and some regressions (lm, glm for instance) has signed methods to handle the class - it fits models for each imputation and the output has a special class. You can then get the Rubin's Rules inference for those regressions using pool directly on that output.

The missing value should be regarded as a random value. "Complete" exists for two reasons, for one: to look at the result for sensitivity analyses - be aware action= has vastly different impacts on the result, and the default is long (it would be nice if Stef updated the default from 1L). The second is to do by-hand regressions and application of Rubin's Rules in case the defaults aren't already added to mice (such as GEEs, maximum likelihood, etc.)

huangapple
  • 本文由 发表于 2023年6月8日 21:11:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76512996.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定