I have a longitudinal data set with missing values. I want to multiply impute (let us say $m$ = 20 times) the missing values in the wide format using the R-package mice. Thereafter, I would like to fit a multilevel model based on the imputed data with the function lmer from the R-package lme4. The function lmer does, however, only seem to be able to fit a model based on the long format.
I therefore extracted the 20 imputed datasets with the function complete from mice and converted each data frame into the long format using the function pivot_longer from the tidyr package. Subsequently, I fitted a multilevel model on each long-format dataset using lmer, resulting in 20 regression outputs. This works.
However, I would eventually want to obtain standard errors of the estimated regression parameters that are based on the within-imputation and between-imputation variance (the whole reason one does want to use multiple imputation). This is usually easily done with the mice function pool. However, pool can only be used on an object of the class mira, which is only obtained if the regression models are directly fitted on a object of the mids class, which again is the object class that is returned by the function mice. Since I converted the multiply imputed data sets, this does not seem to be possible. I found some similar questions on stack overflow, such as these here:
However, all the questions/answers either do not tell how to obtained pooled standard errors or they deal with imputing the data with a multilevel model (such as mice.impute.2l), which does not work in my case (imputation fails). I simply want to use a single-level model, as outlined here: https://stefvanbuuren.name/fimd/sec-fdd.html
Can anybody give adivce?