cirls.control {cirls}R Documentation

Parameters controlling CIRLS fitting

Description

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.

Usage

cirls.control(epsilon = 1e-08, maxit = 25, trace = FALSE, Cmat = NULL,
  lb = 0L, ub = Inf, qp_solver = "osqp", qp_pars = list())

Arguments

epsilon

Positive convergence tolerance. The algorithm converges when the relative change in deviance is smaller than epsilon.

maxit

Integer giving the maximal number of CIRLS iterations.

trace

Logical indicating if output should be produced for each iteration.

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 lb and ub identify equality constraints. Recycled if length is different than the number of constraints defined by Cmat.

qp_solver

The quadratic programming solver. One of "osqp", "quadprog" or "coneproj".

qp_pars

List of parameters specific to the quadratic programming solver. See respective packages help.

Details

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.

Value

A named list containing arguments to be used in cirls.fit.

See Also

the main function cirls.fit, and glm.control.

Examples

# 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))

[Package cirls version 0.3.1 Index]