Lasso and Elastic-Net Regularized Generalized Linear Models

Extremely efficient procedures for fitting the entire lasso or elastic-net regularization path for linear regression, logistic and multinomial regression models, Poisson regression, Cox model, multiple-response Gaussian, and the grouped multinomial regression; see and . There are two new and important additions. The family argument can be a GLM family object, which opens the door to any programmed family (). This comes with a modest computational cost, so when the built-in families suffice, they should be used instead. The other novelty is the relax option, which refits each of the active sets in the path unpenalized. The algorithm uses cyclical coordinate descent in a path-wise fashion, as described in the papers cited.


Lasso and Elastic-Net Regularized Generalized Linear Models

CRAN_Status_Badge

We provide extremely efficient procedures for fitting the entire lasso or elastic-net regularization path for linear regression (gaussian), multi-task gaussian, logistic and multinomial regression models (grouped or not), Poisson regression and the Cox model. The algorithm uses cyclical coordinate descent in a path-wise fashion. Details may be found in Friedman, Hastie, and Tibshirani (2010), Simon et al. (2011), Tibshirani et al. (2012), Simon, Friedman, and Hastie (2013), Tay, Narasimhan and Hastie (2023).

There are several vignettes under Articles which are helpful for getting started with glmnet, and getting into some of the details. Since the glmnet project is more than 18 years old, there is a document that outlines the history.

The companion book glmnet is (almost) all you need, by Tay, Craig, Narasimhan, Tibshirani, and Hastie, brings the package’s many capabilities together in one place, with worked examples. Accessible directly using the Book link in the menu bar. This book is somewhat dynamic, since it is in advanced draft mode, so will change slightly from time to time.

Version 5.0 is a major release with several new features, including:

  • All kernels are written in C++, so Fortran is now gone from glmnet;
  • All aspects of the Cox model are implemented efficiently, and the “Efron” method for tie-breaking is implemented;
  • glmnet.control() has been streamlined and reorganized, and absorbs some of the many arguments in earlier versions of glmnet.

These build on earlier versions, that included features such as:

  • Relaxed fitting to allow models in the path to be refit without regularization;
  • Assessment functions for displaying performance of models on test data. These include all the measures available via cv.glmnet, as well as confusion matrices and ROC plots for classification models;
  • Functions for building the x input matrix for glmnet that allow for one-hot-encoding of factor variables, appropriate treatment of missing values, and an option to create a sparse matrix if appropriate.
  • A function for fitting unpenalized a single version of any of the GLMs of glmnet.
  • The family argument allows for any GLM family used by glm(), in addition to the built-in glmnet families.
  • The scope for survival modeling has been enlarged, allowing for (start, stop) data and strata. We provide a much-requested method for survival:survfit.
  • Any model can use an x in sparse matrix format.

References

Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. 2010. “Regularization Paths for Generalized Linear Models via Coordinate Descent.” Journal of Statistical Software, Articles 33 (1): 1–22. https://doi.org/10.18637/jss.v033.i01.

Simon, Noah, Jerome Friedman, and Trevor Hastie. 2013. “A Blockwise Descent Algorithm for Group-Penalized Multiresponse and Multinomial Regression.”

Simon, Noah, Jerome Friedman, Trevor Hastie, and Robert Tibshirani. 2011. “Regularization Paths for Cox’s Proportional Hazards Model via Coordinate Descent.” Journal of Statistical Software, Articles 39 (5): 1–13. https://doi.org/10.18637/jss.v039.i05.

Tibshirani, Robert, Jacob Bien, Jerome Friedman, Trevor Hastie, Noah Simon, Jonathan Taylor, and Ryan Tibshirani. 2012. “Strong Rules for Discarding Predictors in Lasso-Type Problems.” Journal of the Royal Statistical Society: Series B (Statistical Methodology) 74 (2): 245–66. https://doi.org/10.1111/j.1467-9868.2011.01004.x.

Kenneth Tay, J, Narasimhan, Balasubramanian, Hastie, Trevor. 2023. “Elastic Net Regularization Paths for All Generalized Linear Models.” Journal of Statistical Software, Articles 106 (1): 1–31. https://doi.org/10.18637/jss.v106.i01.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("glmnet")

5.2 by Trevor Hastie, a day ago


https://glmnet.stanford.edu


Browse source code at https://github.com/cran/glmnet


Authors: Jerome Friedman [aut] , Trevor Hastie [aut, cre] , Rob Tibshirani [aut] , Balasubramanian Narasimhan [aut] , Kenneth Tay [aut] , Noah Simon [aut] , Junyang Qian [ctb] , James Yang [aut] , Jonathan Taylor [aut]


Documentation:   PDF Manual  


GPL-2 license


Imports methods, utils, foreach, shape, survival, Rcpp

Depends on Matrix

Suggests knitr, lars, nnet, testthat, xfun, rmarkdown

Linking to RcppEigen, Rcpp

System requirements: C++17


Imported by ARGOS, ARTtransfer, AnchorRegression, AsyPeer, BNrich, BSPBSS, BWGS, BeSS, BlockMissingData, BrainCon, CARBayes, CERFIT, CICI, CIpostSelect, CNVreg, CRE, CSCNet, CauMedi, CausalMetaR, CausalState, CenBAR, ComICS, CompMix, Compositional, CondCopulas, ConformalSmallest, ConnectednessApproach, Coxmos, DDL, DEET, DLL, DLMRMV, DMRnet, DTRlearn2, DVS, DeltaTools, DevTreatRules, E2E, EMJMCMC, ENMeval, ER, EZtune, EpidigiR, FADA, FGLMtrunc, FLAME, FLORAL, FastRet, FindIt, FluxPoint, FunctanSNP, GEInfo, GMDH2, GMSimpute, GRSxE, GWLelast, GWRLASSO, GWlasso, HMC, HOIFCar, HTLR, HTRX, ICBioMark, IOBR, IsingFit, KnockoffHybrid, LEGIT, LKT, LRQVB, LUCIDus, LassoSIR, MESS, MFF, MLSP, MRFA, MRZero, MTE, MUGS, MUVR2, MaximinInfer, MedZIsc, MendelianRandomization, MetaNLP, MetabolicSurv, MicrobiomeSurv, MissCP, NCutYX, NeighborFinder, NetGreg, NetSurvProx, NonProbEst, ODRF, OHPL, OpenSpecy, PCGII, PDN, PFLR, POEMED, PRISM.forecast, PheCAP, PheVis, PhylogeneticEM, ProxReg, QTL.gCIMapping, QTL.gCIMapping.GUI, Qval, RBBR, REN, RISCA, RNAseqNet, ROCSI, RPtests, RSDA, RTextTools, RaSEn, RegEnRF, RegrCoeffsExplorer, Rforestry, Ricrt, RobustIV, RobustPrediction, Robyn, S3VS, SATS, SAVER, SBICgraph, SEMgraph, SIHR, SILFS, SIS, SISIR, SIVMethod, SMAHP, SMLE, SMMAL, SOIL, SPSP, SQIpro, STATassist, STOPES, SVEMnet, SelectBoost, SelectBoost.beta, SentimentAnalysis, ShiVa, Sieve, SoftBart, SpTe2M, SplitKnockoff, StabilizedRegression, StratifiedMedicine, SuRF.vs, SubgrpID, SurvGME, SurvHiDim, TANDEM, TRexSelector, TULIP, TensorMCMC, TraceAssist, TransHDM, VARcpDetectOnline, VSOLassoBag, WLogit, WpProj, ZVCV, afthd, aglm, alookr, aloom, amp, anoint, ardldml, argo, arulesCBA, auxvecLASSO, banditsCI, bbknnR, bestglm, betaStability, biospear, bolasso, bonsaiforest, c060, caretMultimodal, categoryEncodings, cauchyreg, causalweight, cbl, changepoints, circda, clusterMI, coda4microbiome, combss, comets, conformalInference.multi, cornet, cossonet, cpfa, cpt, cramR, creditratingsystem, crossurr, csmpv, customizedTraining, ddml, debiasedTrialEmulation, difR, dipw, dnr, doc2concrete, drcarlate, drrglm, dtComb, ePCR, easy.glmnet, emBayes, enetLTS, eshrink, evalITR, eventstream, factReg, fairml, fastcpd, fbrglm, fetwfe, finnts, flassomsm, flexBART, forestsearch, fspls2, funcml, fuser, gapclosing, ggmix, glmnetSE, glmnetUtils, glmnetr, glmtrans, gofar, goffda, graphicalExtremes, graphicalVAR, hal9001, hbal, hdcce, hdcuremodels, hdm, hdme, hdnom, highMLR, hoopR, icomb, idopNetwork, interflex, inters, intrinsicFRP, ivgls, joinet, khaos, knockoff, kosel, kuenm2, kumquat, l1spectral, lilikoi, lime, localModel, logicDT, manydata, mase, matrans, maxnet, mcb, mcboost, mdpeer, mgm, mice, mikropml, milr, mimar, misaem, misspi, mlS3, mlr3superlearner, modelSelection, modeltime.ensemble, modnets, mplot, msaenet, mudfold, multiModTest, multid, multiness, multivar, multiview, mvfmr, nadir, naivereg, natural, nestedcv, netgsa, nnGarrote, nnfor, nproc, oCELLoc, oRaklE, oalasso, obliqueRSF, ocf, ocrRBBR, omicwas, oncoPredict, organik, pacheck, palasso, pboost, pda, pencal, penppml, pgraph, phd, plasso, plmmr, plsmselect, poissonsuperlearner, politeness, polywog, pqrBayes, pre, precmed, predhy, predhy.GUI, predictoR, priorityelasticnet, prioritylasso, probe, pye, quanteda.textmodels, quickSentiment, rENA, rMultiNet, rare, rdomains, regmhmm, regnet, regressoR, regtools, riskRegression, rminer, robStepSplitReg, roben, roseRF, rrpack, sMTL, savvyGLM, savvyPR, savvySh, sccic, sdafilter, sentometrics, sharp, simode, simputation, sivs, skipTrack, smrlasso, smurf, spareg, sparselink, sparsevar, sparsevb, spexvb, spinBayes, splitSelect, spm2, squant, stabiliser, stabplot, stacks, starnet, stm, sts, sureLDA, survalis, survcompare, survivalSL, svyVarSel, tehtuner, theftdlc, tidylearn, tools4uplift, traineR, transfR, transreg, tsensembler, tsrobprep, varEst, varGuid, varGuidTS, varPro, varycoef, waou, webSDM, wehoop, wsprv, xLLiM, xplus, xrf.

Depended on by CBPS, GlarmaVarSel, HIMA, InvariantCausalPrediction, KLexp, LogisticEnsembles, MNS, MRFcov, MTPS, MultiGlarmaVarSel, NBtsVarSel, NumericEnsembles, ProSGPV, SIMMS, TSGSIS, adapt4pv, btml, cosso, ctmle, elasso, ensr, gamlss.lasso, gcomputation, glmnetcr, glmvsd, ipflasso, islasso, mcen, mmabig, mpath, mvs, personalized, prototest, ptLasso, roccv, selectiveInference, sharpPen, sox, tgml, tmle, uniLasso.

Suggested by AgriFusionR, AutoMLR, BAGofT, BiodiversityR, CanonicalFamilyExtra, CimpleG, DebiasInfer, DeepLearningCausal, DirectEffects, DoubleML, DrData, EDI, EHR, ELAplus, ErrorTracer, FRESA.CAD, GSbench, GWASinlps, GenericML, LSAmitR, MSclassifR, MachineShop, MatchIt, ModStatR, NBvarsel, Nestimate, OptimalBinningWoE, PCpluS, PartialTL, PatientLevelPrediction, Patterns, PenalReg, PortfolioTesteR, PosiR, R4VN, ReproStat, RougeLM, STPGA, SelectBoost.FDA, SelectBoost.gamlss, ShrinkageTrees, SplitReg, StatMatch, SuperLearner, SuperSurv, TensorTest2D, UBayFS, UKBAnalytica, VIM, WeightedROC, aorsf, autostats, autotune, bamlss, bbl, bcaboot, biglasso, bigstatsr, bioLeak, bnlearn, bregr, broom, caretEnsemble, casebase, cases, catdata, ccar3, ccva, censored, cgam, civic.icarm, coefplot, condvis2, contagionchannels, corrselect, cpi, cuda.ml, daltoolbox, dfr, drape, easyalluvial, ecostats, ensModelVis, evoFE, familiar, fastml, fdaSP, fdm2id, featR, flevr, flexmix, fuseMLR, futurize, gedi2, gemR, ggfortify, healthyR.ts, heuristica, hierNest, icarm, iml, imputeR, lassoinf, lingamr, live, medflex, metabodeconplus, ml, mllrnrs, mlr, mlr3automl, mlr3learners, mlr3pipelines, mlr3resampling, mlr3tuningspaces, mlr3viz, mlsurvlrnrs, modeltime, modeltime.resample, mpae, multivarious, nscancor, offsetreg, oosse, orbital, ordinalNet, origami, orthoMTL, oscar, pMEM, peperr, picreg, plotmo, pminternal, pmml, pmsims, poissonreg, polle, projpred, psychnets, purgeR, qeML, quadrupen, qwraps2, r2pmml, rACMEMEEV, randomForestRHF, randomForestSGT, regsem, remstimate, remverse, robCompositions, rtemis, s2net, sAIC, scorecraft, sense, sgd, sgs, simulator, smqf, sparsegl, spatstat.model, sportsfeatures, stabs, stratamatch, subsemble, survex, swag, targeted, text, text2vec, tidyAML, tidyhte, tidypredict, timetk, topics, tornado, tramnet, twoStageDesignTMLE, unifiedml, varbvs, vimp, weights, workflows, writeAlizer, xtdml, xtifedml.

Enhanced by prediction.


See at CRAN