knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
nlpred
Small-sample optimized estimators of cross-validated prediction metrics
nlpred
is an R package for computing estimates of cross-validated prediction metrics. These estimates are tailored for superior performance in small samples. Several estimators are available including ones based cross-validated targeted minimum loss-based estimation, estimating equations, and one-step estimation.
For standard use, we recommend installing the package from CRAN via
install.packages("nlpred")
You can install the current release of nlpred
from GitHub via
devtools
with:
devtools::install_github("benkeser/nlpred")
The main functions in the package are cv_auc
and cv_scrnp
, which are used to
compute, respectively, the K
-fold cross-validated area under the receiver operating
characteristics curve (CVAUC) and
the K
-fold cross-validated sensitivity constrained rate of negative prediction. However, rather than using
standard cross-validation estimators (where prediction algorithms are developed in a
training sample and AUC/SCRNP estimated using the validation sample), we instead use
techniques from efficiency theory to estimate these quantities. This allows us to use
the training data both to develop the prediction algorithm, as well as key nuisance
parameters needed to evaluate AUC/SCRNP. By reserving more data for estimation of these
key parameters, we obtain improved performance in small samples.
# load package library(nlpred) # turn off messages from np package options(np.messages=FALSE) # simulate data n <- 200 p <- 10 X <- data.frame(matrix(rnorm(n*p), nrow = n, ncol = p)) Y <- rbinom(n, 1, plogis(X[,1] + X[,10])) # get cv auc estimates for logistic regression logistic_cv_auc_ests <- cv_auc(Y = Y, X = X, K = 5, learner = "glm_wrapper") logistic_cv_auc_ests # get cv auc estimates for random forest using nested # cross-validation for nuisance parameter estimation. nested # cross-validation is unfortunately necessary when aggressive learners # are used. rf_cv_auc_ests <- cv_auc(Y = Y, X = X, K = 5, learner = "randomforest_wrapper", nested_cv = TRUE) rf_cv_auc_ests # same examples for scrnp logistic_cv_scrnp_ests <- cv_scrnp(Y = Y, X = X, K = 5, learner = "glm_wrapper") logistic_cv_scrnp_ests rf_cv_scrnp_ests <- cv_scrnp(Y = Y, X = X, K = 5, learner = "randomforest_wrapper", nested_cv = TRUE) rf_cv_scrnp_ests
If you encounter any bugs or have any specific feature requests, please file an issue.
Interested contributors can consult our contribution guidelines
prior to submitting a pull request.
After using the nlpred
package, please cite the following:
@Manual{nlpredpackage, title = {nlpred: Estimators of Non-Linear Cross-Validated Risks Optimized for Small Samples}, author = {David Benkeser}, note = {R package version 1.0.1} } @article{benkeser2019improved, year = {2019}, author = {Benkeser, David C and Petersen, Maya and van der Laan, Mark J}, title = {Improved Small-Sample Estimation of Nonlinear Cross-Validated Prediction Metrics}, journal = {Journal of the American Statistical Association}, doi = {10.1080/01621459.2019.1668794} }
© 2019- David Benkeser
The contents of this repository are distributed under the MIT license. See below for details:
The MIT License (MIT) Copyright (c) 2019- David C. Benkeser Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.