I have a set of 5 datasets that were generated through multiple imputation using the mice package. I'm running a hierarchical regression on these datasets, but when I try to pool the results, I get an error that "Column 6 must be named" and to use .name_repair. I've never seen this issue, and I checked the names of my columns, and they all have a name. Can someone explain what I should do to troubleshoot?
pool(with(mids_dis, lmer(exer_vig ~ 1 + (1 | team_num) + (1 | dept_client))))
Error: Column 6 must be named.
Use .name_repair to specify repair.
Call `rlang::last_error()` to see a backtrace
> rlang::last_error()
<error>
message: Column 6 must be named.
Use .name_repair to specify repair.
class: `rlang_error`
backtrace:
1. mice::pool(...)
2. mice:::pool.fitlist(getfit(object), dfcom = dfcom)
4. mice:::summary.mira(fitlist, type = "tidy", exponentiate = FALSE)
8. base::lapply(fitlist, tidy, effects = "fixed", ...)
10. broom:::tidy.merMod(X[[i]], ...)
11. broom::fix_data_frame(ret, newnames = nn)
13. tibble:::as_tibble.data.frame(ret)
14. tibble:::as_tibble.list(unclass(x), ..., .rows = .rows, .name_repair = .name_repair)
15. tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
16. tibble:::set_repaired_names(x, .name_repair)
21. tibble:::repaired_names(names(x), .name_repair = .name_repair)
22. tibble:::check_unique(new_name)
Call `rlang::last_trace()` to see the full backtrace
After some searching, I found the answer to my issue here:
https://github.com/stefvanbuuren/mice/issues/95
In short, mice throws the name_repair error when using lmerTest. There are two ways to get around this error:
If you do NOT need significance (p) values, then loading lme4 or using lme4::lmer will work with no issues.
If you DO need significance values, then you need to also load the package miceadds. With this loaded, you can use lmerTest with no issue.
library(mice)
library(miceadds)
library(lmerTest)
summary(pool(with(mids_dis, lmerTest::lmer(exer_vig ~ 1 + age + (1 | team_num) + (1 | dept_client)))))
estimate std.error statistic df p.value
(Intercept) 2.36102939 0.31957622 7.388001 244.3050 2.353007e-12
age 0.01096181 0.01042713 1.051277 238.7271 2.941943e-01