mxEvaluate {OpenMx}R Documentation

Function To Evaluate MxModel Values


This function can be used to evaluate an arbitrary R expression that includes named entities from a MxModel object, or labels from a MxMatrix object.


mxEvaluate(expression, model, show = FALSE)


expression An arbitrary R expression.
model The model in which to evaluate the expression.
show If TRUE then print the translated expression.


The argument ‘expression’ is an arbitrary R expression. Any named entities that are used within the R expression are translated into their current value from the model. Any labels from the matrices within the model are translated into their current value from the model. Finally the expression is evaluated and the result is returned. To enable debugging, the ‘show’ argument has been provided. The most common mistake when using this function is to include named entities in the model that are identical to R function names. For example, if a model contains a named entity named ‘c’, then the following mxEvaluate call will return an error: mxEvaluate(c(A, B, C), model).


The OpenMx User's guide can be found at


matrixA <- mxMatrix("Full", nrow = 1, ncol = 1, 
        values = "1", name = "A")
algebraB <- mxAlgebra(A + A, name = "B")

model <- mxModel(matrixA, algebraB)
model <- mxRun(model)
start <- mxEvaluate(-pi * A, model)

## Not run: 
mxEvaluate(plot(sin, start, B * pi), model)

# The statement above is equivalent to:

plot(sin, -pi, 2 * pi)

## End(Not run)

[Package OpenMx version 0.1-1 Index]