lmc | R Documentation |
Linear model fitting with positivity and sum-to-one constraints on the model's coefficients.
lmc(y, X, start.v = NULL, lambda = 1, pen = "none", gamma = 1, a = 3.7)
y |
Response vector. |
X |
Design matrix. |
start.v |
Starting values. |
lambda |
Tuning parameter. |
pen |
Type of penalty. Choices are: none, ridge, lasso, alasso, scad. |
gamma |
Power parameter of adaptive lasso. |
a |
Scad parameter. |
Linear model fitting with positivity and sum-to-one constraints on the model's coefficients.
The function returns an object of class lmc
.
## Not run:
library(GJRM)
set.seed(1)
n <- 1000
beta <- c(0.07, 0.08, 0.21, 0.12, 0.15, 0.17, 0.2)
l <- length(beta)
X <- matrix(runif(n*l), n, l)
y <- X%*%beta + rnorm(n)
out <- lmc(y, X)
conv.check(out)
out1 <- lmc(y, X, start.v = beta)
conv.check(out1)
coef(out) # estimated coefficients
round(out$c.coefficients, 3) # constrained coefficients
sum(out$c.coefficients)
round(out1$c.coefficients, 3)
sum(out1$c.coefficients)
# penalised estimation
out1 <- lmc(y, X, pen = "alasso", lambda = 0.02)
conv.check(out1)
coef(out1)
round(out1$c.coefficients, 3)
sum(out1$c.coefficients)
AIC(out, out1)
BIC(out, out1)
round(cbind(out$c.coefficients, out1$c.coefficients), 3)
# scad
n <- 10000
beta <- c(0.2, 0, 0, 0.02, 0.01, 0.01, 0.01, 0.08, 0.21, 0.12, 0.15, 0.17, 0.02)
l <- length(beta)
X <- matrix(runif(n*l), n, l)
y <- X%*%beta + rnorm(n)
out1 <- lmc(y, X, pen = "scad", lambda = 0.01)
conv.check(out1)
coef(out1)
sum(out1$c.coefficients)
round(cbind(beta, out1$c.coefficients), 2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.