yrosseel / lavaan

an R package for structural equation modeling and more
http://lavaan.org
438 stars 99 forks source link

help file for anova() not precise when method="satorra.2000"; and anova() does not mean scale when m0/m1 not estimated robustly #383

Open njaalf opened 2 months ago

njaalf commented 2 months ago

Hi, when test="sb" the scaled.shifte=F option gives a regular sb scaling, and not mean-and variance as claimed in help.

Also, for objects m0 and m1 not fitted with test="sb" or other robust tests, anova(method="satorra.2000") should still calculate a mean scaled test, and not the simple chi-square difference?

note: We did not check what happens for the other methods ("satorra.bentler.2001", etc)

Code:

m0 <- "F=~x1+bx2+bx3+b*x4" m1 <- "F=~x1+x2+x3+x4" set.seed(1) dd <- simulateData(m0)

only happens when test="sb"

f0 <- cfa(m0, dd, test="sb"); f1 <- cfa(m1,dd, test="sb") res <- anova(f0, f1, method="satorra.2000", scaled.shifted=F) str(res)# its a satorra.bentler mean scaling, not mean-and-variance scaled

without test="sb"

f0 <- cfa(m0, dd); f1 <- cfa(m1,dd) res <- anova(f0, f1, method="satorra.2000", scaled.shifted=F) str(res)# regular non-robust chi-square difference!

yrosseel commented 2 months ago

About the first point: Originally, method = "satorra.2000" was only meant to be used in the categorical case. After all, in the continuous case, we have satorra.bentler.2001 (and 2010).

As for the second point: if none of the models involved used a 'robust' test statistic, the regular LRT is returned, and the method= argument is ignored. I suppose a warning would perhaps be in order. (Or a better explanation in the man page).

The code in lav_test_LRT.R and lav_test_diff.R is very old, and has been adapted so many times over the years that a complete rewrite is in order. I only need to find the time. In the mean time, I will keep this issue open.