## Revision of mxAlgebraObjective-help from Thu, 10/27/2011 - 11:23

The revisions let you track differences between multiple versions of a post.

Description:This function creates a new MxAlgebraObjective object.

Usage: mxAlgebraObjective(algebra, numObs = NA, numStats = NA)

Arguments:

1. `algebra`: A character string indicating the name of an MxAlgebra or MxMatrix object to use for optimization.
2. `numObs:` (optional) An adjustment to the total number of observations in the model.
3. `numStats:` (optional) An adjustment to the total number of observed statistics in the model.

Details: Objective functions are functions for which free parameter values are chosen such that the value of the objective function is minimized. While the other objective functions in OpenMx are packaged with a function to be optimized (i.e., maximum likelihood), the ‘mxAlgebraObjective’ function uses the referenced ‘MxAlgebra’ or ‘MxMatrix’ object as the function to be minimized.

If a model's primary objective function is a ‘mxAlgebraObjective’ objective function, then the referenced algebra in the objective function must return a 1 x 1 matrix (when using OpenMx's default optimizer). There is no restriction on the dimensions of an objective function that is not the primary, or ‘topmost’, objective function.

To evaluate an algebra objective function, place the following objects in a ‘MxModel’ object: a ‘MxAlgebraObjective’, ‘MxAlgebra’ and ‘MxMatrix’ entities referenced by the ‘MxAlgebraObjective’, and optional ‘MxBounds’ and ‘MxConstraint’ entities. This model may then be evaluated using the ‘mxRun’ function. The results of the optimization may be obtained using the ‘mxEval’ function on the name of the ‘MxAlgebra’, after the model has been run.

Value: Returns a new MxAlgebraObjective object. MxAlgebraObjective objects should be included with models with referenced ‘MxAlgebra’ and ‘MxMatrix’ objects.

Examples:

```# Create a matrix 'A' with no free parameters
A <- mxMatrix('Full', nrow = 1, ncol = 1, values = c(0), name = 'A')

# Create an algebra 'B', which defines the expression A + A
B <- mxAlgebra(A + A, name = 'B')

# Define the objective function for algebra 'B'
objective <- mxAlgebraObjective('B')

# Place the algebra, its associated matrix and its objective function in a model
model <- mxModel(A, B, objective)

# Evalulate the algebra
modelRun <- mxRun(model)

# View the results
modelRun@output```