[R] R-help Digest, Vol 206, Issue 25
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
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
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
s1 <- mice(lsat2)
Error: No glance method for objects of class numeric
with.mids(data = s1, expr = polychor(A, B))
mice(data = lsat3)
A B C D E
9 11 13 7 10
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