Learn R Programming

starnet (version 0.0.3)

starnet-package: Stacked Elastic Net Regression

Description

The R package starnet implements stacked elastic net regression. The elastic net generalises ridge and lasso regularisation. Instead of fixing or tuning the mixing parameter alpha, we combine multiple alphas by stacked generalisation.

Arguments

Details

Use function starnet for model fitting. Type library(starnet) and then ?starnet or help("starnet)" to open its help file.

See the vignette for further examples. Type vignette("starnet") or browseVignettes("starnet") to open the vignette.

References

A Rauschenberger, E Glaab, and MA van de Wiel (2020). "Predictive and interpretable models via the stacked elastic net". Bioinformatics. In press. 10.1093/bioinformatics/btaa535. armin.rauschenberger@uni.lu

Examples

Run this code
# NOT RUN {
#--- data simulation ---
n <- 50; p <- 100
y <- rnorm(n=n)
X <- matrix(rnorm(n*p),nrow=n,ncol=p)
# n samples, p features

#--- model fitting ---
object <- starnet(y=y,X=X)
# "base": one model for each alpha
# "meta": model for stacking them 

#--- make predictions ---
y_hat <- predict(object,newx=X)
# one column for each alpha,
# and for tuning and stacking

#--- extract coefficients ---
coef <- coef(object)
# scalar "alpha": intercept
# vector "beta": slopes

#--- model comparison ---
# }
# NOT RUN {
loss <- cv.starnet(y=y,X=X)
# }
# NOT RUN {
# cross-validated loss for different alpha,
# and for tuning and stacking

# }

Run the code above in your browser using DataLab