simsem / semTools

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

Should stopifnot(con@Data@data.type != "full") be stopifnot(con@Data@data.type == "full")? #136

Closed Shotgunosine closed 6 months ago

Shotgunosine commented 6 months ago

Trying to run some examples that were working as of 4f3e2bd9b4a17c8325274ac02e2155f163fc4b97 but now fail with the message:

Error in (function (nPermute, modelType, con, uncon, null, param, freeParam,  : 
  con@Data@data.type != "full" is not TRUE

Here's the code:

library("lavaan")
library("semTools")
## create 3-group data in lavaan example(cfa) data
HS <- lavaan::HolzingerSwineford1939
HS$ageGroup <- ifelse(HS$ageyr < 13, "preteen",
                      ifelse(HS$ageyr > 13, "teen", "thirteen"))

## fit target model with varying levels of measurement equivalence
mod.config <- '
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
'
fit.config <- cfa(mod.config, data = HS, std.lv = TRUE, group = "ageGroup")

####################### Permutation Method
## fit indices of interest for multiparameter omnibus test
myAFIs <- c("chisq","cfi","rmsea","mfi","aic")
moreAFIs <- c("gammaHat","adjGammaHat")
## Use only 20 permutations for a demo.  In practice,
## use > 1000 to reduce sampling variability of estimated p values
## test configural invariance
set.seed(12345)
print(fit.config@Data@data.type)
out.config <- permuteMeasEq(nPermute = 20, con = fit.config)

Looking at commit b8af51e the message says "check @DaTa$data.type=="full" before permuting" but it looks like the code is checking the opposite: https://github.com/simsem/semTools/blob/7e646e4e46b633eb573b0dae9a4a40b5439d16bf/semTools/R/permuteMeasEq.R#L1148-L1157

TDJorgensen commented 6 months ago

fixed by #137

TDJorgensen commented 6 months ago

FYI, the issue can close automatically if you indicate in the PR comment "fix #136".

Thanks again!