mxStandardizeRAMpaths(unRunModel, TRUE) gives a warning about the hessian instead of a warning that the model has not been run.
i.e.
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] 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)")
#1
I'll go one step further: there are at least three reasons why the hessian slot would be empty, so I'll add warnings that diagnose why it is, in fact, empty, if the reason can be discerned.Log in or register to post comments
#2
Log in or register to post comments
#3
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]
Warning message:
In mxStandardizeRAMpaths(factorModel, T) :
standard errors will not be computed because model 'One Factor' has not yet been run
Log in or register to post comments