View source: R/sequential-analysis.R
| sequential_analysis | R Documentation |
Fits the prespecified model to the data accumulated so far, computes the monitored posterior probability, applies the prespecified stopping threshold for the current look, and records the result in an auditable monitor object. Call it once per interim look, passing the design on the first call and the returned monitor object on subsequent calls.
The monitor refuses to continue after a stop decision has been recorded
unless allow_after_stop = TRUE, in which case the continuation is
logged as a protocol deviation. Analyses at sample sizes that do not
match the planned schedule are permitted but flagged and recorded.
sequential_analysis(
x,
data,
Ntrials_col = NULL,
allow_after_stop = FALSE,
note = NULL,
inla_num_threads = NULL
)
x |
A |
data |
Data frame containing all data accumulated so far (not just the new batch). Must contain the variables in the design formula. |
Ntrials_col |
Optional name of a column with binomial trial counts
(binomial/beta-binomial families). Defaults to a column named
|
allow_after_stop |
Logical; permit analysis after a recorded stop
decision (logged as a deviation). Default |
note |
Optional character note recorded with this look (e.g. reason for an off-schedule analysis). |
inla_num_threads |
INLA threads ("outer:inner"); auto-detected if
|
A list of class "powerbrmsINLA_seq_monitor" containing the
design, its fingerprint, a looks data frame (one row per analysis:
timestamp, n, planned n, estimate, credible interval, monitored
probability, thresholds, decision, deviations), and the current
status ("ongoing" or a stop decision).
sequential_design(), plot_sequential_monitor(),
brms_inla_sequential_trial()
## Not run:
design <- sequential_design(
formula = y ~ treatment, effect_name = "treatment",
metric = "direction", looks = c(40, 80, 120),
prob_success = 0.95, prob_futility = 0.05
)
# After the first 40 observations have been collected:
mon <- sequential_analysis(design, data_so_far)
print(mon)
# After 80:
mon <- sequential_analysis(mon, data_so_far)
plot_sequential_monitor(mon)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.