Sglfast
R package for the sparse-group lasso problem with regularization parameter selection (iSGL)
Install / Use
/learn @jlaria/SglfastREADME
R package sglfast
sglfast is a fork of R package SGL (Simon et. al. 2013), with individual group regularization parameters, and the iterative sparse-group lasso isgl, an algorithm to select the optimal regularization parameters of the sparse-group lasso.
Installation
The easiest way to install isgl in R is using devtools.
If devtools is not installed, run
install.packages('devtools')
Then, install isgl
library(devtools)
install_github("jlaria/sglfast")
library(sglfast)
Usage
Example 1
library(sglfast)
# We create beta="the true coefficient vector" to be used in the simulations.
beta = 1:5
# We generate the model matrix X with iid columns and rows and the response y
X = matrix(rnorm(100*400), nrow = 100)
y = X[,1:5]%*%beta
# We chose the variance of the error such that SNR = 3
snr = 3
error = rnorm(100, mean = 0, sd=sqrt(var(y)/snr))
y = y+error
# Rows in the training sample
train.idx = sample(100, 50)
# Group indices for the SGL
group_index = rep(1:40, each=10)
# Input data for the iterative
data.train = list(x=X[train.idx,], y=y[train.idx])
data.validate = list(x=X[-train.idx,], y=y[-train.idx])
# We run the (unpooled) iterative SGL. For the 2-parameter version use isg_simple()
isgl.fit = isgl(data.train, data.validate, group_index, type = "linear")
# Best model returned by the iSGL algorithm
isgl.fit$beta
isgl.fit$intercept
Example 2
library(sglfast)
# We create beta="the true coefficient vector" to be used in the simulations.
beta = 1:5
# We generate the model matrix X with iid columns and rows and the response y
X = matrix(rnorm(100*400), nrow = 100)
y = X[,1:5]%*%beta
# We generate the response from a logit model
y = ((1+exp(-y))^-1 > 0.5) + 0
# Rows in the training sample
train.idx = sample(100, 50)
# Group indices for the SGL
group_index = rep(1:40, each=10)
# Input data for the iterative
data.train = list(x=X[train.idx,], y=y[train.idx])
data.validate = list(x=X[-train.idx,], y=y[-train.idx])
# We run the (unpooled) iterative SGL. For the 2-parameter version use isg_simple()
isgl.fit = isgl_simple(data.train, data.validate, group_index, type = "logit")
# Best model returned by the iSGL algorithm
isgl.fit$beta
isgl.fit$intercept
References
Simon, N., J. Friedman, T. Hastie, and R. Tibshirani (2013). A sparse-group lasso. Journal of Computational and Graphical Statistics 22 (2), 231–245.
Related Skills
node-connect
352.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
