[R] R-help Digest, Vol 206, Issue 25

David Duffy D@v|d@Du||y @end|ng |rom q|mrbergho|er@edu@@u
Wed Apr 29 07:47:44 CEST 2020


I don't think anyone responded last week.

> Using the mice package, I have created multiple imputed datasets to deal
> with missing data. I am looking for an example of the R code to use in
> order to analyze the set of imputed datasets using tetrachoric correlations
> in such a way that after pooling, I will have a combined tetrachoric
> covariance-variance matrix to use as input for an exploratory factor
> analysis.

Hi Ian.

The mice package requires you to have an appropriate method to extract the individual simulated datasets:

The ‘mira’ object is generated by the ‘with.mids()’...It may happen that you'll see the messages like ‘No method for tidying an S3 object of class ...’ or ‘Error: No glance method for objects of class ...’. The royal way to solve this problem is to write your own ‘glance()’ and ‘tidy()’ methods and add these to ‘broom’ according to the specifications given in
 <URL: https://broom.tidyverse.org/articles/adding-tidiers.html>.

eg
data(gllm::lsat)
idx <- rep(1:32, lsat$Freq)
lsat2 <- lsat[idx,-6]
idx <- cbind(sample(1:1000, size=50, replace=T), sample(1:5, size=50, replace=T))
lsat2[idx] <- NA
library(mice)
s1 <- mice(lsat2)
pool(with(s1, exp=polychor(A,B)))
Error: No glance method for objects of class numeric

 print(with(s1, exp=polychor(A,B)))
call :
with.mids(data = s1, expr = polychor(A, B))
call1 :
mice(data = lsat3)

nmis :
 A  B  C  D  E 
 9 11 13  7 10 

analyses :
[[1]]
[1] 0.1552523

[[2]]
[1] 0.1485645

[[3]]
[1] 0.1584301

[[4]]
[1] 0.1536678

[[5]]
[1] 0.1698725

You can see that "all" you have to do is take the mean of the A-B tetrachoric correlations from in this case, 5, replicates, to get your corrected correlation.

It happens that there is a ‘glance.lavaan’ routine, and lavaan has the lavCor() function to estimate tetrachoric correlations and
fit structural equation models. So you can probably fit your factor model directly and get correct statistical tests there.

Cheers, David Duffy.



More information about the R-help mailing list