Skip to content

Commit

Permalink
fix optim.method = "bfgs" issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yrosseel committed Aug 5, 2024
1 parent a6bc2a5 commit 6606f50
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lavaan
Title: Latent Variable Analysis
Version: 0.6-19.2170
Version: 0.6-19.2180
Authors@R: c(person(given = "Yves", family = "Rosseel",
role = c("aut", "cre"),
email = "Yves.Rosseel@UGent.be",
Expand Down
6 changes: 3 additions & 3 deletions R/lav_model_estimate.R
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ lav_model_estimate <- function(lavmodel = NULL,
OPTIMIZER <- toupper(lavoptions$optim.method)
stopifnot(OPTIMIZER %in% c(
"NLMINB0", "NLMINB1", "NLMINB2",
"NLMINB", "BFGS", "L-BFGS-B", "NONE"
"NLMINB", "BFGS", "L.BFGS.B", "NONE"
))
if (OPTIMIZER == "NLMINB1") {
OPTIMIZER <- "NLMINB"
Expand Down Expand Up @@ -760,7 +760,7 @@ lav_model_estimate <- function(lavmodel = NULL,
} else {
converged <- FALSE
}
} else if (OPTIMIZER == "L-BFGS-B") {
} else if (OPTIMIZER == "L.BFGS.B") {
# warning, does not cope with Inf values!!

control.lbfgsb <- list(
Expand Down Expand Up @@ -938,7 +938,7 @@ lav_model_estimate <- function(lavmodel = NULL,
if (converged) {
# check.gradient
if (!is.null(GRADIENT) &&
OPTIMIZER %in% c("NLMINB", "BFGS", "L-BFGS-B")) {
OPTIMIZER %in% c("NLMINB", "BFGS", "L.BFGS.B")) {
# compute unscaled gradient
dx <- GRADIENT(x)

Expand Down
3 changes: 2 additions & 1 deletion R/lav_options_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ lav_options_default <- function() {
# optimization
elm("control", list(), oklen = c(0L, 100L))
elm("optim.method", "default", chr = c(
"nlminb", "gn", "default", "noniter", "none", "em"
"nlminb", "nlminb0", "nlminb1", "nlminb2",
"bfgs", "l.bfgs.b", "gn", "default", "noniter", "none", "em"
)) # gn for DLS, nlminb rest
elm("optim.attempts", 4L, nm = "[1, 4]")
elm("optim.force.converged", FALSE, bl = TRUE)
Expand Down

0 comments on commit 6606f50

Please sign in to comment.