| l0ara | R Documentation |
Fit a sparse generalized linear model by approximating the L0-penalized objective with an adaptive ridge algorithm.
l0ara(x, y, family, lam, standardize, maxit, eps)
x |
Design matrix. A numeric matrix is used as-is; other inputs must be coercible to a model matrix. Rows correspond to observations and columns to predictors. |
y |
Response vector. For accurate use, supply numeric outcomes for
|
family |
Model family. |
lam |
A single user-supplied penalty value. If you have a candidate
sequence of values, use |
standardize |
Logical flag indicating whether to standardize the columns
of |
maxit |
Maximum number of iterations passed to the fitting routine. |
eps |
Convergence threshold. Default value is |
The objective function is
-(\log\mbox{-}\mathrm{likelihood}) + (\lambda / 2)|\beta|_0,
where |\beta|_0 is the number of non-zero elements of \beta.
The adaptive ridge algorithm provides an efficient approximation to the
corresponding L0-penalized generalized linear model.
An object with S3 class "l0ara" containing:
beta |
A vector of fitted coefficients. |
df |
Number of non-zero coefficients. |
iter |
Number of iterations used by the fitting routine. |
lam |
The supplied penalty value. |
lambda |
A copy of |
family |
The fitted model family. |
x |
The original design matrix supplied to the function. |
y |
The response vector supplied to the function. |
Wenchuan Guo <wguo1017@gmail.com>, Shujie Ma <shujie.ma@ucr.edu>, Zhenqiu Liu <Zhenqiu.Liu@cshs.org>
cv.l0ara, predict.l0ara,
coef.l0ara, plot.l0ara.
# Linear regression
# Generate design matrix and response variable
n <- 100
p <- 40
x <- matrix(rnorm(n*p), n, p)
beta <- c(1,0,2,3,rep(0,p-4))
noise <- rnorm(n)
y <- x%*%beta+noise
# fit sparse linear regression using BIC
res.gaussian <- l0ara(x, y, family="gaussian", log(n))
# predict for new observations
print(res.gaussian)
predict(res.gaussian, newx=matrix(rnorm(3,p),3,p))
coef(res.gaussian)
# Logistic regression
# Generate design matrix and response variable
n <- 100
p <- 40
x <- matrix(rnorm(n*p), n, p)
beta <- c(1,0,2,3,rep(0,p-4))
prob <- exp(x%*%beta)/(1+exp(x%*%beta))
y <- rbinom(n, rep(1, n), prob)
# fit sparse logistic regression
res.logit <- l0ara(x, y, family="logit", 0.7)
# predict for new observations
print(res.logit)
predict(res.logit, newx=matrix(rnorm(3,p),3,p))
coef(res.logit)
# Poisson regression
# Generate design matrix and response variable
n <- 100
p <- 40
x <- matrix(rnorm(n*p), n, p)
beta <- c(1,0,0.5,0.3,rep(0,p-4))
mu <- exp(x%*%beta)
y <- rpois(n, mu)
# fit sparse Poisson regression using AIC
res.pois <- l0ara(x, y, family="poisson", 2)
# predict for new observations
print(res.pois)
predict(res.pois, newx=matrix(rnorm(3,p),3,p))
coef(res.pois)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.