How to calculate pooled Cronbach's Alpha after multiple imputation

21 Views Asked by At

I'm new here and I have a question regarding Cronbach's Alpha after imputation. I've already looked up several resources and I found the same problem here with a reproducible example (How do I calculate cronbach's alpha on multiply imputed data?). I tried to apply the code to my imputed data set, but it doesn't work.

I used mice() for imputation and did the so-called split file procedure because I am also interested in interaction effects. I specified m=20, maxit=10. Afterwards, I combined both multiply imputed data sets and extracted it in long format. Then I created the scales (e. g. PHQ) and added them to the data set. After that, I calculated the means and standard deviations and since I also want to report the internal consistency, I looked up how to calculate a pooled estimate of Cronbach's Alpha. If I've understood the resources correctly, one should report a pooled estimate. That's why I tried to apply the aforementioned code, however, it didn't work yet, and I don't understand what I'm doing wrong.

For starters, I've also used the ordinary alpha()-command on both the imputed and non-imputed data just to get a first glance at the internal consistency. This worked perfectly finde, however, after doing research on the problem, this does not feel right (and reportable) because the sources I've read point towards a pooled Cronbach's alpha estimate.

Here is my code:

imp.data1 <- mice(data.2, m=20, maxit=10, seed=123, predictorMatrix=pred.m, print=F)
    imp.data2 <- mice(data.2, m=20, maxit=10, seed=123, predictorMatrix=pred.m, print=F) # data.1      and data.2 are subsets of the same dataset
    imp.data <- rbind(imp.data1, imp.data2)
    imp.int2 <- complete(imp.data, action="long", include=F)

cronbach_fun <- function(list_compl_data, boot = TRUE, B = 1e4, ci = FALSE) {
    n <- nrow(list_compl_data); p <- ncol(list_compl_data)
    total_variance <- var(rowSums(list_compl_data))
    item_variance <- sum(apply(list_compl_data, 2, sd)^2)
    alpha <- (p/(p - 1)) * (1 - (item_variance/total_variance))
    out <- list(alpha = alpha)
    boot_alpha <- numeric(B)
    if (boot) {
    for (i in seq_len(B)) {
      boot_dat <- list_compl_data[sample(seq_len(n), replace = TRUE), ]
      total_variance <- var(rowSums(boot_dat))
      item_variance <- sum(apply(boot_dat, 2, sd)^2)
      boot_alpha[i] <- (p/(p - 1)) * (1 - (item_variance/total_variance))
    }
    out$var <- var(boot_alpha)
    }
    if (ci){
    out$ci <- quantile(boot_alpha, c(.025,.975))
    }
    return(out)
    }

this step works

m <- length(unique(imp.int2$.imp))
    boot_alpha <- rep(list(NA), m)
    for (i in seq_len(m)) {
    set.seed(i) # fix random number generator
    sub <- imp.int2[imp.int2$.imp == i, -c(1,2)]
    boot_alpha[[i]] <- cronbach_fun(sub)
    }

after this one I receive a warning message (error in rowSums(list_compl_data): 'x' is not numeric)

Due to data protection regulations, I cannot provide the data. Where did I go wrong? If further information is required, I will happily provide it.

Thanks for your help in advance! :)

0

There are 0 best solutions below