cirls.control | R Documentation |
Internal function controlling the glm fit with linear constraints. Typically only used internally by cirls.fit, but may be used to construct a control argument.
cirls.control(constr = NULL, Cmat = NULL, lb = 0L, ub = Inf,
epsilon = 1e-08, maxit = 25, trace = FALSE, qp_solver = "quadprog",
qp_pars = list())
constr |
A formula specifying constraints to be applied to specific terms in the model. |
Cmat |
Constraint matrix specifying the linear constraints applied to coefficients. Can also be provided as a list of matrices for specific terms. |
lb , ub |
Lower and upper bound vectors for the linear constraints. Identical values in |
epsilon |
Positive convergence tolerance. The algorithm converges when the relative change in deviance is smaller than |
maxit |
Integer giving the maximal number of CIRLS iterations. |
trace |
Logical indicating if output should be produced for each iteration. |
qp_solver |
The quadratic programming solver. One of |
qp_pars |
List of parameters specific to the quadratic programming solver. See respective packages help. |
The control
argument of glm is by default passed to the control
argument of cirls.fit, which uses its elements as arguments for cirls.control: the latter provides defaults and sanity checking. The control parameters can alternatively be passed through the ...
argument of glm. See glm.control for details on general GLM fitting control, and cirls.fit for details on arguments specific to constrained GLMs.
A named list containing arguments to be used in cirls.fit.
the main function cirls.fit, and glm.control.
# Simulate predictors and response with some negative coefficients
set.seed(111)
n <- 100
p <- 10
betas <- rep_len(c(1, -1), p)
x <- matrix(rnorm(n * p), nrow = n)
y <- x %*% betas + rnorm(n)
# Define constraint matrix (includes intercept)
# By default, bounds are 0 and +Inf
Cmat <- cbind(0, diag(p))
# Fit GLM by CIRLS
res1 <- glm(y ~ x, method = cirls.fit, Cmat = Cmat)
coef(res1)
# Same as passing Cmat through the control argument
res2 <- glm(y ~ x, method = cirls.fit, control = list(Cmat = Cmat))
identical(coef(res1), coef(res2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.