Copyright © 2007-2024 The OpenMx Project
mxStandardizeRAMpaths(unRunModel, TRUE) gives a warning about the hessian instead of a warning that the model has not been run.
i.e.
manifests <- names(demoOneFactor) latents <- c("G") factorModel <- mxModel("One Factor", type="RAM", manifestVars = manifests, latentVars = latents, mxPath(from=latents, to=manifests), mxPath(from=manifests, arrows=2), mxPath(from=latents, arrows=2, free=FALSE, values=1.0), mxData(cov(demoOneFactor), type="cov", numObs=500) ) > mxStandardizeRAMpaths(factorModel,T) Loading required package: numDeriv name label matrix row col Raw.Value Raw.SE Std.Value Std.SE 1 One Factor.S[6,6] <NA> S G G 1 not requested 1 not requested Warning message: In mxStandardizeRAMpaths(factorModel, T) : argument 'SE=TRUE' requires model to have a nonempty 'hessian' output slot; continuing with 'SE' coerced to ‘FALSE’
The user might try things like mxOption(factorModel, key="Calculate Hessian"), instead of running the model.
Perhaps
obj_as_str<- function(x) { deparse(substitute(x)) } if (model@.wasRun == FALSE){ stop("Nothing to standardize util you run the model: \n", paste0(obj_as_str(model), '_run') , " <- mxRun(", obj_as_str(model), ")\n mxStandardizeRAMpaths(", paste0(obj_as_str(model), "_run"), ", SE=TRUE)")