simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

Strange (high) SRMR fitmeasures from cfa.mi() #18

Closed sammerk closed 7 years ago

sammerk commented 7 years ago

I get strange (high) SRMR values using cfa.mi().

A minimal example from the help:

##############################
library(semTools)
library(lavaan)

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

HSMiss <- HolzingerSwineford1939[,paste("x", 1:9, sep="")]
randomMiss <- rbinom(prod(dim(HSMiss)), 1, 0.1)
randomMiss <- matrix(as.logical(randomMiss), nrow=nrow(HSMiss))
HSMiss[randomMiss] <- NA

out <- cfa.mi(HS.model, data=HSMiss, m = 3, chi="all")

fitmeasures(out)["srmr"]
###############################

This gives me

> fitmeasures(out)["srmr"]
     srmr 
0.3379134 
TDJorgensen commented 7 years ago

I don't know what version of lavaan or semTools you are using, but runMI does not currently work with the latest development version of lavaan. I am in the process of completely rewriting runMI, and I can tell you is that the new version returns a value similar in magnitude to the complete-data SRMR (around .06). Until the new versions of lavaan and semTools are released on CRAN, you could calculate SRMR on your own from the resid() output:

R <- resid(out, type = "cor") covR <- R$cov # or R[[1]]$cor, for each group mR <- R$mean # or R[[1]]$mean, for each group sqR <- c(covR[lower.tri(covR, diag = TRUE)], mR)^2 # add other groups if necessary sqrt(mean(sqR)) # SRMR

sammerk commented 7 years ago

OK - thank you! Does it make sense to install the development version of {semTools} via devtools::install_git()?

TDJorgensen commented 7 years ago

I have not yet replaced the source code with my revisions. I am hesitant to do so because it relies on experimental features in lavaan that are being developed (multiple updates in the past week) along with the changes in semTools. Neither can be submitted to CRAN until simsem is also updated, but I expect to have a development version of semTools available via github in a couple weeks.

sammerk commented 7 years ago

That sounds great ...

TDJorgensen commented 7 years ago

Hi Sam,

Thanks to the lavaan developer's help, I was able to get a good working copy of the new runMI() ready. There are still a few issues with categorical outcomes to work out (the fitted and residuals methods, the standardized solution and SRMR), but everything else seems to be working fine. You can install the development version using devtools::install_git("simsem/semTools/semTools")