checkCmat | R Documentation |
Checks a constraint matrix does not contains redundant rows
checkCmat(Cmat)
Cmat |
A constraint matrix as passed to |
The user typically doesn't need to use checkCmat
as it is internally called by cirls.control()
. However, it might be useful to undertsand if Cmat
can be reduced for inference purpose. See the note in confint.cirls()
.
A constraint matrix is irreducible if no row can be expressed as a positive linear combination of the other rows. When it happens, it means the constraint is actually implicitly included in other constraints in the matrix and can be dropped. Note that this a less restrictive condition than the constraint matrix having full row rank (see some examples).
The function starts by checking if some constraints are redundant and, if so, checks if they underline equality constraints. In the latter case, the constraint matrix can be reduced by expressing these constraints as a single equality constraint with identical lower and upper bounds (see cirls.fit()
).
The function also checks whether there are "zero constraints" i.e. constraints with only zeros in Cmat
in which case they will be labelled as redundant.
A list with three elements:
redundant |
Logical vector of indicating redundant constraints |
equality |
Logical vector indicating which constraints are part of an underlying equality constraint |
Meyer, M.C., 1999. An extension of the mixed primal–dual bases algorithm to the case of more constraints than dimensions. Journal of Statistical Planning and Inference 81, 13–31. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0378-3758(99)00025-7")}
confint.cirls()
###################################################
# Example of reducible matrix
# Constraints: successive coefficients should increase and be convex
p <- 5
cmatic <- rbind(diff(diag(p)), diff(diag(p), diff = 2))
# Checking indicates that constraints 2 to 4 are redundant.
# Intuitively, if the first two coefficients increase,
# then convexity forces the rest to increase
checkCmat(cmatic)
# Check without contraints
checkCmat(cmatic[-(2:4),])
###################################################
# Example of irreducible matrix
# Constraints: coefficients form an S-shape
p <- 4
cmats <- rbind(
diag(p)[1,], # positive
diff(diag(p))[c(1, p - 1),], # Increasing at both end
diff(diag(p), diff = 2)[1:(p/2 - 1),], # First half convex
-diff(diag(p), diff = 2)[(p/2):(p-2),] # second half concave
)
# Note, this matrix is not of full row rank
qr(t(cmats))$rank
all.equal(cmats[2,] + cmats[4,] - cmats[5,], cmats[3,])
# However, it is irreducible: all constraints are necessary
checkCmat(cmats)
###################################################
# Example of underlying equality constraint
# Contraint: Parameters sum is >= 0 and sum is <= 0
cmateq <- rbind(rep(1, 3), rep(-1, 3))
# Checking indicates that both constraints imply equality constraint (sum == 0)
checkCmat(cmateq)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.