Package: glmnetr 0.6-4

Walter K Kremers

glmnetr: Nested Cross Validation for the Relaxed Lasso and Other Machine Learning Models

Cross validation informed Relaxed LASSO (or more generally elastic net), gradient boosting machine ('xgboost'), Random Forest ('RandomForestSRC'), Oblique Random Forest ('aorsf'), Artificial Neural Network (ANN), Recursive Partitioning ('RPART') or step wise regression models are fit. Cross validation leave out samples (leading to nested cross validation) or bootstrap out-of-bag samples are used to evaluate and compare performances between these models with results presented in tabular or graphical means. Calibration plots can also be generated, again based upon (outer nested) cross validation or bootstrap leave out (out of bag) samples. Note, at the time of this writing, in order to fit gradient boosting machine models one must install the packages 'DiceKriging' and 'rgenoud' using the install.packages() function. For some datasets, for example when the design matrix is not of full rank, 'glmnet' may have very long run times when fitting the relaxed lasso model, from our experience when fitting Cox models on data with many predictors and many patients, making it difficult to get solutions from either glmnet() or cv.glmnet(). This may be remedied by using the 'path=TRUE' option when calling glmnet() and cv.glmnet(). Within the 'glmnetr' package the approach of path=TRUE is taken by default. other packages doing similar include 'nestedcv' <https://cran.r-project.org/package=nestedcv>, 'glmnetSE' <https://cran.r-project.org/package=glmnetSE> which may provide different functionality when performing a nested CV. Use of the 'glmnetr' has many similarities to the 'glmnet' package and it could be helpful for the user of 'glmnetr' also become familiar with the 'glmnet' package <https://cran.r-project.org/package=glmnet>, with the "An Introduction to 'glmnet'" and "The Relaxed Lasso" being especially useful in this regard.

Authors:Walter K Kremers [aut, cre], Nicholas B Larson [ctb]

glmnetr_0.6-4.tar.gz
glmnetr_0.6-4.zip(r-4.7-any)glmnetr_0.6-4.zip(r-4.6-any)
glmnetr_0.6-4.tar.gz(r-4.7-any)glmnetr_0.6-4.tar.gz(r-4.6-any)
glmnetr_0.6-4.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION
card.svg |card.png
glmnetr/json (API)

# Install 'glmnetr' in R:
install.packages('glmnetr', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

On CRAN:

Conda:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

3.08 score 2 scripts 894 downloads 35 exports 115 dependencies

Last updated from:f7cc89b54e. Checks:6 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK269
source / vignettesOK302
linux-releaseOK243
windows-develOK181
windows-releaseOK200
wasm-releaseOK130

Exports:aicregann_tab_cvann_tab_cv_bestbest.predsboot.factor.foldidcalcelosscalplotcox.sat.devcv.glmnetrcv.stepregdevrat_diff_timediff_time1DK_dev_factor.foldidget.foldidget.id.foldidglmnetr_seedglmnetr.cisglmnetr.compcvglmnetr.simdatanested.cisnested.comparenested.glmnetrorf_tuneplot_perf_glmnetrpredict_ann_tabrederive_orfrederive_rfrederive_xgbrf_tuneroundperfstepregxgb.simplexgb.tuned

Dependencies:aorsfbackportsbase64encbbotkbitbit64bslibcachemcallrcheckmateclicliprcodetoolscollapsecorocpp11crayondata.tabledata.treedescDiagrammeRDiceKrigingdigestdplyrevaluatefarverfastmapfontawesomeforeachfsfuturefuture.applygenericsglmnetglobalsgluehighrhmshtmltoolshtmlwidgetsigraphiteratorsjquerylibjsonliteknitrlabelinglatticelgrlifecyclelistenvmagrittrMatrixmatrixStatsmemoisemimemiraimlbenchmlr3mlr3mbomlr3measuresmlr3miscmlr3tuningmoocorenanonextotelpalmerpenguinsparadoxparallellypillarpkgconfigprettyunitspROCprocessxprogressPRROCpspurrrR6randomForestSRCrappdirsrbibutilsRColorBrewerRcppRcppArmadilloRcppEigenRdpackreadrrlangrmarkdownrpartrstudioapisafetensorssassscalesshapespacefillrstringistringrsurvivaltibbletidyrtidyselecttinytextorchtzdbutf8uuidvctrsviridisLitevisNetworkvroomwithrxfunxgboostyaml

An Overview of glmnetr
The Package | Installing glmnetr | Data requirements | An example data set | Performance of cross validation (CV) informed relaxed lasso model | The CV informed relaxed lasso model fit | Nested cross validation (NCV) for multiple models | Further model assessment | Model comparisons with simulated and observed data | Model replicability and model comparisons | Bootstrap assessment of model performance | References

Last update: 2026-09-16
Started: 2026-09-16

Calibration of Machine Learning Models
The Package | An Example Analysis | Linear Calibration | A First Visual | Calibration Using Spline Fits and Resampling | A Binomial Model | A Binomial Model Calibrated Using Bootstrap | Bootstrap Calibration for a Random Forest | A Normal (Gaussian Errors) Model | Perspective | References

Last update: 2026-09-16
Started: 2026-09-16

Elastic net models
Introduction | An example dataset | Fitting an Elastic Net model | A tabular summary of model performances | A graphical summary of model performances | Graphical presentations of cross validation deviances | Graphical presentations of beta estimates | Numerical values for beta and predicteds

Last update: 2026-09-16
Started: 2026-09-16

Ridge and Lasso
The matter | An example dataset | Impact of repeats in the predicteds

Last update: 2026-09-16
Started: 2026-09-16

Using ann_tab_cv
The functions | Installing glmnetr | Data requirements | An example dataset | Working with torch tensors | Performing calibrations with the neural network models | Transfer learning from linear models to neural network models | Comparison of lasso and neural network models | Calibration plots based upon hold out data | Internal implementaiton of the ``transfer learning'' | Further extensions of ``transfer learning'' | Transfer learning and the gradient boosting machine

Last update: 2026-09-16
Started: 2026-09-16

Using stepreg
The Package | Data requirements | An example dataset | Cross validation (CV) informed stepwise model fit | Nested cross validation

Last update: 2026-09-16
Started: 2026-09-16

Readme and manuals

Help Manual

Help pageTopics
Identify model based upon AIC criteria from a stepreg() putputaicreg
Fit an Artificial Neural Network model on "tabular" provided as a matrix, optionally allowing for an offset termann_tab_cv
Fit multiple Artificial Neural Network models on "tabular" provided as a matrix, and keep the best one.ann_tab_cv_best
Get the best models for the steps of a stepreg() fitbest.preds
Generate foldid's by 0/1 factor for bootstrap like samples where unique option between 0 and 1boot.factor.foldid
calculate cross-entry for multinomial outcomescalceloss
Construct calibration plots for a nested.glmnetr output objectcalplot
Calculate the CoxPH saturated log-likelihoodcox.sat.dev
Get a cross validation informed relaxed lasso model fit. Available to the user but intended to be call from nested.glmnetr().cv.glmnetr
Cross validation informed stepwise regression model fit.cv.stepreg
Calculate deviance ratios for CV baseddevrat_
Output to console the elapsed and split timesdiff_time
Get elapsed time in c(hour, minute, secs)diff_time1
invoke DiceKriging for devlopmentDK_dev_
Generate foldid's by factor levelsfactor.foldid
Get foldid's with branching for cox, binomial and gaussian modelsget.foldid
Get foldid's when id variable is used to identify groups of dependent sampling units. With branching for cox, binomial and gaussian modelsget.id.foldid
Get seeds to store, facilitating replicable resultsglmnetr_seed
A redirect to nested.cis()glmnetr.cis
A redirect to nested.compareglmnetr.compcv
Generate example dataglmnetr.simdata
Calculate performance measure "nominal" CI's and p'snested.cis
Compare cross validation fit performances from a nested.glmnetr output.nested.compare
Using (nested) cross validation, describe and compare some machine learning model performancesnested.glmnetr
Fit a Random Forest model on data provided in matrix and vector formats.orf_tune
Plot nested cross validation performance summariesplot_perf_glmnetr
Plot cross-validation deviances, or model coefficients.plot.cv.glmnetr
Plot the relaxed lasso coefficients.plot.glmnetr
Plot results from a nested.glmnetr() outputplot.nested.glmnetr
Get predicteds for an Artificial Neural Network model fit in nested.glmnetr()predict_ann_tab
Give predicteds for elastic net models form a nested.glmnetr() output object.predict.cv.glmnetr
Give predicteds for elastic net models form a nested..glmnetr() output object.predict.cv.glmnetr.el
Give predicteds for elastic net models form a nested..glmnetr() output object.predict.cv.glmnetr.list
Beta's or predicteds based upon a cv.stepreg() output object.predict.cv.stepreg
Give predicteds based upon the cv.glmnet output object contained in the nested.glmnetr output object.predict.nested.glmnetr
A redirect to the summary() function for nested.glmnetr() output objectsprint.nested.glmnetr
Print output from orf_tune() functionprint.orf_tune
Print output from rf_tune() functionprint.rf_tune
Rederive Oblique Random Forest models not kept in nested.glmnetr() outputrederive_orf
Rederive Random Forest models not kept in nested.glmnetr() outputrederive_rf
Rederive XGB models not kept in nested.glmnetr() outputrederive_xgb
Fit a Random Forest model on data provided in matrix and vector formats.rf_tune
round elements of a summary.glmnetr() outputroundperf
Fit the steps of a stepwise regression.stepreg
Output summary for elastic net models fit within a nested.glmnetr() output object.summary.cv.glmnetr
Summarize results from a cv.stepreg() output object.summary.cv.stepreg
Summarize a nested.glmnetr() output objectsummary.nested.glmnetr
Summarize output from rf_tune() functionsummary.orf_tune
Summarize output from rf_tune() functionsummary.rf_tune
Briefly summarize steps in a stepreg() output object, i.e. a stepwise regression fitsummary.stepreg
Get a simple XGBoost model fit (no tuning)xgb.simple
Get a tuned XGBoost model fitxgb.tuned