mxConstraint {OpenMx} | R Documentation |

## Create MxConstraint Object

### Description

This function creates a new MxConstraint object.

### Usage

mxConstraint(expression, name = NA)

### Arguments

`expression` |
An R expression of matrix operators and matrix functions. |

`name` |
An optional character string indicating the name of the object. |

### Details

The mxConstraint function defines relationships between two MxAlgebra or MxMatrix objects. They are used to affect the estimation of free parameters in the referenced objects. The constraint relation is written identically to how a MxAlgebra expression would be written. The outermost operator in this relation must be either ‘<’, ‘==’ or ‘>’. To affect an estimation or optimization, an MxConstraint object must be included in an MxModel object with all referenced MxAlgebra and MxMatrix objects.

The mxConstraint function should not be used to constrain free parameters, either by name or by their position in an MxMatrix or MxAlgebra object. Free parameters in the same MxModel are constrained to equality by giving them the same name in their respective 'labels' matrices.

### Value

Returns an MxConstraint object. If used as an argument in an MxModel object, the objects referenced in the 'alg1' and 'alg2' arguments must also be included prior to optimization.

### References

The OpenMx User's guide can be found at http://openmx.psyc.virginia.edu/documentation.

### See Also

MxConstraint for the S4 class created by mxConstraint. MxAlgebra and MxMatrix for objects which may be entered as arguments in the 'alg' and 'alg2' arguments, and mxAlgebra and mxMatrix for the functions that create them. More information about the OpenMx package may be found here.

### Examples

#Create a constraint between MxMatrices 'A' and 'B'
constraint <- mxConstraint(A > B, name = 'AdominatesB')
# Constrain a matrix of free parameters 'K' to be equal to matrix 'limit'
K <- mxMatrix(type="Full", nrow=2, ncol=2, free=TRUE, name="K")
limit <- mxMatrix(type="Full", nrow=2, ncol=2, free=FALSE, name="limit", values=1:4)
model<- mxModel("con_test", K, limit,
mxConstraint(K == limit, name = "Klimit_equality"),
mxAlgebra(min(K), name="minK"),
mxAlgebraObjective("minK")
)
## Not run:
fit <- mxRun(model)
fit@matrices$K@values
## End(Not run)
# [,1] [,2]
# [1,] 1 3
# [2,] 2 4

[Package

*OpenMx* version 1.0.0-1448

Index]