View source: R/simulation-generators.R
| simulateNullDataset | R Documentation |
Generate a single no-shift simulation replicate under a uniform Brownian
motion process using the empirically calibrated covariance-generation
framework.
By default, each replicate uses the element-sampling operations from the
published simulation code. The empirical generator is available explicitly
for full-covariance draws centered on a createSimulationTemplate() object.
simulateNullDataset(
template,
tree_tip_count = NULL,
seed = NULL,
simulation_generator = c("original", "empirical"),
covariance_df = NULL
)
template |
A |
tree_tip_count |
Optional integer tip count for random subtree sampling.
If |
seed |
Optional integer random seed. When supplied, the function restores the caller's previous RNG state before returning. |
simulation_generator |
Simulation generator to use. |
covariance_df |
Optional integer degrees of freedom for empirical
Wishart draws. It must be at least the number of response traits. The
default uses the residual degrees of freedom stored in |
The default "original" generator samples marginal variance and covariance
summaries and retains the published mathematical operations exactly. Under
the explicit "empirical" generator, a new covariance matrix W is drawn as
W \sim Wishart(\nu, S / \nu), where S is the full empirical
residual covariance and \nu is covariance_df. Thus
E[W] = S: empirical integration is retained on average while individual
replicates vary.
For templates calibrated from richer global
models, the empirical fitted mean structure is added back to the simulated
residual process before the downstream intercept-only search is run on the
regenerated response block. The returned trait_data therefore contains only
the simulated response variables, even when the global calibration model
included predictors. This is the lower-level replicate generator used by
runFalsePositiveSimulationStudy(); use that wrapper for replicated
false-positive simulation workflows.
A list of class bifrost_simulation_replicate_null containing the
sampled tree, a single-regime baseline tree, the simulated response matrix,
a response-only trait_data object used for downstream model fitting, and
the generated covariance matrix, generator metadata, resolved
covariance degrees of freedom, and covariance diagnostics.
createSimulationTemplate(), simulateShiftedDataset(),
runFalsePositiveSimulationStudy()
set.seed(1)
tr <- ape::rtree(12)
X <- matrix(rnorm(12 * 2), ncol = 2)
rownames(X) <- tr$tip.label
tmpl <- createSimulationTemplate(tr, X, formula = "trait_data ~ 1", method = "LL")
sim_null <- simulateNullDataset(tmpl, tree_tip_count = 10, seed = 2)
dim(sim_null$trait_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.