mxRun {OpenMx}R Documentation

Send a Model to the Optimizer


This function begins optimization on the top-level model.


mxRun(model, ..., intervals = NULL, silent = FALSE, suppressWarnings = FALSE, 
    unsafe = FALSE, checkpoint = FALSE, useSocket = FALSE, onlyFrontend = FALSE, 
    useOptimizer = TRUE)



A MxModel object to be optimized.


Not used. Forces remaining arguments to be specified by name.


A boolean indicating whether to compute the specified confidence intervals.


A boolean indicating whether to print status to terminal.


A boolean indicating whether to suppress warnings.


A boolean indicating whether to ignore errors.


A boolean indicating whether to periodically write parameter values to a file.


A boolean indicating whether to periodically write parameter values to a socket.


A boolean indicating whether to run only front-end model transformations.


A boolean indicating whether to run only the log-likelihood of the current free parameter values but not move any of the free parameters.


The mxRun function is used to optimize free parameters in MxModel objects based on an expectation function and fit function. MxModel objects included in the mxRun function must include an appropriate expectation and fit functions.

If the ‘silent’ flag is TRUE, then model execution will not print any status messages to the terminal.

If the ‘suppressWarnings’ flag is TRUE, then model execution will not issue a warning if NPSOL returns a non-zero status code.

If the ‘unsafe’ flag is TRUE, then any error conditions will throw a warning instead of an error. It is strongly recommended to use this feature only for debugging purposes.

Free parameters are estimated or updated based on the expectation and fit functions. These estimated values, along with estimation information and model fit, can be found in the 'output' slot of MxModel objects after mxRun has been used.

If a model is dependent on or shares parameters with another model, both models must be included as arguments in another MxModel object. This top-level MxModel object must include expectation and fit functions in both submodels, as well as an additional fit function describing how the results of the first two should be combined.


Returns an MxModel object with free parameters updated to their final values. The return value contains an "output" slot with the results of optimization.


The OpenMx User's guide can be found at


# Create and run the 1-factor CFA on the front page


data(demoOneFactor)  # load the demoOneFactor dataframe

manifests <- names(demoOneFactor) # set the manifest to the 5 demo variables
latents   <- c("G")  # define 1 latent variable
model <- mxModel(model="One Factor", type="RAM",
    manifestVars = manifests,
    latentVars   = latents,
    mxPath(from=latents, to=manifests, labels=paste("b", 1:5, sep="")),
    mxPath(from=manifests, arrows=2, labels=paste("u", 1:5, sep="")),
    mxPath(from=latents  , arrows=2, free=FALSE, values=1.0),
    mxData(cov(demoOneFactor), type="cov", numObs=500)
model <- mxRun(model) # Run the model, returning the result into model
summary(model) # Show summary of the fitted model

[Package OpenMx version 2.6.8 Index]