Skip to content

Commit 5778cba

Browse files
committed
Should fix applyFolds issue for irregular data (#24 (comment))
1 parent 15e600b commit 5778cba

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

R/FDboost.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@
398398
#' ## plot(mod4)
399399
#' ## plotPredicted(mod4, lwdPred = 2)
400400
#'
401+
#' \donttest{
402+
#' ## Find optimal mstop, small grid/low B for a fast example
403+
#' set.seed(123)
404+
#' folds4 <- cv(rep(1, length(unique(mod4$id))), B = 3)
405+
#' appl4 <- applyFolds(mod4, folds = folds4, grid = 1:50)
406+
#' ## val4 <- validateFDboost(mod4, folds = folds4, grid = 1:50)
407+
#'
408+
#' set.seed(123)
409+
#' folds4long <- cvLong(id = mod4$id, weights = model.weights(mod4), B = 3)
410+
#' cvm4 <- cvrisk(mod4, folds = folds4long, grid = 1:50)
411+
#' mstop(cvm4)
412+
#' }
413+
#'
401414
#' ## Be careful if you want to predict newdata with irregular response,
402415
#' ## as the argument index is not considered in the prediction of newdata.
403416
#' ## Thus, all covariates have to be repeated according to the number of observations

R/utilityFunctions.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,8 @@ reweightData <- function(data, argvals, vars,
11821182
i <- i + 1
11831183
}
11841184
idvars_new <- c(factor(my_temp_idvars))
1185+
# regain 1:n ids format expected by FDboost
1186+
idvars_new <- as.numeric(idvars_new)
11851187
## check whether id variable of hmatrix-object and id variable of long variables are equal
11861188
if(!is.null(idvars_new_hmatrix)){
11871189
if(!all(idvars_new == idvars_new_hmatrix))

0 commit comments

Comments
 (0)