Skip to content

Commit

Permalink
snakecase plus list as return
Browse files Browse the repository at this point in the history
  • Loading branch information
holgstr committed Nov 27, 2023
1 parent 9264521 commit e46251b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions R/corPFSOS.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ corTrans <- function(transition) {
#' Initial parameters for optimization can be specified here.
#' See [exponential_transition()] or [weibull_transition()] for details.
#' @param bootstrap (`flag`)\cr if `TRUE` computes confidence interval via bootstrap.
#' @param bootstrap.n (`count`)\cr number of bootstrap samples.
#' @param bootstrap.level (`proportion`)\cr confidence level for the confidence interval.
#' @param bootstrap_n (`count`)\cr number of bootstrap samples.
#' @param bootstrap_level (`proportion`)\cr confidence level for the confidence interval.
#'
#' @return The correlation of PFS and OS.
#' @export
Expand All @@ -291,34 +291,35 @@ corTrans <- function(transition) {
#' accrual = list(param = "intensity", value = 7)
#' )[[1]]
#' corPFSOS(data, transition)
corPFSOS <- function(data, transition, bootstrap = TRUE, bootstrap.n = 100, bootstrap.level = 0.95) {
corPFSOS <- function(data, transition, bootstrap = TRUE, bootstrap_n = 100, bootstrap_level = 0.95) {
assert_data_frame(data)
assert_flag(bootstrap)
assert_count(bootstrap.n)
assert_number(bootstrap.level, lower = 0.01, upper = 0.999)
assert_count(bootstrap_n)
assert_number(bootstrap_level, lower = 0.01, upper = 0.999)

trans <- estimateParams(data, transition)
res <- corTrans(transition)
res <- list("corPFSOS" = corTrans(transition))
if (bootstrap) {
future::plan(future::multisession, workers = max(1, parallel::detectCores() - 1))
ids <- lapply(1:bootstrap.n, function(x) sample(seq_len(nrow(data)), nrow(data), replace = TRUE))
ids <- lapply(1:bootstrap_n, function(x) sample(seq_len(nrow(data)), nrow(data), replace = TRUE))
corBootstrap <- furrr::future_map_dbl(ids, ~ {
furrr::furrr_options(
globals = list(data = data, transition = transition),
packages = c("simIDM")
)
b_sample <- data[.x, ]
b_sample <- data[.x, ,drop = FALSE]

Check warning on line 310 in R/corPFSOS.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=R/corPFSOS.R,line=310,col=29,[commas_linter] Commas should always have a space after.
prepared_data <- prepareData(b_sample)
b_transition <- estimateParams(b_sample, transition)
corTrans(b_transition)
})
lowerQuantile <- (1 - bootstrap.level) / 2
upperQuantile <- lowerQuantile + bootstrap.level
lowerQuantile <- (1 - bootstrap_level) / 2
upperQuantile <- lowerQuantile + bootstrap_level
c(stats::quantile(corBootstrap, lowerQuantile),
"corPFSOS" = res,
stats::quantile(corBootstrap, upperQuantile)
)
} else {
c("corPFSOS" = res)
res$lower <- stats::quantile(corBootstrap, lowerQuantile)
res$upper <- stats::quantile(corBootstrap, upperQuantile)
}
res
}
8 changes: 4 additions & 4 deletions man/corPFSOS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e46251b

Please sign in to comment.