| Title: | Dependency-Aware Scenario Exploration for Group Sequential Designs |
|---|---|
| Description: | Provides systematic, dependency-aware exploration of group sequential designs created with 'gsDesign'. Supports reproducible grid and random search over user-defined candidate sets, parallel evaluation via the 'future' framework, standardized metric extraction, and auditable reporting for design space evaluation and trade-off analysis. Methods for group sequential design are described in Anderson (2025) <doi:10.32614/CRAN.package.gsDesign>. The 'future' framework for parallel processing is described in Bengtsson (2021) <doi:10.32614/RJ-2021-048>. |
| Authors: | Nan Xiao [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-0250-5673>) |
| Maintainer: | Nan Xiao <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-13 09:37:48 UTC |
| Source: | https://github.com/nanxstats/gsdesigntune |
gsDesign::gsDesign()
gsDesignTune() is a drop-in replacement for gsDesign::gsDesign() that
returns a tune job object instead of immediately running a single design.
gsDesignTune(..., upper = NULL, lower = NULL)gsDesignTune(..., upper = NULL, lower = NULL)
... |
Arguments to |
upper, lower
|
Optional spending specifications provided as
|
Any argument can be replaced by a tuning specification created by tune_*().
Use SpendingSpec / SpendingFamily via upper= and lower= for
dependency-aware spending function tuning.
A GSDTuneJob R6 object.
job <- gsDesignTune( k = 3, test.type = 4, alpha = tune_values(list(0.025, 0.03)) ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())job <- gsDesignTune( k = 3, test.type = 4, alpha = tune_values(list(0.025, 0.03)) ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())
GSDTuneJob
GSDTuneJob
R6 class representing a dependency-aware tuning job for group sequential
designs created by gsDesign::gsDesign() or gsDesign::gsSurv().
An R6 class generator. Use $new() to create a GSDTuneJob object.
targetTarget design function name ("gsDesign" or "gsSurv").
base_argsNamed list of fixed arguments passed to the target function.
tune_specsNamed list of tuning specifications for explored arguments.
param_spaceInternal parameter space used for configuration generation.
specAudit record including base/tuned args and sessionInfo().
new()
Create a new tune job.
GSDTuneJob$new(target = c("gsDesign", "gsSurv", "gsSurvCalendar"), args)targetTarget function name ("gsDesign", "gsSurv", or "gsSurvCalendar").
argsNamed list of evaluated arguments.
run()
Evaluate configurations under a search strategy.
GSDTuneJob$run(
strategy = c("grid", "random"),
n = NULL,
parallel = TRUE,
seed = NULL,
cache_dir = NULL,
metrics_fun = NULL
)strategySearch strategy ("grid" or "random").
nNumber of configurations for random search.
parallelWhether to evaluate configurations in parallel.
seedOptional seed for reproducibility.
cache_dirOptional directory to cache design objects as RDS.
metrics_funOptional metric hook.
results()
Return the results data.frame.
GSDTuneJob$results()
summarize()
Summarize the run (counts + numeric metric summaries).
GSDTuneJob$summarize()
table()
Render a compact results table with tinytable.
Returns a tinytable object which knits to HTML/LaTeX automatically in
R Markdown and can also be printed explicitly with
print(x, output = "html") or print(x, output = "latex").
GSDTuneJob$table( data = NULL, columns = NULL, n = NULL, caption = NULL, notes = NULL, digits = 3, theme = "striped" )
dataOptional results-like data.frame to render. Defaults to
$results().
columnsOptional character vector of columns to display, in order.
When NULL, a compact default set is chosen automatically. Explicit
column selections are preserved, including audit/internal columns.
nOptional number of rows to display.
captionOptional table caption.
notesOptional table notes passed to tinytable::tt().
digitsNumber of digits for numeric columns.
themeTinytable theme passed to tinytable::tt(). Defaults to
"striped".
design()
Retrieve a design object for configuration i.
GSDTuneJob$design(i)
iRow index of the configuration.
call_args()
Return the underlying argument list for configuration i.
GSDTuneJob$call_args(i)
iRow index of the configuration.
best()
Rank configurations by a metric (with optional constraints).
GSDTuneJob$best(metric, direction = c("min", "max"), constraints = NULL)metricMetric column name.
directionRanking direction ("min" or "max").
constraintsOptional constraints (function or expression).
pareto()
Compute a Pareto (non-dominated) set for multiple metrics.
GSDTuneJob$pareto(metrics, directions)
metricsMetric column names.
directionsDirections for each metric ("min"/"max").
plot()
Create a quick exploration plot.
GSDTuneJob$plot(metric, x, color = NULL, facet = NULL)
metricY-axis metric column name.
xX-axis column name.
colorOptional color column name.
facetOptional faceting column name.
report()
Render an HTML report.
GSDTuneJob$report(path)
pathOutput HTML file path.
clone()
The objects of this class are cloneable with this method.
GSDTuneJob$clone(deep = FALSE)
deepWhether to make a deep clone.
job <- GSDTuneJob$new(target = "gsDesign", args = list(k = 3, alpha = 0.025)) job$spec$targetjob <- GSDTuneJob$new(target = "gsDesign", args = list(k = 3, alpha = 0.025)) job$spec$target
gsDesign::gsSurvCalendar()
gsSurvCalendarTune() is a drop-in replacement for
gsDesign::gsSurvCalendar() that returns a tune job object instead of
immediately running a single design.
gsSurvCalendarTune(..., upper = NULL, lower = NULL)gsSurvCalendarTune(..., upper = NULL, lower = NULL)
... |
Arguments to |
upper, lower
|
Optional spending specifications provided as
|
Any argument can be replaced by a tuning specification created by tune_*().
Use SpendingSpec / SpendingFamily via upper= and lower= for
dependency-aware spending function tuning.
A GSDTuneJob R6 object.
job <- gsSurvCalendarTune( calendarTime = tune_values(list(c(12, 24, 36), c(12, 24, 48))), spending = c("information", "calendar") ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())job <- gsSurvCalendarTune( calendarTime = tune_values(list(c(12, 24, 36), c(12, 24, 48))), spending = c("information", "calendar") ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())
gsDesign::gsSurv()
gsSurvTune() is a drop-in replacement for gsDesign::gsSurv() that
returns a tune job object instead of immediately running a single design.
gsSurvTune(..., upper = NULL, lower = NULL)gsSurvTune(..., upper = NULL, lower = NULL)
... |
Arguments to |
upper, lower
|
Optional spending specifications provided as
|
Any argument can be replaced by a tuning specification created by tune_*().
Use SpendingSpec / SpendingFamily via upper= and lower= for
dependency-aware spending function tuning.
A GSDTuneJob R6 object.
job <- gsSurvTune( k = 3, test.type = 4, hr = tune_values(list(0.6, 0.7)) ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())job <- gsSurvTune( k = 3, test.type = 4, hr = tune_values(list(0.6, 0.7)) ) job$run(strategy = "grid", parallel = FALSE, seed = 1) utils::head(job$results())
SpendingSpec and SpendingFamily provide a dependency-aware and
user-friendly way to tune spending functions and their parameters.
SpendingFamily
SpendingFamily
An R6 class representing a set of spending function specifications. Each
family member is a SpendingSpec.
An R6 class generator. Use $new() to create a SpendingFamily object.
membersList of SpendingSpec objects.
new()
Create a new spending family from one or more SpendingSpec.
SpendingFamily$new(...)
...SpendingSpec objects.
expand()
Expand all members to spending settings.
SpendingFamily$expand()
clone()
The objects of this class are cloneable with this method.
SpendingFamily$clone(deep = FALSE)
deepWhether to make a deep clone.
fam <- SpendingFamily$new( SpendingSpec$new(gsDesign::sfHSD, par = tune_fixed(-4)), SpendingSpec$new(gsDesign::sfLDOF, par = tune_fixed(0)) ) fam$expand()fam <- SpendingFamily$new( SpendingSpec$new(gsDesign::sfHSD, par = tune_fixed(-4)), SpendingSpec$new(gsDesign::sfLDOF, par = tune_fixed(0)) ) fam$expand()
SpendingSpec
SpendingSpec
An R6 class representing a single spending function (fun) and a tuning
specification for its parameter (par).
An R6 class generator. Use $new() to create a SpendingSpec object.
funSpending function (callable with signature (alpha, t, param)).
fun_labelLabel captured from the constructor call (used for plotting).
parTuning specification for the spending parameter.
new()
Create a new spending specification.
SpendingSpec$new(fun, par = tune_fixed(NULL))
funSpending function.
parSpending parameter specification.
expand()
Expand to a list of spending settings (fun + concrete parameter values).
SpendingSpec$expand()
clone()
The objects of this class are cloneable with this method.
SpendingSpec$clone(deep = FALSE)
deepWhether to make a deep clone.
spec <- SpendingSpec$new(gsDesign::sfHSD, par = tune_seq(-4, -2, length_out = 2)) spec$expand()spec <- SpendingSpec$new(gsDesign::sfHSD, par = tune_seq(-4, -2, length_out = 2)) spec$expand()
gsDesignTune() uses function-valued columns (for example, spending functions)
in results tables. This method provides a stable, readable label for such
functions to keep printing and plotting robust.
## S3 method for class ''function'' toString(x, ...)## S3 method for class ''function'' toString(x, ...)
x |
A function. |
... |
Unused (included for S3 method compatibility). |
A character scalar.
toString(stats::rnorm)toString(stats::rnorm)
tune_choice() defines a finite set of categorical choices. Each argument in
... is treated as one choice (including functions and other objects).
tune_choice(...)tune_choice(...)
... |
Candidate values. |
A gstune_spec object.
tune_choice("A", "B")tune_choice("A", "B")
tune_dep() defines candidates for one argument as a function of other
arguments.
tune_dep(depends_on, map)tune_dep(depends_on, map)
depends_on |
Character vector of argument names this specification depends on. |
map |
A function returning either a |
A gstune_spec object.
# sfupar depends on sfu tune_dep( depends_on = "sfu", map = function(sfu) { if (identical(sfu, gsDesign::sfLDOF)) tune_fixed(0) else tune_seq(-4, 4, 9) } )# sfupar depends on sfu tune_dep( depends_on = "sfu", map = function(sfu) { if (identical(sfu, gsDesign::sfLDOF)) tune_fixed(0) else tune_seq(-4, 4, 9) } )
Use tune_fixed() to explicitly mark a value as fixed. This is mainly useful
inside dependent specifications such as tune_dep().
tune_fixed(x)tune_fixed(x)
x |
Any R object. |
A gstune_spec object.
tune_fixed(0.025)tune_fixed(0.025)
Integer sequence candidates
tune_int(from, to, by = 1)tune_int(from, to, by = 1)
from, to
|
Integer scalars. |
by |
Integer scalar step size. |
A gstune_spec object.
tune_int(2, 5)tune_int(2, 5)
Numeric sequence candidates
tune_seq(from, to, length_out)tune_seq(from, to, length_out)
from, to
|
Numeric scalars. |
length_out |
Integer scalar, the number of candidates. |
A gstune_spec object.
tune_seq(0.55, 0.75, length_out = 5)tune_seq(0.55, 0.75, length_out = 5)
gsDesignTune() and gsSurvTune() treat most arguments as fixed values.
Wrap an argument in a tune_*() specification to explore candidate values.
tune_values() defines a finite set of candidate values.
Values are provided as a list so vector-valued candidates
(for example, timing) are treated as atomic.
tune_values(values)tune_values(values)
values |
A list of candidate values. |
A gstune_spec object.
tune_values(list(0.55, 0.65, 0.75)) tune_values(list(c(0.33, 0.67, 1), c(0.5, 0.75, 1)))tune_values(list(0.55, 0.65, 0.75)) tune_values(list(c(0.33, 0.67, 1), c(0.5, 0.75, 1)))