diff --git a/DESCRIPTION b/DESCRIPTION index 36d2d91..013e07c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: metaSEM Type: Package Title: Meta-Analysis using Structural Equation Modeling Version: 1.4.0 -Date: 2024-04-08 +Date: 2024-05-15 Depends: R (>= 3.4.0), OpenMx Imports: Matrix, MASS, ellipse, graphics, stats, utils, mvtnorm, numDeriv, lavaan Suggests: metafor, semPlot, R.rsp, testthat, matrixcalc diff --git a/NEWS b/NEWS index ef3b89c..55ee577 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,12 @@ -Release 1.4.0 (Apr 8, 2024) +Release 1.4.0 (May 15, 2024) ==================================== +* Release to CRAN. * Revise create.mxModel(). * Replace dontrun with donttest. Release 1.3.1 (Aug 8, 2023) ==================================== +* Release to CRAN. * Lower the tolerance in testing asyCov(), which returns an error in latest R. Release 1.3.0 (Jan 7, 2023) diff --git a/R/create.mxModel.R b/R/create.mxModel.R index 67a55e5..9f90bd2 100644 --- a/R/create.mxModel.R +++ b/R/create.mxModel.R @@ -173,22 +173,25 @@ create.mxModel <- function(model.name="mxModel", RAM=NULL, data=NULL, } } - if (run==FALSE) return(mx.model) + if (run) { - ## Default is z - mx.fit <- tryCatch(mxRun(mx.model, intervals=(intervals.type=="LB"), - suppressWarnings=TRUE, silent=TRUE, ...), - error=function(e) e) - - ## Check if any errors - if (inherits(mx.fit, "error")) { - mx.fit <- mxTryHard(mx.model, extraTries=50, intervals=FALSE, silent=TRUE) - mx.fit <- tryCatch(mxRun(mx.fit, intervals=(intervals.type=="LB"), + ## Default is z + mx.fit <- tryCatch(mxRun(mx.model, intervals=(intervals.type=="LB"), suppressWarnings=TRUE, silent=TRUE, ...), error=function(e) e) - if (inherits(mx.fit, "error")) { - warning("Error in running mxModel.\n") + + ## Check if any errors + if (inherits(mx.fit, "error")) { + mx.fit <- mxTryHard(mx.model, extraTries=50, intervals=FALSE, silent=TRUE) + mx.fit <- tryCatch(mxRun(mx.fit, intervals=(intervals.type=="LB"), + suppressWarnings=TRUE, silent=TRUE, ...), + error=function(e) e) + if (inherits(mx.fit, "error")) { + warning("Error in running mxModel.\n") + } } + } else { + mx.fit <- mx.model } out <- list(mx.fit=mx.fit, RAM=RAM, data=data, mxalgebras=mxalgebras.ci, diff --git a/R/meta2semPlot.R b/R/meta2semPlot.R index 053c36a..7944b19 100644 --- a/R/meta2semPlot.R +++ b/R/meta2semPlot.R @@ -161,8 +161,8 @@ plot.osmasem <- function(x, manNames=NULL, latNames=NULL, labels=c("labels", "RA labels <- match.arg(labels) if (labels=="labels") { - A.labels <- x$mx.model$A0$labels - S.labels <- x$mx.model$S0$labels + A.labels <- x$mx.fit$A0$labels + S.labels <- x$mx.fit$S0$labels labels <- c(c(A.labels), c(S.labels)) row.pars <- as.numeric(row.names(out@Pars)) out@Pars$label <- labels[row.pars] diff --git a/R/osmasem.R b/R/osmasem.R index b570e4c..f7ddff2 100644 --- a/R/osmasem.R +++ b/R/osmasem.R @@ -512,14 +512,13 @@ osmasem <- function(model.name="osmasem", RAM=NULL, Mmatrix=NULL, ## Assign same starting values, e.g., A and S matrices are different from those in provided in Jmatrix mx.model <- omxAssignFirstParameters(mx.model) - ## Return mx model without running the analysis - if (run==FALSE) { - return(mx.model) - } else { + if (run) { mx.fit <- tryCatch(do.call(mxRun, c(list(mx.model, intervals=intervals, suppressWarnings=suppressWarnings, silent=silent), mxRun.Args)), error = function(e) e) + } else { + mx.fit <- mx.model } # try to run it with error message as output @@ -538,7 +537,8 @@ osmasem <- function(model.name="osmasem", RAM=NULL, Mmatrix=NULL, mxRun.Args=mxRun.Args, subset.variables=subset.variables, subset.rows=subset.rows, - mx.model=mx.model, mx.fit=mx.fit) + #mx.model=mx.model, + mx.fit=mx.fit) class(out) <- 'osmasem' out } diff --git a/man/Cheung09.Rd b/man/Cheung09.Rd index 5777a97..b06872d 100644 --- a/man/Cheung09.Rd +++ b/man/Cheung09.Rd @@ -16,8 +16,6 @@ A list of data with the following structure: \item{n}{A vector of sample sizes} } } -\source{Cheung, M. W.-L. (2009). TSSEM: A LISREL syntax generator for two-stage structural equation modeling (Version 1.11) [Computer software]. Retrieved from \url{http://courses.nus.edu.sg/course/psycwlm/internet/tssem.zip}. -} \references{ Cheung, M. W.-L., & Chan, W. (2005). Meta-analytic structural equation modeling: A two-stage approach. \emph{Psychological Methods}, \bold{10}, 40-64. diff --git a/man/metaSEM-package.Rd b/man/metaSEM-package.Rd index 6eb82c1..eee3cbc 100644 --- a/man/metaSEM-package.Rd +++ b/man/metaSEM-package.Rd @@ -15,7 +15,7 @@ Package: \tab metaSEM\cr Type: \tab Package\cr Version: \tab 1.4.0\cr -Date: \tab 2024-04-08\cr +Date: \tab 2024-05-15\cr License: \tab GPL (>=2)\cr LazyLoad: \tab yes\cr } diff --git a/man/tssem1.Rd b/man/tssem1.Rd index 6785135..2829399 100644 --- a/man/tssem1.Rd +++ b/man/tssem1.Rd @@ -41,8 +41,8 @@ tssem1REM(Cov, n, cor.analysis=TRUE, RE.type=c("Diag", "Symm", "Zero","User"), } \item{RE.type}{Either \code{"Diag"}, \code{"Symm"}, \code{"Zero"} or \code{"User"}. If it is - \code{"Diag"}, a diagonal matrix is used for the random effects - meaning that the random effects are independent. If it is \code{"Symm"} (default if missing), a + \code{"Diag"} (default if missing), a diagonal matrix is used for the random effects + meaning that the random effects are independent. If it is \code{"Symm"}, a symmetric matrix is used for the random effects on the covariances among the correlation (or covariance) vectors. If it is \code{"Zero"}, there is no random effects which is similar to the diff --git a/vignettes/Examples.html b/vignettes/Examples.html index df9c829..4ddfdd1 100644 --- a/vignettes/Examples.html +++ b/vignettes/Examples.html @@ -14,11 +14,24 @@