Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6f40426
Update README; add logo
ewancarr Nov 7, 2025
9755095
Add logo
ewancarr Nov 12, 2025
0402199
Fix image paths
ewancarr Nov 12, 2025
52af683
Remove devtools requirement
ewancarr Nov 12, 2025
d142983
Fix missing images
ewancarr Nov 12, 2025
8c51f0e
Use cache for README.Rmd to prevent long runs
ewancarr Nov 12, 2025
b558f54
Fix alt text
ewancarr Nov 12, 2025
1d23c21
edits to simulate binary to restrict args using match.args
GForb Nov 20, 2025
617e7dc
edits to simulate continuous to restrict args using match.args
GForb Nov 20, 2025
b174b9a
edits to simulate survival to restrict args using match.args
GForb Nov 20, 2025
e4557e1
Merge pull request #75 from pmsims-package/dev-add-match-arg
GForb Nov 25, 2025
ff471a7
adding custom check args function to use in place of match.arg
GForb Nov 27, 2025
a26a0ff
Fix box around print title
ewancarr Nov 27, 2025
4a714e7
removing the option to have binary predictors
GForb Nov 27, 2025
0d93abc
Add input validation of binary prevalence
ewancarr Nov 27, 2025
5f948f4
Update R/simulate_wrappers.R
ewancarr Nov 27, 2025
901c018
Update R/simulate_wrappers.R
ewancarr Nov 27, 2025
c6b0f78
Merge pull request #77 from pmsims-package/bug-fix-beta-testing
GForb Nov 27, 2025
ab7a913
adding informative error message to generate predictors
GForb Nov 27, 2025
b69f2b6
adding cli to DESCRIPTION
GForb Nov 27, 2025
e028710
resolving conflicts to merge with updates to main
GForb Nov 27, 2025
5e82a46
removing unecessary @exports
GForb Nov 27, 2025
d6875f4
updates to package from call to document()
GForb Nov 27, 2025
1de3d55
Update R/input_validation.R
GForb Nov 27, 2025
63d52eb
Update R/input_validation.R
GForb Nov 27, 2025
68693bd
Update R/data_generators.R
ewancarr Nov 28, 2025
98482be
Apply suggestions from code review
ewancarr Nov 28, 2025
4b11b9f
Apply suggestions from code review
ewancarr Nov 28, 2025
534ce5c
Formatting
ewancarr Nov 28, 2025
52b8377
Merge pull request #78 from pmsims-package/bug-fix-binary-predictors
ewancarr Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Imports:
utils,
glmnet,
ranger,
pec
pec,
cli
Suggests:
testthat (>= 3.0.0),
covr,
Expand Down
73 changes: 0 additions & 73 deletions Makefile

This file was deleted.

8 changes: 0 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
S3method(plot,pmsims)
S3method(print,pmsims)
S3method(summary,pmsims)
export(calculate_bisection)
export(calculate_mlpwr_bs)
export(generate_binary_data)
export(objective_function)
export(parse_inputs)
export(predict_custom)
export(simulate_binary)
export(simulate_continuous)
export(simulate_custom)
export(simulate_survival)
export(survival_tuning)
importFrom(survival,Surv)
importFrom(utils,setTxtProgressBar)
importFrom(utils,txtProgressBar)
8 changes: 7 additions & 1 deletion R/data_generators.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ generate_continuous_data <- function(
#'
#' @return A data frame with one outcome column and n_signal_parameters + noise_parameters predictor columns
#' @keywords internal
#' @export

generate_binary_data <- function(
n,
mu_lp,
Expand Down Expand Up @@ -145,6 +145,12 @@ update_arguments <- function(fn, opts) {

generate_predictors <- function(n, parameters, type, predictor_prop) {
if (type == "binary") {
if (is.null(predictor_prop)) {
stop("predictor_prop must be provided when predictor type is binary")
}
if (predictor_prop < 0 || predictor_prop > 1) {
stop("predictor_prop must be between 0 and 1")
}
X <- stats::rbinom(n * parameters, 1, predictor_prop)
} else if (type == "continuous") {
X <- stats::rnorm(n * parameters)
Expand Down
4 changes: 2 additions & 2 deletions R/engines.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ calculate_mlpwr <- function(
#' @return A list containing the simulation `results`, performance `summaries`,
#' optional tracking `history`, and the `track_bisection` records.
#' @keywords internal
#' @export

calculate_bisection <- function(
data_function = data_function,
model_function = model_function,
Expand Down Expand Up @@ -549,7 +549,7 @@ calculate_bisection <- function(
#'
#' @return List containing the combined bisection and mlpwr results (`results`, `summaries`, `min_n`, `perf_n`, and `mlpwr_ds`).
#' @keywords internal
#' @export

calculate_mlpwr_bs <- function(
test_n,
n_reps_total,
Expand Down
67 changes: 67 additions & 0 deletions R/input_validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,70 @@ validate_metric_constraints <- function(metric,
}
}
}




Comment on lines +35 to +36
Copy link
Copy Markdown
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

validate_outcome_prevalence <- function(outcome_prevalence) {
if (is.null(outcome_prevalence)) {
cli::cli_abort("`outcome_prevalence` must be specified.")
}

if (outcome_prevalence < 0.05) {
cli::cli_alert_warning(
"Outcome prevalence is very low ({.val {outcome_prevalence}}). Recommended > {.val 0.05}; values below this haven’t been tested, and simulations may take a long time."
)
}

invisible(TRUE)
}

#' check_pmsims_args - a custom version of the base R match.arg function with improved error message
#'
#'@inherit base::match.arg
#'
check_pmsims_args <- function(arg, choices, several.ok = FALSE) {
if (missing(choices)) {
formal.args <- formals(sys.function(sysP <- sys.parent()))
choices <- eval(
formal.args[[as.character(substitute(arg))]],
envir = sys.frame(sysP)
)
}
arg_name <- as.character(substitute(arg))

if (is.null(arg)) {
return(choices[1L])
} else if (!is.character(arg)) {
stop(paste0(arg_name, " must be NULL or a character vector"))
}
if (!several.ok) {
if (identical(arg, choices)) {
return(arg[1L])
}
if (length(arg) > 1L) {
stop(paste0(arg_name, " must be of length 1"))
}
} else if (length(arg) == 0L) {
stop(paste0(arg_name, " must be of length >= 1"))
}
i <- pmatch(arg, choices, nomatch = 0L, duplicates.ok = TRUE)
if (all(i == 0L)) {
stop(
sprintf(
ngettext(
length(chs <- unique(choices[nzchar(choices)])),
sprintf("'%s' should be %%s", arg_name),
sprintf("'%s' should be one of %%s", arg_name)
),
paste(dQuote(chs), collapse = ", ")
),
domain = NA
)
}
i <- i[i > 0L]
if (!several.ok && length(i) > 1) {
stop("there is more than one match in 'check_pmsims_args'")
}
choices[i]
}
2 changes: 1 addition & 1 deletion R/metric_generators.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ default_metric_generator <- function(metric, data_function) {
}

#' @keywords internal
#' @export

predict_custom <- function(x, y, fit, model, type = "response") {
if (model == "glm") {
stats::predict(fit, newdata = x, type = type)
Expand Down
1 change: 0 additions & 1 deletion R/pmsims_objective_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#'
#' @return A single numeric: the objective value at \eqn{n}.
#' @keywords internal
#' @export
#'
#' @examples
#' # \dontrun{
Expand Down
Loading
Loading