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.
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
#1
Log in or register to post comments
#2
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
Log in or register to post comments
#3
Log in or register to post comments
#4
Log in or register to post comments