Skip to content

Commit

Permalink
Merge pull request #365 from TDJorgensen/master
Browse files Browse the repository at this point in the history
fix scaled.test= issue reported by Njal
  • Loading branch information
yrosseel authored Jun 28, 2024
2 parents 65d1a5c + fd8d918 commit 73ecb27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions R/lav_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,14 @@ lav_options_set <- function(opt = NULL) { # nolint
opt$test <- unique(c(opt$scaled.test, opt$test))
}

# make sure "standard" comes first
# where does "standard" appear in the opt$test vector?
standard.idx <- which(opt$test == "standard")[1]
if (length(standard.idx) > 0L && standard.idx != 1L) {
if (is.na(standard.idx)) {
# "standard" is not in the opt$test vector at all,
# so add it
opt$test <- c("standard", opt$test)
} else if (length(standard.idx) > 0L && standard.idx != 1L) {
# make sure "standard" comes first
opt$test <- c("standard", opt$test[-standard.idx])
}
}
Expand Down
3 changes: 2 additions & 1 deletion R/lav_test_satorra_bentler.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ lav_test_satorra_bentler <- function(lavobject = NULL,
# scaling factor
fg <- unlist(lavsamplestats@nobs) / lavsamplestats@ntotal
a <- sqrt(df.scaled / trace.UGamma2)
if (isTRUE(a < 0) || is.nan(a)) a <- as.numeric(NA)
scaling.factor <- 1 / a
if (scaling.factor < 0) scaling.factor <- as.numeric(NA)
if (isTRUE(scaling.factor < 0)) scaling.factor <- as.numeric(NA)

if (ug2.old.approach) {
# scaling factor
Expand Down

0 comments on commit 73ecb27

Please sign in to comment.