R mice: how to impute a correlation matrix

137 Views Asked by At

I am using the mice package on R to impute missing values for questionnaire, and and I want to find the polychoric correlation matrix so that I can do analysis on it (e.g. alpha, EFA).

I'm not sure how to specify this in the analysis step (with()).

Here is a min reproducible example using the bfi dataset from the psych package:

library(psych)
library(tidyverse)
data <- bfi %>% 
  select(-c(gender, education, age))

# The analysis I want to do (demonstrating on original data set with missing data)
polychoric(data)$rho

# The imputation bit
imp <- mice(data)

# Trying to do the analysis on the imputed datasets
cor <- with(imp, ???) # Not sure how to put in the polychoric function here
2

There are 2 best solutions below

1
Ric On
cor <- with(imp, polychoric(data)$rho)
0
hanne On

There's now a new function in mice (v3.16.0) to pool estimates of analyses that are not recognized by the broom workflow underlying the pool() function. See the pool.table() documentation on https://amices.org/mice/reference/pool.table

In your case, you would need to apply some further steps on the output of the polychoric() function to obtain the estimates that mice can pool.

# apply the polychric function to each imputed dataset
# then perform further analyses (e.g. fa())
compl <- mice::complete(imp, "all")
fits <- purrr::map(compl, ~{
  polychoric(.x)$rho # %>% 
  # ...
  # ...
  # ...
})

# combine estimates in the right format
# by filling in the NAs in the table below
ests <- data.frame(
  term = NA, 
  estimate = NA, 
  std.error = NA, 
  df.residual = NA)

# apply pool.table() function
mice::pool.table(ests)