working example for mxConstraint

Hi,
the example for mxConstraint currently does not demonstrate a constraint in action. Trying to make a minimal model that shows the constraint working, I tried this, but it does not leave K>Z, as desired. If someone can point out the change needed to get a minimal constraint model working, I'll push up some new R help.

# Constrain A to be equal to B
constraint <- mxConstraint('A', '=', 'B', name = 'constraint')

# Constrain a matrix of free parameters 'K' to be greater than Fixed matrix 'Z'

K <- mxMatrix(type="Full", nrow=2, ncol=2, free=TRUE, name="K")
Z <- mxMatrix(type="Full", nrow=2, ncol=2, free=FALSE,name="Z", values=1:4)
KbiggerthanZ <- mxConstraint("K", ">", "Z")
model<- mxModel("con_test", KbiggerthanZ, K,Z)
fit <- mxRun(model)
mxEval(K, fit)
[,1] [,2]
[1,] 0 0
[2,] 0 0

The model needs an objective function.

duh... will submit this

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")
)
fit <- mxRun(model)
fit@matrices$K@values
# [,1] [,2]
# [1,] 1 3
# [2,] 2 4

Added dontrun statement around mxRun() call in example. Issue fixed.

Automatically closed -- issue fixed for 2 weeks with no activity.