build_constraints {cgaim} | R Documentation |
Build a constraint matrix from common simple constraints. Internally used
by g
to construct index-specific constraint matrices.
build_constraints(p, first = 0, sign = 0, monotone = 0, convex = 0)
p |
The number of variables. |
first |
Indicates sign constraint for first coefficient. Recommended for identifiability if no other constraint is passed. |
sign |
Sign constraint applied to all coefficients. |
monotone |
Monotonicity constraint. |
convex |
Convexity constraint. |
For monotonicity and convexity / concavity, the function assumes the coefficients are ordered. For instance, for increasing monotone coefficients, the first one will be lower than the second, which be lower than the third and so on.
The function automatically removes redundant constraints. For instance,
if both sign = 1
and monotone = 1
, then only the sign
constraint on the first variable is kept as others are not needed.
Note that, for all arguments, any number can be passed to the function. In
which case, the sign of the argument is used. Therefore passing
monotone = 3.14
is the same as passing monotone = 1
.
A p-column constraint matrix.
# By default, produces only the identifiability constraint
build_constraints(4)
# Positive and increasing coefficients
build_constraints(4, sign = 1, monotone = 1)
# Concavity constraint
build_constraints(7, convex = -1)
# Any numeric can be passed to the function
build_constraints(5, monotone = pi)