measurment invariance for categorical itens: "measurmentinvarianceCAT" vs measEQ.Syntax

431 views
Skip to first unread message

João Marôco

unread,
Jul 4, 2019, 10:02:07 AM7/4/19
to lavaan
Dear Torgensen, and other colleagues doing measurment invariance for categorical data,

I am trying to do an invariance analysis of a 3 factor scale with 15 itens. My model is

modinv = '
Cp =~ SE1 + SE2 + SE3 + SE4 + SE5
Em =~ SE6 + SE7 + SE8 + SE9 + SE10
Co =~ SE11 + SE12 + SE13 + SE14 + SE15
# fator de 2a ordem
#eng =~ Cp + Em + Co
'

if use the old semTools'  measurmentInvarianceCat:

grupo = "Country"
measurementInvarianceCat(model = modinv, data = bd, group = grupo, method = "Satorra.Bentler.2010", missing ="listwise", ordered=it, strict = F, fit.measures = "default")

where 

it = c("SE1","SE2","SE3","SE4","SE5","SE6","SE7","SE8","SE9","SE10","SE11","SE12","SE13","SE14","SE15")

I get this results for the invariance of the first order constructs (note that my second order "eng" construct is commented with # in the modinv definition):

Measurement invariance models:

Model 1 : fit.configural
Model 2 : fit.loadings
Model 3 : fit.thresholds
Model 4 : fit.means

Scaled Chi Square Difference Test (method = "satorra.bentler.2010")

                 Df AIC BIC  Chisq Chisq diff Df diff Pr(>Chisq)    
fit.configural  696         2171.1                                  
fit.loadings    780         2627.3     247.68      84  < 2.2e-16 ***
fit.thresholds 1074         4414.4    1521.90     294  < 2.2e-16 ***
fit.means      1095         7890.1     269.26      21  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Fit measures:

               cfi.scaled rmsea.scaled cfi.scaled.delta rmsea.scaled.delta
fit.configural      0.962        0.074               NA                 NA
fit.loadings        0.960        0.071            0.002              0.002
fit.thresholds      0.936        0.077            0.024              0.005
fit.means           0.900        0.095            0.036              0.018


But, if I do the same analysis (at least I think its the same) with the new measEQ.syntax:

grupo="Country"
test.seq <-  c("thresholds","loadings","means")
meq.list <- list()
for (i in 0L:length(test.seq)) {
  if (i == 0L) {
    meq.label <- "configural"
    group.equal <- ""
  } else {
    meq.label <- test.seq[i]
    group.equal <- test.seq[1:i]
  }
  meq.list[[meq.label]] <- measEq.syntax(configural.model = modinv,
                                         data = bd,
                                         ordered = it,
                                         parameterization = "theta",
                                         #ID.fac = "ul",
                                         ID.cat = "Wu",
                                         group = grupo,
                                         group.equal = group.equal,
                                         return.fit = TRUE)
  }

compareFit(meq.list)

I get an error that I can't understand:

Error in getMethod("summary", signature = "FitDiff") : 
  no method found for function 'summary' and signature FitDiff


Any clues of what is wrong? I attached the rds data file in case someone wants to do a quick run. My objective of using measEQ.syntax is to then test the invariance of the second order eng=~Cp +Em + Co ...

Thanks in advance,
João
P.S. I am running both lavaan and semTools latest dev versions
bdUSEI4000.rds

Terrence Jorgensen

unread,
Jul 5, 2019, 1:47:07 PM7/5/19
to lavaan
Works fine for me.  sessionInfo() returns these version numbers:

semTools_0.5-1.933 lavaan_0.6-5.1453


I hope you noticed the warning message:

lavaan WARNING: some models have the same degrees of freedom

Your models are not nested.  Before you can test equality of means, you need to constrain intercepts to equality.  

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam


jpma...@gmail.com

unread,
Jul 5, 2019, 4:58:04 PM7/5/19
to lav...@googlegroups.com

Dear Terrence,

Thanks for your reply.

My sessionInfo() returns:

semTools_0.5-1.934 lavaan_0.6-5.1453

and I still get the same error:

        if (!is.null(dotdotdot$control$optim.force.converged)) {

            dotdotdot$optim.force.converged <- dotdotdot$control$optim.force.converged

        }

        if (!is.null(dotdotdot$control$gradient)) {

            dotdotdot$optim.gradient <- dotdotdot$control$gradient

        }

        if (!is.null(dotdotdot$gradient)) {

            dotdotdot$optim.gradient <- dotdotdot$gradient

        }

        if (!is.null(dotdotdot$control$init_nelder_mead)) {

            dotdotdot$optim.init_nelder_mead <- dotdotdot$control$init_nelder_mead

        }

    }

    if (!is.null(slotParTable)) {

        FLAT <- slotParTable

    }

    else if (is.character(model)) {

        FLAT <- lavParseModelString(model)

    }

    else if (inherits(model, "formula")) {

        tmp <- as.character(model)

        if (tmp[1] == "~" && length(tmp) == 2L) {

            warning("lavaan WARNING: model seems to be a formula; please enclose the model syntax between quotes")

            model.bis <- paste("f =", paste(tmp, collapse = " "),

                sep = "")

            FLAT <- lavParseModelString(model.bis)

        }

        else if (tmp[1] == "~" && length(tmp) == 3L) {

            warning("lavaan WARNING: model seems to be a formula; please enclose the model syntax between quotes")

            model.bis <- paste(tmp[2], tmp[1], tmp[3])

            FLAT <- lavParseModelString(model.bis)

        }

        else {

            stop("lavaan ERROR: model seems to be a formula; please enclose the model syntax between quotes")

        }

    }

    else if (inherits(model, "lavaan")) {

        FLAT <- parTable(model)

    }

    else if (is.list(model)) {

        if (!is.null(model$lhs) && !is.null(model$op) && !is.null(model$rhs) &&

            !is.null(model$free)) {

            FLAT <- model

            if (!is.null(FLAT$block)) {

                N <- length(FLAT$lhs)

                if (length(FLAT$block) != N) {

                  FLAT$block <- FLAT$group

                }

                if (any(is.na(FLAT$block))) {

                  FLAT$block <- FLAT$group

                }

            }

            else if (!is.null(FLAT$group)) {

                FLAT$block <- FLAT$group

            }

        }

        else {

            bare.minimum <- c("lhs", "op", "rhs", "free")

            missing.idx <- is.na(match(bare.minimum, names(model)))

            missing.txt <- paste(bare.minimum[missing.idx], collapse = ", ")

            stop("lavaan ERROR: model is a list, but not a parameterTable?",

                "\n  lavaan  NOTE: ", "missing column(s) in parameter table: [",

                missing.txt, "]")

        }

    }

    else if (is.null(model)) {

        stop("lavaan ERROR: model is NULL!")

    }

    if (any(FLAT$op == ":" & tolower(FLAT$lhs) == "group")) {

        group.idx <- which(FLAT$op == ":" & tolower(FLAT$lhs) ==

            "group")

        FLAT$lhs[group.idx] <- "group"

        tmp.group.values <- unique(FLAT$rhs[group.idx])

        tmp.ngroups <- length(tmp.group.values)

        tmp.lav <- lavaanify(FLAT, ngroups = tmp.ngroups, warn = FALSE)

        ov.names <- ov.names.y <- ov.names.x <- vector("list",

            length = tmp.ngroups)

        for (g in seq_len(tmp.ngroups)) {

            ov.names[[g]] <- unique(unlist(lav_partable_vnames(tmp.lav,

                type = "ov", group = tmp.group.values[g])))

            ov.names.y[[g]] <- unique(unlist(lav_partable_vnames(tmp.lav,

                type = "ov.nox", group = tmp.group.values[g])))

           ov.names.x[[g]] <- unique(unlist(lav_partable_vnames(tmp.lav,

                type = "ov.x", group = tmp.group.values[g])))

        }

    }

    else if (!is.null(FLAT$group)) {

        ngroups <- lav_partable_ngroups(FLAT)

        if (ngroups > 1L) {

            group.values <- lav_partable_group_values(FLAT)

            ov.names <- ov.names.y <- ov.names.x <- vector("list",

                length = ngroups)

            for (g in seq_len(ngroups)) {

                ov.names[[g]] <- lav_partable_vnames(FLAT, type = "ov",

                  group = group.values[g])

                ov.names.y[[g]] <- lav_partable_vnames(FLAT,

                  type = "ov.nox", group = group.values[g])

                ov.names.x[[g]] <- lav_partable_vnames(FLAT,

                  type = "ov.x", group = group.values[g])

            }

        }

        else {

            ov.names <- lav_partable_vnames(FLAT, type = "ov")

            ov.names.y <- lav_partable_vnames(FLAT, type = "ov.nox")

            ov.names.x <- lav_partable_vnames(FLAT, type = "ov.x")

        }

    }

    else {

        ov.names <- lav_partable_vnames(FLAT, type = "ov")

        ov.names.y <- lav_partable_vnames(FLAT, type = "ov.nox")

        ov.names.x <- lav_partable_vnames(FLAT, type = "ov.x")

    }

    if (any(FLAT$op == ":" & tolower(FLAT$lhs) == "level")) {

        if (!is.null(data) && is.null(cluster)) {

            stop("lavaan ERROR: cluster argument is missing.")

        }

        group.idx <- which(FLAT$op == ":" & FLAT$lhs == "group")

        tmp.group.values <- unique(FLAT$rhs[group.idx])

        tmp.ngroups <- max(c(length(tmp.group.values), 1))

        level.idx <- which(FLAT$op == ":" & tolower(FLAT$lhs) ==

            "level")

        FLAT$lhs[level.idx] <- "level"

        tmp.level.values <- unique(FLAT$rhs[level.idx])

        tmp.nlevels <- length(tmp.level.values)

        if (tmp.nlevels < 2L) {

            stop("lavaan ERROR: when data is clustered, you must specify a model\n",

                "  for each level in the model syntax (for now); see example(Demo.twolevel)")

        }

        tmp.lav <- lavaanify(FLAT, ngroups = tmp.ngroups, warn = FALSE)

        if (max(tmp.lav$level) < 2L) {

            stop("lavaan ERROR: at least one level has no model syntax; you must specify a model for each level in the model syntax (for now); see example(Demo.twolevel)")

        }

        ov.names.l <- vector("list", length = tmp.ngroups)

        for (g in seq_len(tmp.ngroups)) {

            ov.names.l[[g]] <- vector("list", length = tmp.nlevels)

            for (l in seq_len(tmp.nlevels)) {

                if (tmp.ngroups > 1L) {

                  ov.names.l[[g]][[l]] <- unique(unlist(lav_partable_vnames(tmp.lav,

                    type = "ov", group = tmp.group.values[g],

                    level = tmp.level.values[l])))

                }

                else {

                  ov.names.l[[g]][[l]] <- unique(unlist(lav_partable_vnames(tmp.lav,

                    type = "ov", level = tmp.level.values[l])))

                }

            }

        }

    }

    else {

        nlevels <- lav_partable_nlevels(FLAT)

        if (nlevels > 1L) {

            if (!is.null(data) && is.null(cluster)) {

                stop("lavaan ERROR: cluster argument is missing.")

            }

            ngroups <- lav_partable_ngroups(FLAT)

            ov.names.l <- vector("list", length = ngroups)

            for (g in 1:ngroups) {

                ov.names.l[[g]] <- lavNames(FLAT, "ov", group = g)

            }

        }

        else {

            ov.names.l <- list()

        }

    }

    if (!is.null(ordered)) {

        if (is.logical(ordered) && ordered) {

            ordered <- lavNames(FLAT, "ov")

        }

        else if (is.logical(ordered) && !ordered) {

            ordered <- character(0L)

        }

        else if (!is.character(ordered)) {

            stop("lavaan ERROR: ordered argument must be a character vector")

        }

        else {

            if (!is.null(data)) {

                missing.idx <- which(!ordered %in% names(data))

                if (length(missing.idx) > 0L) {

                  warning("lavaan WARNING: ordered variable(s): ",

                    paste(ordered[missing.idx], collapse = " "),

                    "\n  could not be found in the data and will be ignored")

                }

            }

        }

    }

    ordered <- unique(c(ordered, lavNames(FLAT, "ov.ord")))

    if (!is.null(slotOptions)) {

        lavoptions <- slotOptions

        if (length(dotdotdot) > 0L) {

            dot.names <- names(dotdotdot)

            op.idx <- which(dot.names %in% names(slotOptions))

            warning("lavaan WARNING: the following argument(s) override(s) the options in slotOptions:\n\t\t",

                paste(dot.names[op.idx], collapse = " "))

            lavoptions[dot.names[op.idx]] <- dotdotdot[op.idx]

        }

    }

    else {

        opt <- lav_options_default()

        ok.names <- names(opt)

        dot.names <- names(dotdotdot)

        wrong.idx <- which(!dot.names %in% ok.names)

        if (length(wrong.idx) > 0L) {

            idx <- wrong.idx[1L]

            stop("lavaan ERROR: unknown argument `", dot.names[idx],

                "'")

        }

        opt <- modifyList(opt, dotdotdot)

        if (any(FLAT$op == "|")) {

            opt$categorical <- TRUE

        }

        else if (!is.null(data) && length(ordered) > 0L) {

            opt$categorical <- TRUE

        }

        else if (!is.null(sample.th)) {

            opt$categorical <- TRUE

        }

        else if (is.data.frame(data) && lav_dataframe_check_ordered(frame = data,

            ov.names = ov.names.y)) {

            opt$categorical <- TRUE

        }

        else {

            opt$categorical <- FALSE

        }

        if (length(cluster) > 0L) {

            opt$clustered <- TRUE

        }

        else {

            opt$clustered <- FALSE

        }

        if (length(ov.names.l) > 0L && length(ov.names.l[[1]]) >

            1L) {

            opt$multilevel <- TRUE

        }

        else {

            opt$multilevel <- FALSE

        }

        if (!is.null(sampling.weights)) {

            opt$estimator <- "MLR"

        }

        if (any(nchar(constraints) > 0L) && opt$estimator %in%

            c("ML")) {

            opt$information <- "observed"

        }

        if (any(FLAT$op == "~1") || !is.null(sample.mean)) {

            opt$meanstructure <- TRUE

        }

        if (!is.null(group) && is.null(dotdotdot$meanstructure)) {

            opt$meanstructure <- TRUE

        }

        if ((is.list(ov.names.x) && sum(sapply(ov.names.x, FUN = length)) ==

            0L) || (is.character(ov.names.x) && length(ov.names.x) ==

            0L)) {

            if (is.logical(dotdotdot$conditional.x) && dotdotdot$conditional.x) {

                warning("lavaan WARNING: no exogenous covariates; conditional.x will be set to FALSE")

            }

            opt$conditional.x <- FALSE

        }

        if ((is.list(ov.names.x) && sum(sapply(ov.names.x, FUN = length)) ==

            0L) || (is.character(ov.names.x) && length(ov.names.x) ==

            0L)) {

            if (is.logical(dotdotdot$fixed.x) && dotdotdot$fixed.x) {

            }

            else {

                opt$fixed.x <- FALSE

            }

        }

        lavoptions <- lav_options_set(opt)

    }

    timing$Options <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    if (!lavoptions$fixed.x) {

        ov.names.x <- character(0L)

    }

    if (!is.null(slotData)) {

        lavdata <- slotData

    }

    else {

        OV.NAMES <- if (lavoptions$conditional.x) {

            ov.names.y

        }

        else {

            ov.names

        }

        lavdata <- lavData(data = data, group = group, cluster = cluster,

            ov.names = OV.NAMES, ov.names.x = ov.names.x, ov.names.l = ov.names.l,

            ordered = ordered, sampling.weights = sampling.weights,

            sample.cov = sample.cov, sample.mean = sample.mean,

            sample.th = sample.th, sample.nobs = sample.nobs,

            lavoptions = lavoptions)

    }

    if (lav...@data.type == "none") {

        lavoptions$do.fit <- FALSE

        lavoptions$start <- "simple"

        lavoptions$se <- "none"

        lavoptions$test <- "none"

    }

    else if (lav...@data.type == "moment") {

        if (!is.null(dotdotdot$estimator)) {

            if (dotdotdot$estimator %in% c("MLM", "MLMV", "MLR",

                "MLR", "ULSM", "ULSMV", "ULSMVS") && is.null(NACOV)) {

                stop("lavaan ERROR: estimator ", dotdotdot$estimator,

                  " requires full data or user-provided NACOV")

            }

            else if (dotdotdot$estimator %in% c("WLS", "WLSM",

                "WLSMV", "WLSMVS", "DWLS") && is.null(WLS.V)) {

                stop("lavaan ERROR: estimator ", dotdotdot$estimator,

                  " requires full data or user-provided WLS.V and NACOV")

            }

        }

        if (lavoptions$se == "bootstrap") {

            stop("lavaan ERROR: bootstrapping requires full data")

        }

    }

    timing$Data <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    if (lavoptions$debug) {

        print(str(lavdata))

    }

    if (!is.null(slotParTable)) {

        lavpartable <- slotParTable

    }

    else if (is.character(model) || inherits(model, "formula")) {

        if (lavoptions$debug) {

            print(as.data.frame(FLAT))

        }

        if (lavoptions$fixed.x) {

            tmp <- try(vnames(FLAT, type = "ov.x", ov.x.fatal = TRUE),

                silent = TRUE)

            if (inherits(tmp, "try-error")) {

                warning("lavaan WARNING: syntax contains parameters involving exogenous covariates; switching to fixed.x = FALSE")

                lavoptions$fixed.x <- FALSE

            }

        }

        if (lavoptions$conditional.x) {

            tmp <- vnames(FLAT, type = "ov.x", ov.x.fatal = TRUE)

        }

        lavpartable <- lavaanify(model = FLAT, constraints = constraints,

            varTable = lavdata@ov, ngroups = lavdata@ngroups,

            meanstructure = lavoptions$meanstructure, int.ov.free = lavoptions$int.ov.free,

            int.lv.free = lavoptions$int.lv.free, orthogonal = lavoptions$orthogonal,

            orthogonal.x = lavoptions$orthogonal.x, orthogonal.y = lavoptions$orthogonal.y,

            orthogonal.efa = lavoptions$rotation.args$orthogonal,

            conditional.x = lavoptions$conditional.x, fixed.x = lavoptions$fixed.x,

            std.lv = lavoptions$std.lv, effect.coding = lavoptions$effect.coding,

            parameterization = lavoptions$parameterization, auto.fix.first = lavoptions$auto.fix.first,

            auto.fix.single = lavoptions$auto.fix.single, auto.var = lavoptions$auto.var,

            auto.cov.lv.x = lavoptions$auto.cov.lv.x, auto.cov.y = lavoptions$auto.cov.y,

            auto.th = lavoptions$auto.th, auto.delta = lavoptions$auto.delta,

            auto.efa = lavoptions$auto.efa, group.equal = lavoptions$group.equal,

            group.partial = lavoptions$group.partial, group.w.free = lavoptions$group.w.free,

            debug = lavoptions$debug, warn = lavoptions$warn,

            as.data.frame. = FALSE)

    }

    else if (inherits(model, "lavaan")) {

        lavpartable <- parTable(model)

    }

    else if (is.list(model)) {

        lavpartable <- as.list(FLAT)

        lavpartable <- lav_partable_complete(lavpartable)

    }

    else {

        stop("lavaan ERROR: model [type = ", class(model), "] is not of type character or list")

    }

    if (lavoptions$debug) {

        print(as.data.frame(lavpartable))

    }

    junk <- lav_partable_check(lavpartable, categorical = lavoptions$categorical,

        warn = TRUE)

    if (lavoptions$optim.method == "em") {

        zero.var.idx <- which(lavpartable$op == "~~" & lavpartable$lhs ==

            lavpartable$rhs & lavpartable$free == 0L & lavpartable$ustart ==

            0)

        if (length(zero.var.idx) > 0L) {

            lavpartable$ustart[zero.var.idx] <- lavoptions$em.zerovar.offset

        }

    }

    lavpta <- lav_partable_attributes(lavpartable)

    timing$ParTable <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    if (!is.null(slotSampleStats)) {

        lavsamplestats <- slotSampleStats

    }

    else if (lav...@data.type == "full") {

        lavsamplestats <- lav_samplestats_from_data(lavdata = lavdata,

            missing = lavoptions$missing, rescale = (lavoptions$estimator %in%

                c("ML", "REML", "NTRLS") && lavoptions$likelihood ==

                "normal"), estimator = lavoptions$estimator,

            mimic = lavoptions$mimic, meanstructure = lavoptions$meanstructure,

            conditional.x = lavoptions$conditional.x, fixed.x = lavoptions$fixed.x,

            group.w.free = lavoptions$group.w.free, missing.h1 = (lavoptions$missing !=

                "listwise"), WLS.V = WLS.V, NACOV = NACOV, gamma.n.minus.one = lavoptions$gamma.n.minus.one,

            se = lavoptions$se, information = lavoptions$information,

            ridge = lavoptions$ridge, optim.method = lavoptions$optim.method.cor,

            zero.add = lavoptions$zero.add, zero.keep.margins = lavoptions$zero.keep.margins,

            zero.cell.warn = lavoptions$zero.cell.warn, debug = lavoptions$debug,

            verbose = lavoptions$verbose)

    }

    else if (lav...@data.type == "moment") {

        lavsamplestats <- lav_samplestats_from_moments(sample.cov = sample.cov,

            sample.mean = sample.mean, sample.th = sample.th,

            sample.nobs = sample.nobs, ov.names = ov.names, ov.names.x = ov.names.x,

            estimator = lavoptions$estimator, mimic = lavoptions$mimic,

            group.w.free = lavoptions$group.w.free, WLS.V = WLS.V,

            NACOV = NACOV, ridge = lavoptions$ridge, rescale = lavoptions$sample.cov.rescale)

    }

    else {

        lavsamplestats <- new("lavSampleStats", ngroups = lavdata@ngroups,

            nobs = as.list(rep(0L, lavdata@ngroups)), th.idx = lavpta$th.idx,

            missing.flag = FALSE)

    }

    timing$SampleStats <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    if (lavoptions$debug) {

        print(str(lavsamplestats))

    }

    if (!is.null(sloth1)) {

        lavh1 <- sloth1

    }

    else {

        lavh1 <- list()

        if (is.logical(lavoptions$h1) && lavoptions$h1) {

            if (length(lavsamplestats@ntotal) > 0L) {

                out <- lav_h1_implied_logl(lavdata = lavdata,

                  lavsamplestats = lavsamplestats, lavoptions = lavoptions)

                h1.implied <- out$implied

                h1.loglik <- out$logl$loglik

                h1.loglik.group <- out$logl$loglik.group

                lavh1 <- list(implied = h1.implied, loglik = h1.loglik,

                  loglik.group = h1.loglik.group)

            }

            else {

            }

        }

        else {

            if (!is.logical(lavoptions$h1)) {

                stop("lavaan ERROR: argument `h1' must be logical (for now)")

            }

        }

    }

    timing$h1 <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    if (!is.null(slotModel)) {

        lavmodel <- slotModel

        timing$start <- (proc.time()[3] - start.time)

        start.time <- proc.time()[3]

        timing$Model <- (proc.time()[3] - start.time)

        start.time <- proc.time()[3]

    }

    else {

        if (!is.null(lavpartable$est) && lavoptions$start ==

            "default") {

            zero.idx <- which(lavpartable$free > 0L & lavpartable$op ==

                "~~" & lavpartable$lhs == lavpartable$rhs & lavpartable$est ==

                0)

            if (length(zero.idx) > 0L || any(is.na(lavpartable$est))) {

                lavpartable$start <- lav_start(start.method = lavoptions$start,

                  lavpartable = lavpartable, lavsamplestats = lavsamplestats,

                  model.type = lavoptions$model.type, mimic = lavoptions$mimic,

                  debug = lavoptions$debug)

            }

            else {

                lavpartable$start <- lavpartable$est

            }

        }

        else {

            START <- lav_start(start.method = lavoptions$start,

                lavpartable = lavpartable, lavsamplestats = lavsamplestats,

                model.type = lavoptions$model.type, mimic = lavoptions$mimic,

                debug = lavoptions$debug)

            if (!is.null(lavoptions$check.start) && lavoptions$check.start) {

                START <- lav_start_check_cov(lavpartable = lavpartable,

                  start = START)

            }

            lavpartable$start <- START

        }

        timing$start <- (proc.time()[3] - start.time)

        start.time <- proc.time()[3]

        lavmodel <- lav_model(lavpartable = lavpartable, lavoptions = lavoptions,

            th.idx = lavsamp...@th.idx, cov.x = lavsamplestats@cov.x,

            mean.x = lavsamplestats@mean.x)

        timing$Model <- (proc.time()[3] - start.time)

        start.time <- proc.time()[3]

        if (lav...@data.type == "none" && lavmodel@categorical) {

            lavmodel <- lav_model_set_parameters(lavmodel = lavmodel,

                x = lav_model_get_parameters(lavmodel))

            lavpartable$start <- lav_model_get_parameters(lavmodel,

                type = "user")

            if (!all(lavpartable$start == lavpartable$ustart)) {

                if (lavmodel@parameterization == "delta") {

                  user.var.idx <- which(lavpartable$op == "~~" &

                    lavpartable$lhs == lavpartable$rhs & lavpartable$lhs %in%

                    unlist(lavpta$vnames$ov.ord) & lavpartable$user ==

                    1L)

                  if (length(user.var.idx)) {

                    warning("lavaan WARNING: ", "variance (theta) values for categorical variables are ignored",

                      "\n\t\t  if parameterization = \"delta\"!")

                  }

                }

                else if (lavmodel@parameterization == "theta") {

                  user.delta.idx <- which(lavpartable$op == "~*~" &

                    lavpartable$lhs == lavpartable$rhs & lavpartable$lhs %in%

                    unlist(lavpta$vnames$ov.ord) & lavpartable$user ==

                    1L)

                  if (length(user.delta.idx)) {

                    warning("lavaan WARNING: ", "scaling (~*~) values for categorical variables are ignored",

                      "\n\t\t  if parameterization = \"theta\"!")

                  }

                }

            }

        }

    }

    if (!is.null(slotCache)) {

        lavcache <- slotCache

    }

    else {

        lavcache <- vector("list", length = lavdata@ngroups)

        ov.types <- lavdata@ov$type

        if (lavmodel@conditional.x && sum(lavmodel@nexo) > 0L) {

            ov.x.idx <- unlist(lavpta$vidx$ov.x)

            ov.types <- ov.types[-ov.x.idx]

        }

        if (lavoptions$estimator == "PML" && all(ov.types ==

            "ordered")) {

            TH <- computeTH(lavmodel)

            BI <- lav_tables_pairwise_freq_cell(lavdata)

            if (lavoptions$missing == "available.cases" || lavoptions$missing ==

                "doubly.robust") {

                UNI <- lav_tables_univariate_freq_cell(lavdata)

            }

            if (lavoptions$missing == "doubly.robust") {

                if (is.null(lavoptions$control$pairwiseProbGivObs)) {

                  stop("lavaan ERROR: could not find `pairwiseProbGivObs' in control() list")

                }

                if (is.null(lavoptions$control$univariateProbGivObs)) {

                  stop("lavaan ERROR: could not find `univariateProbGivObs' in control() list")

                }

            }

            for (g in 1:lavdata@ngroups) {

                if (is.null(BI$group) || max(BI$group) == 1L) {

                  bifreq <- BI$obs.freq

                  binobs <- BI$nobs

                }

                else {

                  idx <- which(BI$group == g)

                  bifreq <- BI$obs.freq[idx]

                  binobs <- BI$nobs[idx]

                }

                LONG <- LongVecInd(no.x = ncol(lavdata@X[[g]]),

                  all.thres = TH[[g]], index.var.of.thres = lavm...@th.idx[[g]])

                lavcache[[g]] <- list(bifreq = bifreq, nobs = binobs,

                  LONG = LONG)

                if (lavoptions$missing == "available.cases" ||

                  lavoptions$missing == "doubly.robust") {

                  if (is.null(UNI$group) || max(UNI$group) ==

                    1L) {

                    unifreq <- UNI$obs.freq

                    uninobs <- UNI$nobs

                  }

                  else {

                    idx <- which(UNI$group == g)

                    unifreq <- UNI$obs.freq[idx]

                    uninobs <- UNI$nobs[idx]

                  }

                  lavcache[[g]]$unifreq <- unifreq

                  lavcache[[g]]$uninobs <- uninobs

                  uniweights.casewise <- rowSums(is.na(lavdata@X[[g]]))

                  lavcache[[g]]$uniweights.casewise <- uniweights.casewise

                  tmp.uniweights <- apply(lavdata@X[[g]], 2,

                    function(x) {

                      tapply(uniweights.casewise, as.factor(x),

                        sum, na.rm = TRUE)

                    })

                  if (is.matrix(tmp.uniweights)) {

                    lavcache[[g]]$uniweights <- c(tmp.uniweights)

                  }

                  if (is.list(tmp.uniweights)) {

                    lavcache[[g]]$uniweights <- unlist(tmp.uniweights)

                  }

                }

                if (lavoptions$missing == "doubly.robust") {

                  lavcache[[g]]$pairwiseProbGivObs <- lavoptions$control$pairwiseProbGivObs[[g]]

                  lavcache[[g]]$univariateProbGivObs <- lavoptions$control$univariateProbGivObs[[g]]

                  ind.vec <- as.data.frame(LONG[1:5])

                  ind.vec <- ind.vec[((ind.vec$index.thres.var1.of.pair !=

                    0) & (ind.vec$index.thres.var2.of.pair !=

                    0)), ]

                  idx.cat.y1 <- ind.vec$index.thres.var1.of.pair

                  idx.cat.y2 <- ind.vec$index.thres.var2.of.pair

                  idx.pairs <- ind.vec$index.pairs.extended

                  lavcache[[g]]$idx.pairs <- idx.pairs

                  idx.cat.y1.split <- split(idx.cat.y1, idx.pairs)

                  idx.cat.y2.split <- split(idx.cat.y2, idx.pairs)

                  lavcache[[g]]$idx.cat.y1.split <- idx.cat.y1.split

                  lavcache[[g]]$idx.cat.y2.split <- idx.cat.y2.split

                  nlev <- lavdata@ov$nlev

                  nvar <- length(nlev)

                  idx.var.matrix <- matrix(1:nvar, nrow = nvar,

                    ncol = nvar)

                  idx.diag <- diag(matrix(1:(nvar * nvar), nrow = nvar,

                    ncol = nvar))

                  idx.Y1Gy2.matrix <- rbind(t(idx.var.matrix)[-idx.diag],

                    idx.var.matrix[-idx.diag])

                  no.pairs.Y1Gy2 <- ncol(idx.Y1Gy2.matrix)

                  idx.cat.Y1 <- unlist(lapply(1:no.pairs.Y1Gy2,

                    function(x) {

                      rep(1:nlev[idx.Y1Gy2.matrix[1, x]], times = nlev[idx.Y1Gy2.matrix[2,

                        x]])

                    }))

                  idx.cat.Gy2 <- unlist(lapply(1:no.pairs.Y1Gy2,

                    function(x) {

                      rep(1:nlev[idx.Y1Gy2.matrix[2, x]], each = nlev[idx.Y1Gy2.matrix[1,

                        x]])

                    }))

                  dim.pairs <- unlist(lapply(1:no.pairs.Y1Gy2,

                    function(x) {

                      nlev[idx.Y1Gy2.matrix[1, x]] * nlev[idx.Y1Gy2.matrix[2,

                        x]]

                    }))

                  idx.Y1 <- unlist(mapply(rep, idx.Y1Gy2.matrix[1,

                    ], each = dim.pairs))

                  idx.Gy2 <- unlist(mapply(rep, idx.Y1Gy2.matrix[2,

                    ], each = dim.pairs))

                  lavcache[[g]]$idx.Y1 <- idx.Y1

                  lavcache[[g]]$idx.Gy2 <- idx.Gy2

                  lavcache[[g]]$idx.cat.Y1 <- idx.cat.Y1

                  lavcache[[g]]$idx.cat.Gy2 <- idx.cat.Gy2

                  lavcache[[g]]$id.uniPrGivObs <- sort(c(unique(lavm...@th.idx[[g]]),

                    lavm...@th.idx[[g]]))

                }

            }

        }

        if (lav...@data.type == "full" && !is.null(lavdata@Rp[[1L]])) {

            for (g in 1:lavdata@ngroups) {

                lavcache[[g]]$pat <- lavdata@Rp[[g]]$pat

            }

        }

    }

    if (lavoptions$estimator == "MML") {

        for (g in 1:lavdata@ngroups) {

            nfac <- lavpta$nfac[[g]]

            lavcache[[g]]$GH <- lav_integration_gauss_hermite(n = lavoptions$integration.ngh,

                dnorm = TRUE, mean = 0, sd = 1, ndim = nfac)

        }

    }

    timing$cache <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    x <- NULL

    if (lavoptions$do.fit && lavoptions$estimator != "none" &&

        lavm...@nx.free > 0L) {

        if (lavoptions$optim.method == "em") {

            stopifnot(lavdata@nlevels > 1L)

            x <- lav_mvnorm_cluster_em_h0(lavsamplestats = lavsamplestats,

                lavdata = lavdata, lavimplied = NULL, lavpartable = lavpartable,

                lavmodel = lavmodel, lavoptions = lavoptions,

                verbose = lavoptions$verbose, fx.tol = lavoptions$em.fx.tol,

                dx.tol = lavoptions$em.dx.tol, max.iter = lavoptions$em.iter.max)

        }

        else {

            x <- lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable,

                lavsamplestats = lavsamplestats, lavdata = lavdata,

                lavoptions = lavoptions, lavcache = lavcache)

        }

        if (!is.null(attr(x, "con.jac")))

            lavm...@con.jac <- attr(x, "con.jac")

        if (!is.null(attr(x, "con.lambda")))

            lavm...@con.lambda <- attr(x, "con.lambda")

        if ((.hasSlot(lavmodel, "nefa")) && (lavmodel@nefa >

            0L) && (lavoptions$rotation != "none")) {

            x.unrotated <- as.numeric(x)

            tmp <- lav_model_set_parameters(lavmodel, x = as.numeric(x))

            lavpartable$est.unrotated <- lav_model_get_parameters(lavmodel = tmp,

                type = "user", extra = TRUE)

            if (lavoptions$verbose) {

                cat("Rotating solution using rotation method =",

                  lavoptions$rotation, "... ")

            }

            lavmodel <- lav_model_efa_rotate(lavmodel = lavmodel,

                x.orig = as.numeric(x), lavoptions = lavoptions)

            if (lavoptions$verbose) {

                cat("done.\n")

            }

        }

        else {

            lavmodel <- lav_model_set_parameters(lavmodel, x = as.numeric(x))

        }

        lavpartable$est <- lav_model_get_parameters(lavmodel = lavmodel,

            type = "user", extra = TRUE)

        if (!attr(x, "converged") && lavoptions$warn) {

            warning("lavaan WARNING: the optimizer warns that a solution has NOT been found!")

        }

    }

    else {

        x <- numeric(0L)

        attr(x, "iterations") <- 0L

        attr(x, "converged") <- FALSE

        attr(x, "control") <- lavoptions$control

        attr(x, "fx") <- lav_model_objective(lavmodel = lavmodel,

            lavsamplestats = lavsamplestats, lavdata = lavdata,

            lavcache = lavcache)

        lavpartable$est <- lavpartable$start

    }

    if (lavoptions$optim.force.converged) {

        attr(x, "converged") <- TRUE

    }

    lavoptim <- list()

    x2 <- x

    attributes(x2) <- NULL

    lavoptim$x <- x2

    lavoptim$npar <- length(x)

    lavoptim$iterations <- attr(x, "iterations")

    lavoptim$converged <- attr(x, "converged")

    lavoptim$parscale <- attr(x, "parscale")

    fx.copy <- fx <- attr(x, "fx")

    attributes(fx) <- NULL

    lavoptim$fx <- fx

    lavoptim$fx.group <- attr(fx.copy, "fx.group")

    if (!is.null(attr(fx.copy, "logl.group"))) {

        lavoptim$logl.group <- attr(fx.copy, "logl.group")

        lavoptim$logl <- sum(lavoptim$logl.group)

    }

    else {

        lavoptim$logl.group <- as.numeric(NA)

        lavoptim$logl <- as.numeric(NA)

    }

    lavoptim$control <- attr(x, "control")

    timing$optim <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    lavimplied <- list()

    if (lavoptions$implied) {

        lavimplied <- lav_model_implied(lavmodel)

    }

    lavloglik <- list()

    if (lavoptions$loglik) {

        lavloglik <- lav_model_loglik(lavdata = lavdata, lavsamplestats = lavsamplestats,

            lavimplied = lavimplied, lavmodel = lavmodel, lavoptions = lavoptions)

    }

    timing$implied <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    VCOV <- NULL

    if (lavoptions$se != "none" && lavoptions$se != "external" &&

        lavoptions$se != "twostep" && lavm...@nx.free > 0L &&

        attr(x, "converged")) {

        if ((.hasSlot(lavmodel, "nefa")) && (lavmodel@nefa >

            0L) && (lavoptions$rotation != "none") && lavoptions$rotation.se ==

            "delta") {

            lavmodel2 <- lav_model_set_parameters(lavmodel, x = x.unrotated)

        }

        else {

            lavmodel2 <- lavmodel

        }

        if (lavoptions$verbose) {

            cat("Computing VCOV for se =", lavoptions$se, "...")

        }

        VCOV <- lav_model_vcov(lavmodel = lavmodel2, lavsamplestats = lavsamplestats,

            lavoptions = lavoptions, lavdata = lavdata, lavpartable = lavpartable,

            lavcache = lavcache, lavimplied = lavimplied, lavh1 = lavh1)

        if (lavoptions$verbose) {

            cat(" done.\n")

        }

        if ((.hasSlot(lavmodel, "nefa")) && (lavmodel@nefa >

            0L) && (lavoptions$rotation != "none") && (lavoptions$se !=

            "bootstrap") && (lavoptions$rotation.se == "delta")) {

            if (lavoptions$verbose) {

                cat("Using delta method to compute VCOV of rotated parameters:")

            }

            JAC <- numDeriv::jacobian(func = lav_model_efa_rotate_x,

                x = x.unrotated, lavmodel = lavmodel, init.rot = lavoptions$rotation.args$jac.init.rot,

                lavoptions = lavoptions, type = "free", extra = FALSE,

                method.args = list(eps = 0.001), method = "simple")

            VCOV <- JAC %*% VCOV %*% t(JAC)

            if (lavoptions$verbose) {

                cat(" done.\n")

            }

        }

    }

    if (!is.null(attr(VCOV, "BOOT.COEF"))) {

        lavboot <- list()

        lavboot$coef <- attr(VCOV, "BOOT.COEF")

   }

    else {

        lavboot <- list()

    }

    tmp.attr <- attributes(VCOV)

    VCOV1 <- VCOV

    attributes(VCOV1) <- tmp.attr["dim"]

    lavvcov <- list(se = lavoptions$se, information = lavoptions$information,

        vcov = VCOV1)

    if (lavoptions$se != "external" && lavoptions$se != "twostep") {

        lavpartable$se <- lav_model_vcov_se(lavmodel = lavmodel,

            lavpartable = lavpartable, VCOV = VCOV, BOOT = lavboot$coef)

    }

    else {

        if (is.null(lavpartable$se)) {

            lavpartable$se <- lav_model_vcov_se(lavmodel = lavmodel,

                lavpartable = lavpartable, VCOV = NULL, BOOT = NULL)

            warning("lavaan WARNING: se = \"external\" but parameter table does not contain a `se' column")

        }

    }

    timing$vcov <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    TEST <- NULL

    if (lavoptions$test != "none" && attr(x, "converged")) {

        if (lavoptions$verbose) {

            cat("Computing TEST for test =", lavoptions$test,

                "...")

        }

        TEST <- lav_model_test(lavmodel = lavmodel, lavpartable = lavpartable,

            lavsamplestats = lavsamplestats, lavimplied = lavimplied,

            lavh1 = lavh1, lavoptions = lavoptions, x = x, VCOV = VCOV,

            lavdata = lavdata, lavcache = lavcache, lavloglik = lavloglik)

        if (lavoptions$verbose) {

            cat(" done.\n")

        }

    }

    else {

        TEST <- list(list(test = "none", stat = NA, stat.group = rep(NA,

            lavdata@ngroups), df = NA, refdistr = "unknown",

            pvalue = NA))

    }

    lavtest <- TEST

    timing$test <- (proc.time()[3] - start.time)

    start.time <- proc.time()[3]

    lavfit <- lav_model_fit(lavpartable = lavpartable, lavmodel = lavmodel,

        x = x, VCOV = VCOV, TEST = TEST)

    timing$total <- (proc.time()[3] - start.time0)

    lavbaseline <- list()

    if (is.logical(lavoptions$baseline) && lavoptions$baseline) {

    }

    lavaan <- new("lavaan", version = as.character(packageVersion("lavaan")),

        call = mc, timing = timing, Options = lavoptions, ParTable = lavpartable,

        pta = lavpta, Data = lavdata, SampleStats = lavsamplestats,

        Model = lavmodel, Cache = lavcache, Fit = lavfit, boot = lavboot,

        optim = lavoptim, implied = lavimplied, loglik = lavloglik,

        vcov = lavvcov, test = lavtest, h1 = lavh1, baseline = list(),

        external = list())

    if (!is.null(lavoptions$check.post) && lavoptions$check.post &&

        lavTech(lavaan, "converged")) {

        lavInspect(lavaan, "post.check")

    }

    hasExplicitConstraints <- FALSE

    if (is.character(constraints) && any(nchar(constraints) >

        0L)) {

        hasExplicitConstraints <- TRUE

    }

    hasNonLinearEqConstraints <- FALSE

    if (length(lavm...@ceq.nonlinear.idx) > 0L) {

        hasNonLinearEqConstraints <- TRUE

    }

    hasIneqConstraints <- FALSE

    if (length(lavm...@cin.linear.idx) > 0L || length(lavm...@cin.nonlinear.idx) >

        0L) {

        hasIneqConstraints <- TRUE

    }

    if (!is.null(lavoptions$check.gradient) && lavoptions$check.gradient &&

        lavTech(lavaan, "converged") && !hasExplicitConstraints &&

        !hasNonLinearEqConstraints && !hasIneqConstraints) {

        grad <- lavInspect(lavaan, "optim.gradient")

        large.idx <- which(abs(grad) > 0.001)

        if (length(large.idx) > 0L) {

            warning("lavaan WARNING: not all elements of the gradient are (near) zero;\n",

                "                  the optimizer may not have found a local solution;\n",

                "                  use lavInspect(fit, \"optim.gradient\") to investigate")

        }

    }

    lavaan

}

<bytecode: 0x69f76f8>

<environment: namespace:lavaan>

> lavaan()

Error in lavaan() : lavaan ERROR: model is NULL!

> sessioninfo()

Error in sessioninfo() : could not find function "sessioninfo"

> sessionInfo()

R version 3.6.0 (2019-04-26)

Platform: x86_64-pc-linux-gnu (64-bit)

Running under: Ubuntu 18.04.2 LTS

 

Matrix products: default

BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3

LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

 

Random number generation:

RNG:     Mersenne-Twister

 Normal:  Inversion

 Sample:  Rounding

 

locale:

[1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8   

 [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C            

 [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C  

 

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods   base    

 

other attached packages:

[1] semPlot_1.1.1      haven_2.1.0        lavaanPlot_0.5.1   forcats_0.4.0      stringr_1.4.0    

 [6] dplyr_0.8.1        purrr_0.3.2        readr_1.3.1        tidyr_0.8.3        tibble_2.1.3     

[11] ggplot2_3.2.0      tidyverse_1.2.1    semTools_0.5-1.934 lavaan_0.6-5.1453  skimr_1.0.7      

 

loaded via a namespace (and not attached):

  [1] readxl_1.3.1        backports_1.1.4     Hmisc_4.2-0         BDgraph_2.59        plyr_1.8.4        

  [6] igraph_1.2.4.1      lazyeval_0.2.2      splines_3.6.0       usethis_1.5.0       digest_0.6.18     

 [11] htmltools_0.3.6     matrixcalc_1.0-3    viridis_0.5.1       magrittr_1.5        Rsolnp_1.16       

 [16] checkmate_1.9.3     memoise_1.1.0       lisrelToR_0.1.4     cluster_2.1.0       openxlsx_4.1.0.1  

 [21] remotes_2.0.2       modelr_0.1.4        prettyunits_1.0.2   jpeg_0.1-8          sem_3.1-9         

 [26] colorspace_1.4-1    rvest_0.3.4         xfun_0.8            callr_3.2.0         crayon_1.3.4      

 [31] jsonlite_1.6        lme4_1.1-21         regsem_1.3.9        brew_1.0-6          survival_2.44-1.1 

 [36] glue_1.3.1          gtable_0.3.0        mi_1.0              pkgbuild_1.0.3      Rook_1.1-1        

 [41] ggm_2.3             abind_1.4-5         scales_1.0.0        Rcpp_1.0.1          viridisLite_0.3.0 

 [46] xtable_1.8-3        htmlTable_1.13.1    foreign_0.8-71      Formula_1.2-3       stats4_3.6.0      

 [51] truncnorm_1.0-8     htmlwidgets_1.3     httr_1.4.0          DiagrammeR_1.0.1    RColorBrewer_1.1-2

 [56] acepack_1.4.1       pkgconfig_2.0.2     XML_3.98-1.20       nnet_7.3-12         kutils_1.69       

 [61] tidyselect_0.2.5    rlang_0.4.0         reshape2_1.4.3      munsell_0.5.0       cellranger_1.1.0  

 [66] tools_3.6.0         visNetwork_2.0.7    downloader_0.4      cli_1.1.0           generics_0.0.2    

 [71] devtools_2.0.2      broom_0.5.2         fdrtool_1.2.15      yaml_2.2.0          arm_1.10-1        

 [76] processx_3.3.1      knitr_1.22          fs_1.3.1            zip_2.0.2           glasso_1.10       

 [81] pbapply_1.4-0       nlme_3.1-140        whisker_0.3-2       xml2_1.2.0          compiler_3.6.0    

 [86] rstudioapi_0.10     curl_3.3            rgexf_0.15.3        png_0.1-7           testthat_2.1.1    

 [91] huge_1.3.2          pbivnorm_0.6.0      stringi_1.3.1       highr_0.8           ps_1.3.0           

 [96] qgraph_1.6.3        rockchalk_1.8.144   desc_1.2.0          lattice_0.20-38     Matrix_1.2-17     

[101] psych_1.8.12        nloptr_1.2.1        pillar_1.4.1        OpenMx_2.13.2       data.table_1.12.2 

[106] corpcor_1.6.9       R6_2.4.0            latticeExtra_0.6-28 gridExtra_2.3       sessioninfo_1.1.1 

[111] gtools_3.8.1        boot_1.3-22         MASS_7.3-51.4       assertthat_0.2.1    pkgload_1.0.2     

[116] rjson_0.2.20        rprojroot_1.3-2     withr_2.1.2         mnormt_1.5-5        parallel_3.6.0    

[121] hms_0.4.2           influenceR_0.1.0    grid_3.6.0          rpart_4.1-15        coda_0.19-2       

[126] minqa_1.2.4         carData_3.0-2       d3Network_0.5.2.1   lubridate_1.7.4     base64enc_0.1-3   

> ## compare several invariance models

>

> modinv = '

+ Cp =~ SE1 + SE2 + SE3 + SE4 + SE5

+ Em =~ SE6 + SE7 + SE8 + SE9 + SE10

+ Co =~ SE11 + SE12 + SE13 + SE14 + SE15

+ # fator de 2a ordem

+ #eng =~ Cp + Em + Co

+ '

>

> #install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source")

> #devtools::install_github("simsem/semTools/semTools")

> #bd1=subset(bd, Country %in% c("ZH", "PT"))

>

> grupo="Country"

> test.seq <-  c("thresholds","loadings","intercepts", "regressions", "means","residuals")

> meq.list <- list()

> for (i in 0L:length(test.seq)) {

+   if (i == 0L) {

+     meq.label <- "configural"

+     group.equal <- ""

+   } else {

+     meq.label <- test.seq[i]

+     group.equal <- test.seq[1:i]

+   }

+   meq.list[[meq.label]] <- measEq.syntax(configural.model = modinv,

+                                          data = bd,

+                                          ordered = it,

+                                          parameterization = "theta",

+                                          ID.fac = "ul",

+                                          ID.cat = "Wu",

+                                          group = grupo,

+                                          group.equal = group.equal,

+                                          return.fit = TRUE)

+   }

Warning messages:

1: In lavaan::lavaan(model = "## LOADINGS:\n\nCp =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE1 + c(lambda.1_1.g1, lambda.1_1.g2, lambda.1_1.g3, lambda.1_1.g4, lambda.1_1.g5, lambda.1_1.g6, lambda.1_1.g7, lambda.1_1.g8)*SE1\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE2 + c(lambda.2_1.g1, lambda.2_1.g2, lambda.2_1.g3, lambda.2_1.g4, lambda.2_1.g5, lambda.2_1.g6, lambda.2_1.g7, lambda.2_1.g8)*SE2\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE3 + c(lambda.3_1.g1, lambda.3_1.g2, lambda.3_1.g3, lambda.3_1.g4, lambda.3_1.g5, lambda.3_1.g6, lambda.3_1.g7, lambda.3_1.g8)*SE3\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE4 + c(lambda.4_1.g1, lambda.4_1.g2, lambda.4_1.g3, lambda.4_1.g4, lambda.4_1.g5, lambda.4_1.g6, lambda.4_1.g7, lambda.4_1.g8)*SE4\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE5 + c(lambda.5_1.g1, lambda.5_1.g2, lambda.5_1.g3, lambda.5_1.g4, lambda.5_1.g5, lambda.5_1.g6, lambda.5_1.g7, lambda.5_1.g8)*SE5\nEm =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE6 + c(lambda.6_2.g1, lambda.6_2.g2, lambda.6_2.g3, lambda.6_2.g4, lambda.6_2.g5, lambda.6_2.g6, lambda.6_2.g7, lambda.6_2.g8)*SE6\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE7 + c(lambda.7_2.g1, lambda.7_2.g2, lambda.7_2.g3, lambda.7_2.g4, lambda.7_2.g5, lambda.7_2.g6, lambda.7_2.g7, lambda.7_2.g8)*SE7\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE8 + c(lambda.8_2.g1, lambda.8_2.g2, lambda.8_2.g3, lambda.8_2.g4, lambda.8_2.g5, lambda.8_2.g6, lambda.8_2.g7, lambda.8_2.g8)*SE8\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE9 + c(lambda.9_2.g1, lambda.9_2.g2, lambda.9_2.g3, lambda.9_2.g4, lambda.9_2.g5, lambda.9_2.g6, lambda.9_2.g7, lambda.9_2.g8)*SE9\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE10 + c(lambda.10_2.g1, lambda.10_2.g2, lambda.10_2.g3, lambda.10_2.g4, lambda.10_2.g5, lambda.10_2.g6, lambda.10_2.g7, lambda.10_2.g8)*SE10\nCo =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE11 + c(lambda.11_3.g1, lambda.11_3.g2, lambda.11_3.g3, lambda.11_3.g4, lambda.11_3.g5, lambda.11_3.g6, lambda.11_3.g7, lambda.11_3.g8)*SE11\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE12 + c(lambda.12_3.g1, lambda.12_3.g2, lambda.12_3.g3, lambda.12_3.g4, lambda.12_3.g5, lambda.12_3.g6, lambda.12_3.g7, lambda.12_3.g8)*SE12\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE13 + c(lambda.13_3.g1, lambda.13_3.g2, lambda.13_3.g3, lambda.13_3.g4, lambda.13_3.g5, lambda.13_3.g6, lambda.13_3.g7, lambda.13_3.g8)*SE13\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE14 + c(lambda.14_3.g1, lambda.14_3.g2, lambda.14_3.g3, lambda.14_3.g4, lambda.14_3.g5, lambda.14_3.g6, lambda.14_3.g7, lambda.14_3.g8)*SE14\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE15 + c(lambda.15_3.g1, lambda.15_3.g2, lambda.15_3.g3, lambda.15_3.g4, lambda.15_3.g5, lambda.15_3.g6, lambda.15_3.g7, lambda.15_3.g8)*SE15\n\n## THRESHOLDS:\n\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE1.thr1.g1, SE1.thr1.g2, SE1.thr1.g3, SE1.thr1.g4, SE1.thr1.g5, SE1.thr1.g6, SE1.thr1.g7, SE1.thr1.g8)*t1\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE1.thr2.g1, SE1.thr2.g2, SE1.thr2.g3, SE1.thr2.g4, SE1.thr2.g5, SE1.thr2.g6, SE1.thr2.g7, SE1.thr2.g8)*t2\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE1.thr3.g1, SE1.thr3.g2, SE1.thr3.g3, SE1.thr3.g4, SE1.thr3.g5, SE1.thr3.g6, SE1.thr3.g7, SE1.thr3.g8)*t3\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE1.thr4.g1, SE1.thr4.g2, SE1.thr4.g3, SE1.thr4.g4, SE1.thr4.g5, SE1.thr4.g6, SE1.thr4.g7, SE1.thr4.g8)*t4\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE2.thr1.g1, SE2.thr1.g2, SE2.thr1.g3, SE2.thr1.g4, SE2.thr1.g5, SE2.thr1.g6, SE2.thr1.g7, SE2.thr1.g8)*t1\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE2.thr2.g1, SE2.thr2.g2, SE2.thr2.g3, SE2.thr2.g4, SE2.thr2.g5, SE2.thr2.g6, SE2.thr2.g7, SE2.thr2.g8)*t2\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE2.thr3.g1, SE2.thr3.g2, SE2.thr3.g3, SE2.thr3.g4, SE2.thr3.g5, SE2.thr3.g6, SE2.thr3.g7, SE2.thr3.g8)*t3\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE2.thr4.g1, SE2.thr4.g2, SE2.thr4.g3, SE2.thr4.g4, SE2.thr4.g5, SE2.thr4.g6, SE2.thr4.g7, SE2.thr4.g8)*t4\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE3.thr1.g1, SE3.thr1.g2, SE3.thr1.g3, SE3.thr1.g4, SE3.thr1.g5, SE3.thr1.g6, SE3.thr1.g7, SE3.thr1.g8)*t1\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE3.thr2.g1, SE3.thr2.g2, SE3.thr2.g3, SE3.thr2.g4, SE3.thr2.g5, SE3.thr2.g6, SE3.thr2.g7, SE3.thr2.g8)*t2\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE3.thr3.g1, SE3.thr3.g2, SE3.thr3.g3, SE3.thr3.g4, SE3.thr3.g5, SE3.thr3.g6, SE3.thr3.g7, SE3.thr3.g8)*t3\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE3.thr4.g1, SE3.thr4.g2, SE3.thr4.g3, SE3.thr4.g4, SE3.thr4.g5, SE3.thr4.g6, SE3.thr4.g7, SE3.thr4.g8)*t4\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE4.thr1.g1, SE4.thr1.g2, SE4.thr1.g3, SE4.thr1.g4, SE4.thr1.g5, SE4.thr1.g6, SE4.thr1.g7, SE4.thr1.g8)*t1\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE4.thr2.g1, SE4.thr2.g2, SE4.thr2.g3, SE4.thr2.g4, SE4.thr2.g5, SE4.thr2.g6, SE4.thr2.g7, SE4.thr2.g8)*t2\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE4.thr3.g1, SE4.thr3.g2, SE4.thr3.g3, SE4.thr3.g4, SE4.thr3.g5, SE4.thr3.g6, SE4.thr3.g7, SE4.thr3.g8)*t3\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE4.thr4.g1, SE4.thr4.g2, SE4.thr4.g3, SE4.thr4.g4, SE4.thr4.g5, SE4.thr4.g6, SE4.thr4.g7, SE4.thr4.g8)*t4\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE5.thr1.g1, SE5.thr1.g2, SE5.thr1.g3, SE5.thr1.g4, SE5.thr1.g5, SE5.thr1.g6, SE5.thr1.g7, SE5.thr1.g8)*t1\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE5.thr2.g1, SE5.thr2.g2, SE5.thr2.g3, SE5.thr2.g4, SE5.thr2.g5, SE5.thr2.g6, SE5.thr2.g7, SE5.thr2.g8)*t2\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE5.thr3.g1, SE5.thr3.g2, SE5.thr3.g3, SE5.thr3.g4, SE5.thr3.g5, SE5.thr3.g6, SE5.thr3.g7, SE5.thr3.g8)*t3\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE5.thr4.g1, SE5.thr4.g2, SE5.thr4.g3, SE5.thr4.g4, SE5.thr4.g5, SE5.thr4.g6, SE5.thr4.g7, SE5.thr4.g8)*t4\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE6.thr1.g1, SE6.thr1.g2, SE6.thr1.g3, SE6.thr1.g4, SE6.thr1.g5, SE6.thr1.g6, SE6.thr1.g7, SE6.thr1.g8)*t1\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE6.thr2.g1, SE6.thr2.g2, SE6.thr2.g3, SE6.thr2.g4, SE6.thr2.g5, SE6.thr2.g6, SE6.thr2.g7, SE6.thr2.g8)*t2\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE6.thr3.g1, SE6.thr3.g2, SE6.thr3.g3, SE6.thr3.g4, SE6.thr3.g5, SE6.thr3.g6, SE6.thr3.g7, SE6.thr3.g8)*t3\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE6.thr4.g1, SE6.thr4.g2, SE6.thr4.g3, SE6.thr4.g4, SE6.thr4.g5, SE6.thr4.g6, SE6.thr4.g7, SE6.thr4.g8)*t4\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE7.thr1.g1, SE7.thr1.g2, SE7.thr1.g3, SE7.thr1.g4, SE7.thr1.g5, SE7.thr1.g6, SE7.thr1.g7, SE7.thr1.g8)*t1\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE7.thr2.g1, SE7.thr2.g2, SE7.thr2.g3, SE7.thr2.g4, SE7.thr2.g5, SE7.thr2.g6, SE7.thr2.g7, SE7.thr2.g8)*t2\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE7.thr3.g1, SE7.thr3.g2, SE7.thr3.g3, SE7.thr3.g4, SE7.thr3.g5, SE7.thr3.g6, SE7.thr3.g7, SE7.thr3.g8)*t3\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE7.thr4.g1, SE7.thr4.g2, SE7.thr4.g3, SE7.thr4.g4, SE7.thr4.g5, SE7.thr4.g6, SE7.thr4.g7, SE7.thr4.g8)*t4\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE8.thr1.g1, SE8.thr1.g2, SE8.thr1.g3, SE8.thr1.g4, SE8.thr1.g5, SE8.thr1.g6, SE8.thr1.g7, SE8.thr1.g8)*t1\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE8.thr2.g1, SE8.thr2.g2, SE8.thr2.g3, SE8.thr2.g4, SE8.thr2.g5, SE8.thr2.g6, SE8.thr2.g7, SE8.thr2.g8)*t2\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE8.thr3.g1, SE8.thr3.g2, SE8.thr3.g3, SE8.thr3.g4, SE8.thr3.g5, SE8.thr3.g6, SE8.thr3.g7, SE8.thr3.g8)*t3\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE8.thr4.g1, SE8.thr4.g2, SE8.thr4.g3, SE8.thr4.g4, SE8.thr4.g5, SE8.thr4.g6, SE8.thr4.g7, SE8.thr4.g8)*t4\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE9.thr1.g1, SE9.thr1.g2, SE9.thr1.g3, SE9.thr1.g4, SE9.thr1.g5, SE9.thr1.g6, SE9.thr1.g7, SE9.thr1.g8)*t1\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE9.thr2.g1, SE9.thr2.g2, SE9.thr2.g3, SE9.thr2.g4, SE9.thr2.g5, SE9.thr2.g6, SE9.thr2.g7, SE9.thr2.g8)*t2\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE9.thr3.g1, SE9.thr3.g2, SE9.thr3.g3, SE9.thr3.g4, SE9.thr3.g5, SE9.thr3.g6, SE9.thr3.g7, SE9.thr3.g8)*t3\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE9.thr4.g1, SE9.thr4.g2,

  lavaan WARNING: the optimizer warns that a solution has NOT been found!

2: In lavaan::lavaan(model = "## LOADINGS:\n\nCp =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE1 + c(lambda.1_1.g1, lambda.1_1.g2, lambda.1_1.g3, lambda.1_1.g4, lambda.1_1.g5, lambda.1_1.g6, lambda.1_1.g7, lambda.1_1.g8)*SE1\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE2 + c(lambda.2_1.g1, lambda.2_1.g2, lambda.2_1.g3, lambda.2_1.g4, lambda.2_1.g5, lambda.2_1.g6, lambda.2_1.g7, lambda.2_1.g8)*SE2\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE3 + c(lambda.3_1.g1, lambda.3_1.g2, lambda.3_1.g3, lambda.3_1.g4, lambda.3_1.g5, lambda.3_1.g6, lambda.3_1.g7, lambda.3_1.g8)*SE3\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE4 + c(lambda.4_1.g1, lambda.4_1.g2, lambda.4_1.g3, lambda.4_1.g4, lambda.4_1.g5, lambda.4_1.g6, lambda.4_1.g7, lambda.4_1.g8)*SE4\nCp =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE5 + c(lambda.5_1.g1, lambda.5_1.g2, lambda.5_1.g3, lambda.5_1.g4, lambda.5_1.g5, lambda.5_1.g6, lambda.5_1.g7, lambda.5_1.g8)*SE5\nEm =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE6 + c(lambda.6_2.g1, lambda.6_2.g2, lambda.6_2.g3, lambda.6_2.g4, lambda.6_2.g5, lambda.6_2.g6, lambda.6_2.g7, lambda.6_2.g8)*SE6\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE7 + c(lambda.7_2.g1, lambda.7_2.g2, lambda.7_2.g3, lambda.7_2.g4, lambda.7_2.g5, lambda.7_2.g6, lambda.7_2.g7, lambda.7_2.g8)*SE7\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE8 + c(lambda.8_2.g1, lambda.8_2.g2, lambda.8_2.g3, lambda.8_2.g4, lambda.8_2.g5, lambda.8_2.g6, lambda.8_2.g7, lambda.8_2.g8)*SE8\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE9 + c(lambda.9_2.g1, lambda.9_2.g2, lambda.9_2.g3, lambda.9_2.g4, lambda.9_2.g5, lambda.9_2.g6, lambda.9_2.g7, lambda.9_2.g8)*SE9\nEm =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE10 + c(lambda.10_2.g1, lambda.10_2.g2, lambda.10_2.g3, lambda.10_2.g4, lambda.10_2.g5, lambda.10_2.g6, lambda.10_2.g7, lambda.10_2.g8)*SE10\nCo =~ c(1, 1, 1, 1, 1, 1, 1, 1)*SE11 + c(lambda.11_3.g1, lambda.11_3.g2, lambda.11_3.g3, lambda.11_3.g4, lambda.11_3.g5, lambda.11_3.g6, lambda.11_3.g7, lambda.11_3.g8)*SE11\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE12 + c(lambda.12_3.g1, lambda.12_3.g2, lambda.12_3.g3, lambda.12_3.g4, lambda.12_3.g5, lambda.12_3.g6, lambda.12_3.g7, lambda.12_3.g8)*SE12\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE13 + c(lambda.13_3.g1, lambda.13_3.g2, lambda.13_3.g3, lambda.13_3.g4, lambda.13_3.g5, lambda.13_3.g6, lambda.13_3.g7, lambda.13_3.g8)*SE13\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE14 + c(lambda.14_3.g1, lambda.14_3.g2, lambda.14_3.g3, lambda.14_3.g4, lambda.14_3.g5, lambda.14_3.g6, lambda.14_3.g7, lambda.14_3.g8)*SE14\nCo =~ c(NA, NA, NA, NA, NA, NA, NA, NA)*SE15 + c(lambda.15_3.g1, lambda.15_3.g2, lambda.15_3.g3, lambda.15_3.g4, lambda.15_3.g5, lambda.15_3.g6, lambda.15_3.g7, lambda.15_3.g8)*SE15\n\n## THRESHOLDS:\n\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE1.thr1, SE1.thr1, SE1.thr1, SE1.thr1, SE1.thr1, SE1.thr1, SE1.thr1, SE1.thr1)*t1\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE1.thr2, SE1.thr2, SE1.thr2, SE1.thr2, SE1.thr2, SE1.thr2, SE1.thr2, SE1.thr2)*t2\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE1.thr3, SE1.thr3, SE1.thr3, SE1.thr3, SE1.thr3, SE1.thr3, SE1.thr3, SE1.thr3)*t3\nSE1 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE1.thr4, SE1.thr4, SE1.thr4, SE1.thr4, SE1.thr4, SE1.thr4, SE1.thr4, SE1.thr4)*t4\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE2.thr1, SE2.thr1, SE2.thr1, SE2.thr1, SE2.thr1, SE2.thr1, SE2.thr1, SE2.thr1)*t1\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE2.thr2, SE2.thr2, SE2.thr2, SE2.thr2, SE2.thr2, SE2.thr2, SE2.thr2, SE2.thr2)*t2\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE2.thr3, SE2.thr3, SE2.thr3, SE2.thr3, SE2.thr3, SE2.thr3, SE2.thr3, SE2.thr3)*t3\nSE2 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE2.thr4, SE2.thr4, SE2.thr4, SE2.thr4, SE2.thr4, SE2.thr4, SE2.thr4, SE2.thr4)*t4\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE3.thr1, SE3.thr1, SE3.thr1, SE3.thr1, SE3.thr1, SE3.thr1, SE3.thr1, SE3.thr1)*t1\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE3.thr2, SE3.thr2, SE3.thr2, SE3.thr2, SE3.thr2, SE3.thr2, SE3.thr2, SE3.thr2)*t2\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE3.thr3, SE3.thr3, SE3.thr3, SE3.thr3, SE3.thr3, SE3.thr3, SE3.thr3, SE3.thr3)*t3\nSE3 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE3.thr4, SE3.thr4, SE3.thr4, SE3.thr4, SE3.thr4, SE3.thr4, SE3.thr4, SE3.thr4)*t4\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE4.thr1, SE4.thr1, SE4.thr1, SE4.thr1, SE4.thr1, SE4.thr1, SE4.thr1, SE4.thr1)*t1\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE4.thr2, SE4.thr2, SE4.thr2, SE4.thr2, SE4.thr2, SE4.thr2, SE4.thr2, SE4.thr2)*t2\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE4.thr3, SE4.thr3, SE4.thr3, SE4.thr3, SE4.thr3, SE4.thr3, SE4.thr3, SE4.thr3)*t3\nSE4 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE4.thr4, SE4.thr4, SE4.thr4, SE4.thr4, SE4.thr4, SE4.thr4, SE4.thr4, SE4.thr4)*t4\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE5.thr1, SE5.thr1, SE5.thr1, SE5.thr1, SE5.thr1, SE5.thr1, SE5.thr1, SE5.thr1)*t1\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE5.thr2, SE5.thr2, SE5.thr2, SE5.thr2, SE5.thr2, SE5.thr2, SE5.thr2, SE5.thr2)*t2\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE5.thr3, SE5.thr3, SE5.thr3, SE5.thr3, SE5.thr3, SE5.thr3, SE5.thr3, SE5.thr3)*t3\nSE5 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE5.thr4, SE5.thr4, SE5.thr4, SE5.thr4, SE5.thr4, SE5.thr4, SE5.thr4, SE5.thr4)*t4\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE6.thr1, SE6.thr1, SE6.thr1, SE6.thr1, SE6.thr1, SE6.thr1, SE6.thr1, SE6.thr1)*t1\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE6.thr2, SE6.thr2, SE6.thr2, SE6.thr2, SE6.thr2, SE6.thr2, SE6.thr2, SE6.thr2)*t2\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE6.thr3, SE6.thr3, SE6.thr3, SE6.thr3, SE6.thr3, SE6.thr3, SE6.thr3, SE6.thr3)*t3\nSE6 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE6.thr4, SE6.thr4, SE6.thr4, SE6.thr4, SE6.thr4, SE6.thr4, SE6.thr4, SE6.thr4)*t4\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE7.thr1, SE7.thr1, SE7.thr1, SE7.thr1, SE7.thr1, SE7.thr1, SE7.thr1, SE7.thr1)*t1\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE7.thr2, SE7.thr2, SE7.thr2, SE7.thr2, SE7.thr2, SE7.thr2, SE7.thr2, SE7.thr2)*t2\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE7.thr3, SE7.thr3, SE7.thr3, SE7.thr3, SE7.thr3, SE7.thr3, SE7.thr3, SE7.thr3)*t3\nSE7 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE7.thr4, SE7.thr4, SE7.thr4, SE7.thr4, SE7.thr4, SE7.thr4, SE7.thr4, SE7.thr4)*t4\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE8.thr1, SE8.thr1, SE8.thr1, SE8.thr1, SE8.thr1, SE8.thr1, SE8.thr1, SE8.thr1)*t1\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE8.thr2, SE8.thr2, SE8.thr2, SE8.thr2, SE8.thr2, SE8.thr2, SE8.thr2, SE8.thr2)*t2\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE8.thr3, SE8.thr3, SE8.thr3, SE8.thr3, SE8.thr3, SE8.thr3, SE8.thr3, SE8.thr3)*t3\nSE8 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE8.thr4, SE8.thr4, SE8.thr4, SE8.thr4, SE8.thr4, SE8.thr4, SE8.thr4, SE8.thr4)*t4\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE9.thr1, SE9.thr1, SE9.thr1, SE9.thr1, SE9.thr1, SE9.thr1, SE9.thr1, SE9.thr1)*t1\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE9.thr2, SE9.thr2, SE9.thr2, SE9.thr2, SE9.thr2, SE9.thr2, SE9.thr2, SE9.thr2)*t2\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE9.thr3, SE9.thr3, SE9.thr3, SE9.thr3, SE9.thr3, SE9.thr3, SE9.thr3, SE9.thr3)*t3\nSE9 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE9.thr4, SE9.thr4, SE9.thr4, SE9.thr4, SE9.thr4, SE9.thr4, SE9.thr4, SE9.thr4)*t4\nSE10 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE10.thr1, SE10.thr1, SE10.thr1, SE10.thr1, SE10.thr1, SE10.thr1, SE10.thr1, SE10.thr1)*t1\nSE10 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE10.thr2, SE10.thr2, SE10.thr2, SE10.thr2, SE10.thr2, SE10.thr2, SE10.thr2, SE10.thr2)*t2\nSE10 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t3 + c(SE10.thr3, SE10.thr3, SE10.thr3, SE10.thr3, SE10.thr3, SE10.thr3, SE10.thr3, SE10.thr3)*t3\nSE10 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t4 + c(SE10.thr4, SE10.thr4, SE10.thr4, SE10.thr4, SE10.thr4, SE10.thr4, SE10.thr4, SE10.thr4)*t4\nSE11 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t1 + c(SE11.thr1, SE11.thr1, SE11.thr1, SE11.thr1, SE11.thr1, SE11.thr1, SE11.thr1, SE11.thr1)*t1\nSE11 | c(NA, NA, NA, NA, NA, NA, NA, NA)*t2 + c(SE11.thr2, SE11.thr2, SE11.thr2,

  lavaan WARNING: the optimizer warns that a solution has NOT been found!

3: In lav_model_vcov(lavmodel = lavmodel2, lavsamplestats = lavsamplestats,  :

  lavaan WARNING:

    The variance-covariance matrix of the estimated parameters (vcov)

    does not appear to be positive definite! The smallest eigenvalue

    (= 1.079082e-13) is close to zero. This may be a symptom that the

    model is not identified.

 

And

 

> compareFit(meq.list)

Error in lav_fit_measures(object = object, fit.measures = fit.measures,  :

  lavaan ERROR: fit measures not available if model did not converge

 

 

I do get results if I remove the  “ordered = it,” option. But in that case, I am using ML estimation and not WLSMV on the categorical polychoric matrix, correct?

For the ML estimation (without the “ordered=it,” option, the thresholds and configural model are the same (since there are no thresholds) and I do get the warning that there are models with same df (the configural and thresholds models):

 

################### Nested Model Comparison #########################

Chi Square Difference Test

 

                       Df    AIC    BIC  Chisq Chisq diff Df diff Pr(>Chisq)   

meq.list.configural   696 119612 121933 1904.5                                 

meq.list.thresholds   696 119612 121933 1904.5       0.00       0              

meq.list.loadings     780 119667 121481 2127.9     223.46      84  1.325e-14 ***

meq.list.intercepts   864 120431 121737 3059.6     931.64      84  < 2.2e-16 ***

meq.list.regressions  878 120440 121661 3096.7      37.13      14  0.0007048 ***

meq.list.means        899 120886 121980 3584.7     487.98      21  < 2.2e-16 ***

meq.list.residuals   1004 121447 121906 4355.4     770.73     105  < 2.2e-16 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

 

####################### Model Fit Indices ###########################

                         chisq   df pvalue   cfi   tli         aic         bic rmsea  srmr

meq.list.configural  1904.485†  696   .000 .920† .904  119611.822† 121933.328  .067  .056†

meq.list.thresholds  1904.485†  696   .000 .920† .904  119611.822† 121933.328  .067  .056†

meq.list.loadings    2127.943   780   .000 .911  .904† 119667.281  121480.957† .067† .068

meq.list.intercepts  3059.580   864   .000 .855  .859  120430.917  121736.764  .081  .078

meq.list.regressions 3096.710   878   .000 .854  .860  120440.048  121661.257  .080  .081

meq.list.means       3584.692   899   .000 .823  .834  120886.029  121980.281  .088  .104

meq.list.residuals   4355.418  1004   .000 .779  .815  121446.755  121906.220  .093  .109

 

################## Differences in Fit Indices #######################

                                            df    cfi    tli     aic      bic rmsea  srmr

meq.list.thresholds - meq.list.configural    0  0.000  0.000   0.000    0.000 0.000 0.000

meq.list.loadings - meq.list.thresholds     84 -0.009  0.000  55.459 -452.371 0.000 0.013

meq.list.intercepts - meq.list.loadings     84 -0.056 -0.045 763.636  255.807 0.014 0.009

meq.list.regressions - meq.list.intercepts  14 -0.002  0.001   9.131  -75.507 0.000 0.004

meq.list.means - meq.list.regressions       21 -0.031 -0.026 445.981  319.024 0.007 0.023

meq.list.residuals - meq.list.means        105 -0.044 -0.019 560.726  -74.061 0.005 0.006

 

☹☹

 

João Marôco

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/53174768-66b6-4288-8b47-2889599ce460%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Terrence Jorgensen

unread,
Jul 6, 2019, 5:37:44 AM7/6/19
to lavaan

and I still get the same error:


Looks like a very different error to me:

Error in lav_fit_measures(object = object, fit.measures = fit.measures,  :

  lavaan ERROR: fit measures not available if model did not converge 


It looks like now you are trying to include invariance of the higher-order loadings (i.e., "regressions") and intercepts (i.e., "means"), but the higher-order factor was commented out in your model syntax. 

To narrow down which model fails to converge, do not loop blindly.  Instead, save the syntax for each model, and run each model one at a time, checking convergence, fit, etc.

If a test of nested models fails, you need to resolve the issue before proceeding to the next step anyway.  This is why I deprecated the old measurementInvariance() functions.

I do get results if I remove the  “ordered = it,” option. But in that case, I am using ML estimation and not WLSMV on the categorical polychoric matrix, correct?


Correct.

jpma...@gmail.com

unread,
Jul 6, 2019, 6:00:15 AM7/6/19
to lav...@googlegroups.com

Thanks Terrence,.
Yes, I did that (I left the 2nd order comment by mistake). The thresholds model does not converge.
I boiled the problem down to a few items in one of the countries were there are empty response categories. I think will proceed with MLR. The response format is 5-point likert, the loadings are a little smaller but still acceptable (hope the referees won't bother with the polychorics mambo - jambo :-)

One a diiferent note. Thanks you (and Yves) so much for putiing so much work and time answering the lavaan and semtools users questions. Really appreciate it.

Best,

João Marôco
[Sent from my not that smart smartphone, with more errors than usual]



-------- Original Message --------
From: Terrence Jorgensen <tjorge...@gmail.com>
Sent: Saturday, July 6, 2019 10:37 AM
To: lavaan <lav...@googlegroups.com>
Subject: Re: measurment invariance for categorical itens: "measurmentinvarianceCAT" vs measEQ.Syntax

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/6673a237-0eaa-4fee-80ed-a9cf8685ac31%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages