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]
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
OK. Fair enough.
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
OK, revision 3931 changes the warning message to say that the model hasn't been run if that's the reason why the hessian slot is empty. I didn't add checks for other possible reasons for an empty hessian slot, though. I'd say this issue can be closed.
Log in or register to post comments
#3
great: thanks Rob!
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