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 <- 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 tried to pool with both of those hashtag/commented codes but both of them result in the error message.
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.)