Skip to content

merge main to dev#89

Merged
rid4stat merged 30 commits intodevfrom
main
Feb 20, 2026
Merged

merge main to dev#89
rid4stat merged 30 commits intodevfrom
main

Conversation

@rid4stat
Copy link
Collaborator

No description provided.

Ridwan Olaniran and others added 30 commits November 10, 2025 23:53
Attempt to pull recent changes from main into pmsims-ml
Merge remote-tracking branch 'origin/main' into pmsims-ml
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@rid4stat rid4stat merged commit b35e7dc into dev Feb 20, 2026
3 of 23 checks passed
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

air

[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 228 to 232 in c3613e2

perf_n = as.numeric(ds$final$power) ,
mlpwr_ds = list(data = ds$dat, fit = ds$fit,
boundaries = ds$boundaries,
final = ds$final,
aggregate_fun = ds$aggregate_fun)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 286 to 287 in c3613e2


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 289 to 290 in c3613e2


[air] reported by reviewdog 🐶

start_n = start_values$start_min_sample_size,


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 305 to 309 in c3613e2

start_min_sample_size <- start_values$min_sample_size
start_max_sample_size <- start_values$max_sample_size


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

core_names <- c("data_function", "model_function", "metric_function", "value_on_error", "test_data")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 334 to 336 in c3613e2

envs <- unique(list(environment(data_function),
environment(model_function),
environment(metric_function)))


[air] reported by reviewdog 🐶

try(parallel::clusterExport(cl, varlist = objs, envir = e), silent = TRUE)


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 346 to 347 in c3613e2


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 353 to 356 in c3613e2

on.exit({
try(parallel::stopCluster(cl), silent = TRUE)
try(doParallel::stopImplicitCluster(), silent = TRUE)
}, add = TRUE)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 374 to 388 in c3613e2

if (!"package:foreach" %in% search()) library(foreach, quietly = TRUE)
if (!"package:doParallel" %in% search()) library(doParallel, quietly = TRUE)
# Use foreach %dopar% on the already-registered cluster
vals <- foreach::foreach(i = seq_len(n_reps_per), .combine = c) %dopar% {
# Each worker will call single_run; single_run closes over data_function, etc.
tryCatch(
{
dat <- data_function(n)
fit <- model_function(dat)
metric_function(test_data, fit, attr(model_function, "model"))
},
error = function(e) value_on_error
)


[air] reported by reviewdog 🐶

} else {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

(!budget && (p_hi - p_lo) >= tol && iter < max_iter)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 480 to 493 in c3613e2

test_n,
n_reps_total,
n_reps_per,
se_final,
min_sample_size,
max_sample_size,
target_performance,
c_statistic,
mean_or_assurance,
verbose,
data_function,
model_function,
metric_function,
value_on_error


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 509 to 510 in c3613e2


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

start_n = start_values$start_min_sample_size,


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 616 to 621 in c3613e2

mlpwrbs_max_sample_size <- ifelse((mlpwrbs_max_sample_size -
mlpwrbs_min_sample_size) < 5,
round(mlpwrbs_min_sample_size * 1.2),
mlpwrbs_max_sample_size)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/engines.R

Lines 659 to 663 in c3613e2

perf_n = as.numeric(ds$final$power) ,
mlpwr_ds = list(data = ds$dat, fit = ds$fit,
boundaries = ds$boundaries,
final = ds$final,
aggregate_fun = ds$aggregate_fun)


[air] reported by reviewdog 🐶

}


[air] reported by reviewdog 🐶

if (!is.null(expected_performance) && metric_lower %in% c("auc","r2","cindex")) {


[air] reported by reviewdog 🐶

"Requested minimum acceptable", metric_lower, "exceeds the expected",


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

if (model %in% c("lm","glm")) {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

glmnet_type <- switch(type,
response = "response",
link = "link",
lp = "link",
stop("Type '", type, "' not supported for lasso."))
preds <- as.numeric(predict(fit, newx = x_mat, s = s_val, type = glmnet_type))


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

if (!inherits(pr, "try-error")) return(pr)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

stop("rf (ranger) prediction type not supported or unknown prediction structure.")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

p <- pmin(pmax(as.numeric(preds), .Machine$double.eps), 1 - .Machine$double.eps)


[air] reported by reviewdog 🐶

stop("xgboost: direct survival probability matrix is not available from xgboost predictions. Consider using type = 'lp' and mapping to survival via a baseline if needed.")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

bs <- mean((y - y_hat) ^ 2)


[air] reported by reviewdog 🐶

return(1 - mean((y - y_hat) ^ 2) / mean((y - mean(y)) ^ 2))


[air] reported by reviewdog 🐶

mse <- sum((y_hat - y) ^ 2) / n


[air] reported by reviewdog 🐶

cf <- try(survival::concordancefit(y_surv, -1 * as.numeric(y_hat)), silent = TRUE)


[air] reported by reviewdog 🐶

cf <- try(stats::coef(survival::coxph(y_surv ~ as.numeric(y_hat))), silent = TRUE)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

try({
pred_surv <- predict_custom(x, NULL, fit, model, type = "survival")
}, silent = TRUE)


[air] reported by reviewdog 🐶

pred_surv <- try(survival:::predict.coxph(fit, data, type = "survival"), silent = TRUE)


[air] reported by reviewdog 🐶

if (!inherits(pr, "try-error") && !is.null(pr$predictions) && is.matrix(pr$predictions)) {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

warning("survival_calib_slope_free: predicted survival probabilities not available for model '", model, "'. Returning NaN.")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

if (is.null(eval_time)) eval_time <- max(data$time[data$event == 1]) * 0.9999


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pred_surv_at_time <- pmin(pmax(pred_surv_at_time, .Machine$double.eps), 1 - .Machine$double.eps)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

fit_slope <- try(suppressWarnings(stats::glm(
y_obs ~ y_hat,
weights = w,
family = stats::binomial()
)), silent = TRUE)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

if (class(try(survival::concordancefit(y_surv, y_hat), silent = TRUE))[1] == "try-error") {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

xgboost = function(d, nrounds = 100, params = list(objective = "binary:logistic", eval_metric = "logloss")) {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

num.threads = nthreads


[air] reported by reviewdog 🐶

xgboost = function(d, nrounds = 100, params = list(objective = "reg:squarederror", eval_metric = "rmse")) {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

x <- as.matrix(d[, setdiff(colnames(d), c("time", "event")), drop = FALSE])


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

xgboost = function(d, nrounds = 100, params = list(objective = "survival:cox", eval_metric = "cox-nloglik")) {


[air] reported by reviewdog 🐶

x <- as.matrix(d[, setdiff(colnames(d), c("time", "event")), drop = FALSE])


[air] reported by reviewdog 🐶

dtrain <- xgboost::xgb.DMatrix(data = x, label = label_time, weight = event)


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 188 to 200 in c3613e2

cv.ranger_tune <- function(data, formula,
type = c("regression", "classification", "survival"),
tune.parameters = c("mtry", "min.node.size"),
num.trees = 1000,
iters = 70,
iters.warmup = 30,
time.budget = NULL,
num.threads = parallel::detectCores() - 1,
measure = NULL,
build.final.model = TRUE,
show.info = TRUE,
seed = 123,
...) {


[air] reported by reviewdog 🐶

stop("Please install required packages: ", paste(missing_pkgs, collapse = ", "))


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 220 to 221 in c3613e2

if (length(surv_vars) < 2) stop("For survival, specify Surv(time, status) on LHS of formula.")
time_col <- surv_vars[1]; status_col <- surv_vars[2]


[air] reported by reviewdog 🐶

if (!is.numeric(data[[resp]])) warning("Regression target is not numeric.")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 244 to 246 in c3613e2

if (length(task$task.desc$class.levels) == 2) measure_obj <- list(mlr::auc)
else measure_obj <- list(mlr::acc)
} else { # survival


[air] reported by reviewdog 🐶

if (is.null(mm)) stop("Unknown mlr measure: ", mn)


[air] reported by reviewdog 🐶

} else if (is.list(measure) && all(sapply(measure, function(x) inherits(x, "Measure")))) {


[air] reported by reviewdog 🐶

stop("`measure` must be NULL, a character name, an mlr::Measure, or a list of Measures.")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 285 to 286 in c3613e2

if (length(extra_args) > 0) tune_args <- c(tune_args, extra_args)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 295 to 296 in c3613e2

if (build.final.model && !is.null(tune_res$model)) out$model <- tune_res$model


[air] reported by reviewdog 🐶

pmsims/R/model_generators.R

Lines 308 to 310 in c3613e2

cat("Recommended parameters:\n"); print(x$recommended.pars)
cat("\nTop tuning results (first 6 rows):\n"); print(head(x$results))
if (!is.null(x$model)) cat("\nFinal model attached as $model\n")


[air] reported by reviewdog 🐶

if (!inherits(x, "pmsims")) stop("Object is not of class 'pmsims'")


[air] reported by reviewdog 🐶

has_cli <- requireNamespace("cli", quietly = TRUE)


[air] reported by reviewdog 🐶

has_tools <- requireNamespace("tools", quietly = TRUE)


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 12 to 15 in c3613e2

bold <- function(txt) if (has_crayon) crayon::bold(txt) else txt
cyan <- function(txt) if (has_crayon) crayon::cyan(txt) else txt
blue <- function(txt) if (has_crayon) crayon::blue(txt) else txt
dimc <- function(txt) if (has_crayon) crayon::silver(txt) else txt


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 22 to 23 in c3613e2

if (is.null(title)) cli::cat_rule(width = scr_width)
else cli::cat_rule(center = as.character(title), width = scr_width)


[air] reported by reviewdog 🐶

if (!is.null(title)) cat(title, "\n", sep = "")


[air] reported by reviewdog 🐶

plural <- function(n, unit) sprintf("%d %s", n, if (n == 1) unit else paste0(unit, "s"))


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 34 to 36 in c3613e2

secs <- if (inherits(simt, "difftime")) as.numeric(simt, units = "secs")
else if (is.numeric(simt)) as.numeric(simt) else return("<NA>")
if (is.na(secs)) return("<NA>")


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 38 to 40 in c3613e2

d <- secs %/% 86400; rem <- secs %% 86400
h <- rem %/% 3600 ; rem <- rem %% 3600
m <- rem %/% 60 ; s <- rem %% 60


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 42 to 45 in c3613e2

if (d > 0) parts <- c(parts, plural(d, "day"))
if (h > 0) parts <- c(parts, plural(h, "hour"))
if (m > 0) parts <- c(parts, plural(m, "minute"))
if (s > 0 || length(parts) == 0) parts <- c(parts, plural(s, "second"))


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 50 to 52 in c3613e2

if (!is_present(v)) return("<NA>")
if (is.numeric(v) && length(v) == 1L) formatC(v, format = "f", digits = digits)
else paste(v, collapse = ", ")


[air] reported by reviewdog 🐶

if (!is_present(v)) return("<NA>")


[air] reported by reviewdog 🐶

if (!is_present(metric)) return(NULL)


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 65 to 69 in c3613e2

"cstatistic" = "C-statistic",
"brier" = "Brier score",
"rmse" = "RMSE",
{label <- gsub("_", " ", metric)
if (has_tools) tools::toTitleCase(label) else label}


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 74 to 82 in c3613e2

moa <- x$mean_or_assurance %||% "mean"
model <- x$model %||% NA_character_
target <- x$target_performance %||% x$minimum_acceptable_performance %||% NA_real_
metric <- x$metric %||% NA_character_
metric_2 <- x$metric_2 %||% NA_character_
min_n <- x$min_n %||% NA
perf_at <- x$perf_n %||% NA
perf2_at <- x$metric_2_at_n %||% NA
simtime <- x$simulation_time %||% NA


[air] reported by reviewdog 🐶

r2 <- x$r2


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 90 to 96 in c3613e2

"Outcome" = x$outcome,
"Predictor type" = x$predictor_type,
"Number of predictors" = x$parameters,
"Noise predictors" = x$noise_parameters,
"Prevalence" = x$prevalence,
"Baseline hazard" = x$baseline_hazard,
"Censoring rate" = x$censoring_rate


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 98 to 104 in c3613e2

if (is_present(cstatistic))
inputs[["Expected large-sample performance"]] <- paste0("C-statistic ('cstatistic') = ", fmt_num(cstatistic, 3))
if (is_present(r2))
inputs[["Expected large-sample performance"]] <- paste0("R² ('r2') = ", fmt_num(r2, 3))
if (is_present(metric) || is_present(target))
inputs[["Target for chosen performance metric"]] <- paste0(pretty_metric(metric), " = ", fmt_num(target, 3))
inputs[["Model"]] <- model


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 112 to 120 in c3613e2

"Final minimum sample size" = bold(fmt_int(min_n)),
"Estimated performance at N" = paste0(fmt_num(perf_at, 3),
" (", pretty_metric(metric),
" = ", fmt_num(target, 3), ")"),
"Estimated other metric at N" = paste0(fmt_num(perf2_at, 3),
" (", pretty_metric(metric_2), ")"),
"Model" = model,
"Mode" = if (tolower(moa) == "assurance") "Assurance" else "Mean",
"Running time" = fmt_duration(simtime)


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 123 to 124 in c3613e2


[air] reported by reviewdog 🐶

pmsims/R/print.R

Lines 157 to 160 in c3613e2

cat(" ", dimc(if (tolower(moa) == "assurance")
italic("Assurance mode ensures the target metric is met with high probability across repeated datasets.")
else
italic("Mean mode ensures the target metric is met on average across datasets.")), "\n", sep = "")


[air] reported by reviewdog 🐶

}


[air] reported by reviewdog 🐶

signal_parameters, # Predictors
noise_parameters = 0,
predictor_type = "continuous",
binary_predictor_prevalence = NULL,
outcome_prevalence, # Outcome
large_sample_cstatistic,
model = "glm", # Model
metric = "calibration_slope", # Performance
minimum_acceptable_performance,
n_reps_total = 1000, # Engine control
mean_or_assurance = "assurance",
...


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

signal_parameters,
noise_parameters = 0,
predictor_type = "continuous",
binary_predictor_prevalence = NULL,
large_sample_rsquared,
model = "lm",
metric = "calibration_slope",
minimum_acceptable_performance,
n_reps_total = 1000,
mean_or_assurance = "assurance",
...


[air] reported by reviewdog 🐶

expected_performance = large_sample_rsquared)


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

signal_parameters,
noise_parameters = 0,
predictor_type = "continuous",
binary_predictor_prevalence = NULL,
large_sample_cindex,
baseline_hazard = 1,
censoring_rate,
model = "coxph",
metric = "calibration_slope",
minimum_acceptable_performance,
n_reps_total = 1000,
mean_or_assurance = "assurance",
...


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

#' @param results
#' @param p
#' @param mean


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 48 to 52 in c3613e2

output,
aggregate_fun,
var_bootstrap,
target,
ci_q = 0.975


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 116 to 130 in c3613e2

#' @param data_function
#' @param model_function
#' @param metric_function
#' @param value_on_error
#' @param start_n
#' @param test_n
#' @param n_reps_per
#' @param n_reps_total
#' @param target_performance
#' @param threshold
#' @param mean_or_assurance
#' @param c_statistic
#' @param parallel
#' @param cores
#' @param verbose


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 137 to 151 in c3613e2

data_function,
model_function,
metric_function,
value_on_error,
start_n,
test_n,
n_reps_per,
n_reps_total,
target_performance,
threshold = 0.01,
mean_or_assurance = "mean",
c_statistic = NULL,
parallel = FALSE,
cores = 20,
verbose = FALSE


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 186 to 190 in c3613e2

vals <- foreach::foreach(i = 1:n_reps_per, .combine = c) %dopar% {
single_run(n)
}


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 257 to 258 in c3613e2

if (n_new == n_current) break


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 308 to 312 in c3613e2

#' @param data_function
#' @param metric_function
#' @param target_performance
#' @param c_statistic
#' @param mean_or_assurance


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 319 to 323 in c3613e2

data_function,
metric_function,
target_performance,
c_statistic = NULL,
mean_or_assurance = c("mean", "assurance")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

if (!is.numeric(baseline_prob) ||


[air] reported by reviewdog 🐶

is.na(baseline_prob)) {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 410 to 411 in c3613e2

if (baseline_prob <= 0.2 &&


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 413 to 414 in c3613e2

mean_or_assurance == "assurance") {


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

pmsims/R/start_values.R

Lines 515 to 520 in c3613e2

npar,
prevalence = NULL,
c_stat = NULL,
calib_slope = NULL,
epv_value = NULL,
outcome_type = c("binary", "survival", "continuous")


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

Comment on lines +8 to +22
test_n,
n_reps_total,
n_reps_per,
se_final,
min_sample_size,
max_sample_size,
target_performance,
c_statistic,
mean_or_assurance,
n_init,
verbose,
data_function,
model_function,
metric_function,
value_on_error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
test_n,
n_reps_total,
n_reps_per,
se_final,
min_sample_size,
max_sample_size,
target_performance,
c_statistic,
mean_or_assurance,
n_init,
verbose,
data_function,
model_function,
metric_function,
value_on_error
test_n,
n_reps_total,
n_reps_per,
se_final,
min_sample_size,
max_sample_size,
target_performance,
c_statistic,
mean_or_assurance,
n_init,
verbose,
data_function,
model_function,
metric_function,
value_on_error

metric_function,
value_on_error
) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

@@ -434,8 +31,25 @@ calculate_mlpwr <- function(
mean_or_assurance = mean_or_assurance
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

start_max_sample_size <- start_values$start_max_sample_size
# Adaptive starting values search
cat("Estimating first stage... (Adaptive starting value search algorithm)\n")
start_values <- calculate_adaptive_bounds(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
start_values <- calculate_adaptive_bounds(
start_values <- calculate_adaptive_bounds(

model_function = model_function,
metric_function = metric_function,
value_on_error = NA,
start_n = start_values$start_min_sample_size,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change
start_n = start_values$start_min_sample_size,
start_n = start_values$start_min_sample_size,

utils::setTxtProgressBar(pb_txt, evaluations_used)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

ns <- asNamespace("mlpwr")
orig_print_progress <- get("print_progress", envir = ns)
assignInNamespace("print_progress", patched_print_progress, ns)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

Comment on lines +195 to +196


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

silent = FALSE
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

results[i, seq(1, length(perfs[[i]]$y), 1)] <- perfs[[i]]$y
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[air] reported by reviewdog 🐶

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants