From b1f6c3e10e111234797b082e25399bb020d4dd70 Mon Sep 17 00:00:00 2001 From: Yves Rosseel Date: Tue, 22 Oct 2024 17:17:39 +0200 Subject: [PATCH] [SAM] if orthogonal = TRUE, given warning (if sam.method = "local") and switch to global SAM --- DESCRIPTION | 2 +- R/lav_syntax_parser_r.R | 6 +++--- R/xxx_sam.R | 11 +++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4fe7f844..5243371f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: lavaan Title: Latent Variable Analysis -Version: 0.6-20.2218 +Version: 0.6-20.2219 Authors@R: c(person(given = "Yves", family = "Rosseel", role = c("aut", "cre"), email = "Yves.Rosseel@UGent.be", diff --git a/R/lav_syntax_parser_r.R b/R/lav_syntax_parser_r.R index 0e35637d..449e7e10 100644 --- a/R/lav_syntax_parser_r.R +++ b/R/lav_syntax_parser_r.R @@ -35,7 +35,7 @@ lav_local_msgcode <- function(isError, msgcode, msgpos, msgenv) { assign("error", c(msgcode, msgpos), msgenv) } else { wrnnum <- 1L + get0("warncount", envir = msgenv, ifnotfound = 0L) - assign(paste0("warn", sprintf("%03d", wrnnum)), + assign(paste0("warn", sprintf("%03d", wrnnum)), c(msgcode, msgpos - 1L), msgenv) # msgpos - 1L to align with C assign("warncount", wrnnum, msgenv) } @@ -1042,9 +1042,9 @@ lav_parse_model_string_r <- function(model.syntax = "", as.data.frame. = FALSE) warns <- list(); warncount <- get("warncount", envir = msgenv) for (jj in seq.int(warncount)) { - warns = c(warns, + warns = c(warns, list(get(paste0("warn", sprintf("%03d", jj)), envir = msgenv))) - } + } attr(flat, "warns") <- warns } attr(flat, "modifiers") <- mod diff --git a/R/xxx_sam.R b/R/xxx_sam.R index b44bcb5a..a2cdc564 100644 --- a/R/xxx_sam.R +++ b/R/xxx_sam.R @@ -118,6 +118,7 @@ sam <- function(model = NULL, "se= argument must be twostep, bootstrap, naive, standard or none.")) } + # check conditional.x= argument if (!is.null(dotdotdot$conditional.x)) { lav_msg_warn(gettext( "sam() does not support conditional.x = TRUE (yet) -> switching to @@ -125,6 +126,16 @@ sam <- function(model = NULL, dotdotdot$conditional.x <- FALSE } + # check orthogonal= argument + if (!is.null(dotdotdot$orthogonal) && + dotdotdot$orthogonal && + sam.method == "local") { + lav_msg_warn(gettext( + "local sam does not support orthogonal = TRUE -> switching to + global sam")) + sam.method <- "global" + } + ############################################### # STEP 0: process full model, without fitting # ###############################################