| Title: | Sparse Regression for Related Problems |
|---|---|
| Description: | Estimates sparse regression models (i.e., with few non-zero coefficients) in high-dimensional multi-task learning and transfer learning settings, as proposed by Rauschenberger et al. (2025) <doi:10.1093/bioinformatics/btaf406>. |
| Authors: | Armin Rauschenberger [aut, cre] (ORCID: <https://orcid.org/0000-0001-6498-4801>) |
| Maintainer: | Armin Rauschenberger <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-14 07:16:38 UTC |
| Source: | https://github.com/rauschenberger/sparselink |
The R package 'sparselink' implements sparse regression for related problems (multi-task learning and transfer learning).
Use function [sparselink()] for model fitting. Type 'library(sparselink)' and then '?sparselink' or 'help("sparselink")' to open its help file.
See the vignette for further examples. Type 'vignette("sparselink")' or 'browseVignettes("sparselink")' to open the vignette.
Maintainer: Armin Rauschenberger [email protected] (ORCID)
Armin Rauschenberger, Petr N. Nazarov, and Enrico Glaab (2025). "Estimating sparse regression models in multi-task learning and transfer learning through adaptive penalisation". Under revision. https://hdl.handle.net/10993/63425
First use sparselink to fit the models,
and then coef to extract coefficients
or predict to make predictions.
?sparselink ?coef.sparselink ?predict.sparselink?sparselink ?coef.sparselink ?predict.sparselink
Extracts coefficients from multi-task or transfer learning regression model.
## S3 method for class 'sparselink' coef(object, ...)## S3 method for class 'sparselink' coef(object, ...)
object |
object of class |
... |
(not applicable) |
Returns estimated coefficients.
The output is a list with two slots:
slot alpha with the estimated intercept
(vector of length ),
and slot beta with the estimated slopes
(matrix with rows and columns).
Armin Rauschenberger, Petr N. Nazarov, and Enrico Glaab (2025). "Estimating sparse regression models in multi-task learning and transfer learning through adaptive penalisation". Under revision. https://hdl.handle.net/10993/63425
Use sparselink to fit the model
and predict to make predictions.
family <- "gaussian" type <- "multiple" # try "multiple" or "transfer" if(type=="multiple"){ data <- sim_data_multi(family=family) } else if(type=="transfer"){ data <- sim_data_trans(family=family) } object <- sparselink(x=data$X_train,y=data$y_train,family=family) coef <- coef(object=object)family <- "gaussian" type <- "multiple" # try "multiple" or "transfer" if(type=="multiple"){ data <- sim_data_multi(family=family) } else if(type=="transfer"){ data <- sim_data_trans(family=family) } object <- sparselink(x=data$X_train,y=data$y_train,family=family) coef <- coef(object=object)
Predicts outcomes with a multi-task or transfer learning regression model.
## S3 method for class 'sparselink' predict(object, newx, weight = NULL, ...)## S3 method for class 'sparselink' predict(object, newx, weight = NULL, ...)
object |
object of class |
newx |
features:
matrix with |
weight |
hyperparameters for scaling external and internal weights:
numeric vector of length 2,
with the first entry for the external weights
(prior coefficients from source data),
and the second entry for the internal weights
(prior coefficients from target data),
selected values must be among the candidate values,
default: |
... |
(not applicable) |
Returns predicted values or predicted probabilities.
The output is a list of column vectors of length
for in .
Each vector corresponds to one target (multi-task learning)
or one dataset (transfer learning).
Armin Rauschenberger, Petr N. Nazarov, and Enrico Glaab (2025). "Estimating sparse regression models in multi-task learning and transfer learning through adaptive penalisation". Under revision. https://hdl.handle.net/10993/63425
Use sparselink to fit the model
and coef to extract coefficients.
family <- "gaussian" type <- "multiple" # try "multiple" or "transfer" if(type=="multiple"){ data <- sim_data_multi(family=family) } else if(type=="transfer"){ data <- sim_data_trans(family=family) } object <- sparselink(x=data$X_train,y=data$y_train,family=family) y_hat <- predict(object=object,newx=data$X_test)family <- "gaussian" type <- "multiple" # try "multiple" or "transfer" if(type=="multiple"){ data <- sim_data_multi(family=family) } else if(type=="transfer"){ data <- sim_data_trans(family=family) } object <- sparselink(x=data$X_train,y=data$y_train,family=family) y_hat <- predict(object=object,newx=data$X_test)
Estimates sparse regression models (i.e., performing feature selection) in multi-task learning or transfer learning. Multi-task learning involves multiple targets, and transfer learning involves multiple datasets.
sparselink( x, y, family, alpha.init = 0.95, alpha = 1, type = "exp", nfolds = 10, cands = NULL )sparselink( x, y, family, alpha.init = 0.95, alpha = 1, type = "exp", nfolds = 10, cands = NULL )
x |
|
y |
|
family |
character |
alpha.init |
elastic net mixing parameter for initial regressions, default: 0.95 (lasso-like elastic net) |
alpha |
elastic net mixing parameter of final regressions, default: 1 (lasso) |
type |
default |
nfolds |
number of internal cross-validation folds, default: 10 (10-fold cross-validation) |
cands |
candidate values for both scaling parameters,
default: |
Returns an object of class sparselink, a list with multiple slots:
Stage 1 regressions (before sharing information):
Slot glm.one contains objects of type
cv.glmnet (one for each problem).
Candidate scaling parameters (exponents):
Slot weight contains
a data frame with combinations of exponents for the external (source)
and internal (target) weights
Stage 2 regressions (after sharing information):
Slot glm.two contains lists (one for each problem)
of objects of type cv.glmnet
(one for each combination of exponents).
Optimal regularisation parameters: Slot lambda.min
contains the cross-validated regularisation parameters for the stage 2
regressions.
Optimal scaling parameters: Slots weight.ind and
weight.min indicate or contain the cross-validated scaling parameters.
Armin Rauschenberger, Petr N. Nazarov, and Enrico Glaab (2025). "Estimating sparse regression models in multi-task learning and transfer learning through adaptive penalisation". Under revision. https://hdl.handle.net/10993/63425
Use coef to extract coefficients
and predict to make predictions.
#--- multi-task learning --- n <- 100 p <- 200 q <- 3 family <- "gaussian" x <- matrix(data=rnorm(n=n*p),nrow=n,ncol=p) y <- matrix(data=rnorm(n*q),nrow=n,ncol=q) object <- sparselink(x=x,y=y,family=family) #--- transfer learning --- n <- c(100,50) p <- 200 x <- lapply(X=n,function(x) matrix(data=stats::rnorm(n*p),nrow=x,ncol=p)) y <- lapply(X=n,function(x) stats::rnorm(x)) family <- "gaussian" object <- sparselink(x=x,y=y,family=family)#--- multi-task learning --- n <- 100 p <- 200 q <- 3 family <- "gaussian" x <- matrix(data=rnorm(n=n*p),nrow=n,ncol=p) y <- matrix(data=rnorm(n*q),nrow=n,ncol=q) object <- sparselink(x=x,y=y,family=family) #--- transfer learning --- n <- c(100,50) p <- 200 x <- lapply(X=n,function(x) matrix(data=stats::rnorm(n*p),nrow=x,ncol=p)) y <- lapply(X=n,function(x) stats::rnorm(x)) family <- "gaussian" object <- sparselink(x=x,y=y,family=family)