Wiki home pagePlease add material here as you learn...
The job of mxRun() is to send a Model to the Optimizer, which will optimize the model, i.e. will seek out values for all the free parameters in your model which maximise the likelihood of an objective function (which you also have to provide)
You call mxRun as follows:
mxRun(model)
where "model" is an mxModel object to be optimized. After it has run, mxRun returns a model, with the free parameters now set to their optimized values, and an "@output" component or "slot" with the results of the optimization.
Unlike much some other functions and packages you may be used to in R, OpenMx package separates the process of assembling your model and submodels from the the process of running the model. Imagine that instead of saying
lm(x~y, data=mydata)
you said
myModel <- lmModel(lmFormula(x~y), lmData(mydata), lmMethod="qr") lmRun(myModel)
And you get the idea somewhat. . This lets you define a model without running it, and define sub-models which can be assembled into a supermodel before being run.
# Create a model that includes data, matrices A, S and F, and an objective function
data <- mxData(mydata, type="cov", numObs = 100) objective <- mxRAMObjective('A', 'S', 'F') model <- mxModel("mymodel", A, S, F, data, objective)
# Use mxRun to optimize the free parameters in the matrices A and S
model <- mxRun(model)
#print the output
summary(model) model@output
While OpenMx does a valiant job at error-checking the components of a model as they are created, much of the validity of a model cannot be assessed until it is run. Problems in your model which mxRun may highlight include: