Skip to content

Commit 1563c3e

Browse files
committed
Merge branch 'master' of https://github.com/boost-R/FDboost
2 parents c1a25dc + 2b3f011 commit 1563c3e

3 files changed

Lines changed: 50 additions & 28 deletions

File tree

R/bootstrapCIs.R

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,26 @@
103103
#'
104104
#' ## now speed things up by defining the inner resampling
105105
#' ## function with parallelization based on mclapply (does not work on Windows)
106+
#' isWindows <- Sys.info()['sysname']=="Windows"
106107
#'
107108
#' my_inner_fun <- function(object){
108109
#' cvrisk(object, folds = cvLong(id = object$id, weights =
109110
#' model.weights(object),
110111
#' B = 10 # 10-fold for inner resampling
111-
#' ), mc.cores = 10) # use ten cores
112+
#' ), mc.cores = if(isWindows) 1 else 10) # use ten cores
112113
#' }
113114
#'
114115
#' \donttest{
115-
#' bootCIs <- bootstrapCI(m1, resampling_fun_inner = my_inner_fun)
116+
#' bootCIs <- bootstrapCI(m1, resampling_fun_inner = my_inner_fun,
117+
#' B_outer = 5) # small B_outer to speed up
116118
#' }
117119
#'
118120
#' ## We can also use the ... argument to parallelize the applyFolds
119121
#' ## function in the outer resampling
120122
#'
121123
#' \donttest{
122-
#' bootCIs <- bootstrapCI(m1, mc.cores = 30)
124+
#' bootCIs <- bootstrapCI(m1, mc.cores = if(isWindows) 1 else 30,
125+
#' B_inner = 5, B_outer = 3)
123126
#' }
124127
#'
125128
#' ## Now let's parallelize the outer resampling and use
@@ -128,17 +131,24 @@
128131
#' my_inner_fun <- function(object){
129132
#' cvrisk(object, folds = cvLong(id = object$id, weights =
130133
#' model.weights(object), type = "kfold", # use CV
131-
#' B = 10, # 10-fold for inner resampling
134+
#' B = 5, # 5-fold for inner resampling
132135
#' ),
133-
#' mc.cores = 10) # use ten cores
136+
#' mc.cores = if(isWindows) 1 else 5) # use five cores
134137
#' }
135138
#'
136139
#' # use applyFolds for outer function to avoid messing up weights
137140
#' my_outer_fun <- function(object, fun){
138141
#' applyFolds(object = object,
139142
#' folds = cv(rep(1, length(unique(object$id))),
140-
#' type = "bootstrap", B = 100), fun = fun,
141-
#' mc.cores = 10) # parallelize on 10 cores
143+
#' type = "bootstrap", B = 10), fun = fun,
144+
#' mc.cores = if(isWindows) 1 else 10) # parallelize on 10 cores
145+
#' }
146+
#'
147+
#' \donttest{
148+
#' bootCIs <- bootstrapCI(m1, resampling_fun_inner = my_inner_fun,
149+
#' resampling_fun_outer = my_outer_fun,
150+
#' B_inner = 5, B_outer = 10)
151+
# -> provide B_inner & B_outer only for enabling default plot
142152
#' }
143153
#'
144154
#' ######## Example for scalar-on-function-regression with bsignal()
@@ -165,15 +175,10 @@
165175
#'
166176
#' \donttest{
167177
#' # takes some time, because of defaults: B_outer = 100, B_inner = 25
168-
#' bootCIs <- bootstrapCI(mod2)
178+
#' bootCIs <- bootstrapCI(mod2, B_outer = 10, B_inner = 5)
179+
#' # in practice, rather set B_outer = 1000
169180
#' }
170181
#'
171-
#' ## run with a larger number of outer bootstrap samples
172-
#' ## and only 10-fold for validation of each outer fold
173-
#' ## WARNING: This may take very long!
174-
#' \donttest{
175-
#' bootCIs <- bootstrapCI(mod2, B_outer = 1000, B_inner = 10)
176-
#' }
177182
#'
178183
#' @export
179184
bootstrapCI <- function(object, which = NULL,

man/FDboost.Rd

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/bootstrapCI.Rd

Lines changed: 18 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)