View source: R/simulation-studies.R
| runFalsePositiveSimulationStudy | R Documentation |
Repeatedly simulate null datasets from a
createSimulationTemplate() object and analyze
each replicate with searchOptimalConfiguration() to estimate the expected
false-positive behavior of a candidate bifrost search setup.
runFalsePositiveSimulationStudy(
template,
n_replicates,
tree_tip_count = NULL,
simulation_options = list(),
search_options = list(),
num_cores = 1,
seed = NULL
)
template |
A |
n_replicates |
Integer number of simulation replicates to run. |
tree_tip_count |
Optional integer tip count for random subtree sampling.
If |
simulation_options |
Named list of additional arguments passed to
|
search_options |
Named list of arguments passed to
|
num_cores |
Integer number of workers used across replicate analyses.
When greater than one, outer replicate parallelism takes precedence and
each inner search is forced to |
seed |
Optional integer random seed. When supplied, the wrapper restores the caller's previous RNG state before returning. |
Simulated datasets, search results, a per-replicate summary table, and a
compact study summary are returned in a single object of class
bifrost_simulation_study.
Regardless of the global calibration model used to build template, the
downstream search is intentionally restricted to intercept-only formulas.
This keeps the simulation study focused on branch-shift detection in the
response block, matching the residual-calibration logic. The
simulated trait_data supplied to each search result therefore contains only
the regenerated response variables.
Templates calibrated with covariates are supported; those covariates influence
the fitted means and residual covariance used to generate each response block,
but they are not re-fit within each simulated search replicate.
Failed search replicates are retained in the output, but their inferred-shift
and false-positive metrics are recorded as NA and excluded from scientific
summaries. Their error messages and candidate counts remain available for
diagnosis, and completion and failure rates are reported separately.
Reproducibility for replicated studies is controlled by the wrapper-level
seed argument. A supplied seed deterministically creates separate
per-replicate simulation and search streams, so serial and parallel runs use
the same replicate-level random draws. Parallel execution also uses
future.seed = TRUE; per-replicate simulator seeds are intentionally
disallowed here.
If no replicate yields an evaluable false-positive rate, the study-level mean
and median false-positive summaries are returned as NA.
A list of class bifrost_simulation_study containing the simulated
datasets, raw search results, a per-replicate summary table, and a compact
study-level summary for the null scenario.
simulateNullDataset(), runShiftRecoverySimulationStudy(),
searchOptimalConfiguration()
set.seed(1)
tr <- ape::rtree(14)
X <- matrix(rnorm(14 * 2), ncol = 2)
rownames(X) <- tr$tip.label
tmpl <- createSimulationTemplate(tr, X, formula = "trait_data ~ 1", method = "LL")
fp_study <- runFalsePositiveSimulationStudy(
tmpl,
n_replicates = 1,
tree_tip_count = 12,
search_options = list(
formula = "trait_data ~ 1",
min_descendant_tips = 2,
shift_acceptance_threshold = 5,
num_cores = 1,
IC = "GIC",
method = "LL",
plot = FALSE,
progress = FALSE,
verbose = FALSE,
store_model_fit_history = FALSE
),
num_cores = 1,
seed = 2
)
fp_study
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.