simsem / semTools

Useful tools for structural equation modeling
74 stars 35 forks source link

Uninformative Error in compRelSEM with multiple factors and ordered data #130

Closed juliuspfadt closed 9 months ago

juliuspfadt commented 9 months ago

With the following data shortUpps.csv and this code:

library(lavaan)

data <- read.csv("shortUpps.csv", sep = ";")
data <- data[complete.cases(data), ]

model <- "f1 =~ U17_r + U22_r + U29_r + U34_r
f2 =~ U4 + U14 + U19 + U27"

fit1 <- cfa(model, data, ordered = TRUE, std.lv = TRUE)
semTools::compRelSEM(fit1, tau.eq = FALSE, return.total = TRUE, ord.scale = TRUE)

I get the error: Error in diag(scales) %*% truevar : non-conformable arguments

It does not happen with a single factor:

model2 <- "f1 =~ U17_r + U22_r + U29_r + U34_r"

fit2 <- cfa(model2, data, ordered = TRUE, std.lv = TRUE)
semTools::compRelSEM(fit2, tau.eq = FALSE, return.total = TRUE, ord.scale = TRUE)

Given that the loadings and residuals are all there, and lavaan does not throw any warnings, I wonder what is going wrong?

TDJorgensen commented 9 months ago

This example works fine in the GitHub version, so I must have already fixed that bug.

remotes::install_github("simsem/semTools/semTools")

I have some work to do getting semTools ready for CRAN, but that update should resolve the problem in JASP too.

juliuspfadt commented 9 months ago

Thanks for the swift reply. You are right, it is fixed. Thanks :)

juliuspfadt commented 1 week ago

Hi @TDJorgensen are there any news in regards to a CRAN version that contains the fix. Usually the JASP developers only allow CRAN packages so I can't really use your GitHub version.

TDJorgensen commented 1 week ago

I'm working on it, but this has to happen in coordination with sending the new lavaan.mi package to CRAN. I know this has been a long time in the works, but it has been a much larger set of updates than I anticipated. I have one more feature to implement in semTools before sending to CRAN, which I need for a workshop I will teach this summer. Other deadlines just keep interrupting...

juliuspfadt commented 1 week ago

Alright, thanks for clarifying.