linear {holiglm} | R Documentation |
Linear Constraint
Description
Linear Constraint
Usage
linear(L, dir, rhs, on_big_m = FALSE)
Arguments
L |
a named vector or matrix defining the linear constraints on the coefficients of the covariates. |
dir |
a character vector giving the direction of the linear constraints. |
rhs |
a numeric vector giving the right hand side of the linear constraint. |
on_big_m |
a logical indicating if the constraint should be imposed on the big-M related binary variables. |
Value
A holistic generalized model constraint, object inheriting from class "hglmc"
.
References
Lawson, C. L., & Hanson, R. J. (1995). Solving least squares problems. Society for Industrial and Applied Mathematics. Society for Industrial and Applied Mathematics. doi:10.1137/1.9781611971217
See Also
Other Constraint-Constructors:
group_equal()
,
group_inout()
,
group_sparsity()
,
include()
,
k_max()
,
lower()
,
pairwise_sign_coherence()
,
rho_max()
,
sign_coherence()
,
upper()
Examples
# vector constraint
beta <- c(1, -2, 3)
dat <- rhglm(100, beta)
constraints <- c(linear(c(x1 = 2, x2 = 1), "==", 0), rho_max(1))
hglm(y ~ ., data = dat, constraints = constraints)
# matrix constraint
dat <- rhglm(100, c(1, -2, 3, 4, 5, 6, 7))
mat <- diag(2)
colnames(mat) <- c("x1", "x5")
constraints <- c(linear(mat, c("==", "=="), c(-1, 3)), rho_max(1))
hglm(y ~ ., data = dat, constraints = constraints)