View source: R/simulation-template.R
| createSimulationTemplate | R Documentation |
bifrostFit a global single-regime multivariate GLS model to an empirical dataset and convert the fitted object into a reusable calibration template for null and shift-recovery simulation studies.
createSimulationTemplate(
baseline_tree,
trait_data,
formula = "trait_data ~ 1",
response_columns = NULL,
predictor_columns = NULL,
...
)
baseline_tree |
A rooted phylogenetic tree of class |
trait_data |
A numeric matrix or data frame containing the empirical data
used to parameterize the simulations. Row names must be unique, non-empty,
and match |
formula |
Formula specification passed to |
response_columns |
Optional column specification identifying the
multivariate response. May be integer positions, character column names, or
a mix resolvable against |
predictor_columns |
Optional column specification identifying predictor
columns used by the global calibration model. For named-column formulas
these are usually inferred from the formula itself. For non-intercept
workflows where |
... |
Additional arguments passed to |
The returned template stores:
the aligned empirical tree and calibration data,
the fitted global mvgls model,
evaluated copies of key fit settings (fit_method, fit_error) that
can be reused safely by downstream simulation-study wrappers,
the fitted response mean structure,
the full empirical residual covariance and residual degrees of freedom used by the empirical Wishart generator, and
summaries of the diagonal and off-diagonal elements
(variance_mean, variance_sd, covariance_mean, covariance_sd)
retained by the manuscript-reproduction generator.
The template is a calibration object, not a full simulation-study design. Its
formula defines the one global mean model used to estimate fitted values and
residual covariance structure. Downstream simulation studies then regenerate
the response block around those fitted means and evaluate intercept-only
shift-search behavior on the simulated responses. In other words, a richer
calibration model can still feed the response-only trait_data ~ 1
simulation workflow. Predictor columns are retained in the template for
calibration provenance, but simulated replicates returned by the study
helpers contain the regenerated response block only.
Internally, all supported formulas are normalized into a single simulation
formula specification. Indexed trait_data formulas are rewritten onto named
columns, formula objects are accepted alongside character strings, predictor
schemas record numeric/logical/factor/ordered predictors, and unsupported
forms such as transformed responses, . shorthand, and character predictors
are rejected early.
A list of class bifrost_simulation_template containing the aligned
inputs, fitted global model, empirical mean structure, response/predictor
column metadata, stored fit settings, the empirical residual covariance and
degrees of freedom, and covariance summaries used for simulation.
simulateNullDataset(), simulateShiftedDataset(),
runFalsePositiveSimulationStudy(), runShiftRecoverySimulationStudy(),
searchOptimalConfiguration()
set.seed(1)
tr <- ape::rtree(12)
X <- matrix(rnorm(12 * 2), ncol = 2)
rownames(X) <- tr$tip.label
tmpl <- createSimulationTemplate(
baseline_tree = tr,
trait_data = X,
formula = "trait_data ~ 1",
method = "LL"
)
tmpl
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.