plot_history {adaptr} | R Documentation |
Plot trial metric history
Description
Plots the history of relevant metrics over the progress of a single or
multiple trial simulations. Simulated trials only contribute until the
time they are stopped, i.e., if some trials are stopped earlier than others,
they will not contribute to the summary statistics at later adaptive looks.
Data from individual arms in a trial contribute until the complete trial is
stopped.
These history plots require non-sparse results (sparse
set to
FALSE
; see run_trial()
and run_trials()
) and the ggplot2
package
installed.
Usage
plot_history(object, x_value = "look", y_value = "prob", line = NULL, ...)
## S3 method for class 'trial_result'
plot_history(object, x_value = "look", y_value = "prob", line = NULL, ...)
## S3 method for class 'trial_results'
plot_history(
object,
x_value = "look",
y_value = "prob",
line = NULL,
ribbon = list(width = 0.5, alpha = 0.2),
cores = NULL,
...
)
Arguments
object |
|
x_value |
single character string, determining whether the number of
adaptive analysis looks ( |
y_value |
single character string, determining which values are plotted
on the y-axis. The following options are available: allocation
probabilities ( |
line |
list styling the lines as per |
... |
additional arguments, not used. |
ribbon |
list, as |
cores |
|
Value
A ggplot2
plot object.
See Also
Examples
#### Only run examples if ggplot2 is installed ####
if (requireNamespace("ggplot2", quietly = TRUE)){
# Setup a trial specification
binom_trial <- setup_trial_binom(arms = c("A", "B", "C", "D"),
control = "A",
true_ys = c(0.20, 0.18, 0.22, 0.24),
data_looks = 1:20 * 100)
# Run a single simulation with a fixed random seed
res <- run_trial(binom_trial, seed = 12345)
# Plot total allocations to each arm according to overall total allocations
plot_history(res, x_value = "total n", y_value = "n")
}
if (requireNamespace("ggplot2", quietly = TRUE)){
# Run multiple simulation with a fixed random base seed
# Notice that sparse = FALSE is required
res_mult <- run_trials(binom_trial, n_rep = 15, base_seed = 12345, sparse = FALSE)
# Plot allocation probabilities at each look
plot_history(res_mult, x_value = "look", y_value = "prob")
# Other y_value options are available but not shown in these examples
}