mxConstraint {OpenMx}R Documentation

Create MxConstraint Object

Description

This function creates a new MxConstraint object.

Usage

mxConstraint(alg1, relation, alg2, name = NA)

Arguments

alg1 A character string indicating the name of an MxAlgebra or MxMatrix object, whose relationship to the object specified in the 'alg2' argument is constrained.
relation A character string indicating the relation between 'alg1' and 'alg2'. Must be either "<", "=", or ">".
alg2 A character string indicating the name of an MxAlgebra or MxMatrix object, whose relationship to the object specified in the 'alg1' argument is constrained.
name An optional character string indicating the name of this 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 relationships "<", "=" and ">" are supported. 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 may 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 may be constrained to equality by giving them the same name in their respective 'spec' 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 = 'constraint')

# 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"), 
	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 0.2.9-1147 Index]