| simulate_tls | R Documentation |
simulate_tls() draws survival counts from the locked data-generating
process used throughout the freqTLS test suite and benchmarks. It builds a
factorial grid of temperatures by durations by replicates, computes the true
survival probability under the selected direct-CTmax/z mean curve (the same forward map as
the TMB engine in src/profile_tls.cpp), and draws binomial or beta-binomial
counts. The simulating truth is attached as attr(, "truth").
simulate_tls(
temps = seq(30, 42, by = 2),
times = c(0.5, 1, 2, 4, 8),
reps = 3,
n = 20,
low = 0.02,
up = 0.98,
k = 5,
CTmax = 36,
z = 3,
phi = NULL,
family = c("binomial", "beta_binomial", "beta"),
group = NULL,
re_sd = NULL,
re_sd_z = NULL,
re_sd_low = NULL,
re_sd_logk = NULL,
n_re_groups = NULL,
re_group_name = "colony",
tref = 1,
seed = NULL,
curve = "loglogistic"
)
temps |
Numeric vector of assay temperatures (degrees C). |
times |
Numeric vector of exposure durations in minutes. |
reps |
Number of replicate observations per temperature-by-duration cell (per group). |
n |
Number of individuals per observation (binomial size). |
low, up |
Lower and upper survival asymptotes ( |
k |
Steepness of the logistic on the |
CTmax |
Critical thermal maximum at |
z |
Thermal sensitivity ( |
phi |
Dispersion (sum of Beta shapes); |
family |
One of |
group |
Optional atomic vector of group labels (character, factor,
or numeric). When supplied, |
re_sd |
Optional standard deviation of a random intercept on |
re_sd_z |
Optional standard deviation of a random intercept on
|
re_sd_low, re_sd_logk |
Optional standard deviations of random
intercepts on the lower asymptote |
n_re_groups |
Number of random-effect groups (required with any |
re_group_name |
Name of the grouping column added to the output for the
random-effect mode (default |
tref |
Reference time at which |
seed |
Optional integer seed for reproducibility. |
curve |
Mean-survival curve: |
phi conventionFor the beta-binomial family, phi is the sum of the Beta shape
parameters: counts are drawn as prob <- rbeta(a = p * phi, b = (1 - p) * phi) followed by rbinom(n, prob). The Beta mean is p and its variance is
p (1 - p) / (phi + 1), so larger phi means less overdispersion and the
binomial is recovered as phi -> Inf. This matches the engine's
parameterisation in beta_binomial_tls().
A base data.frame with columns temp, duration, the true
probability p, and (when grouped) group. The count families
(binomial, beta_binomial) add total and survived; the beta family
instead adds a single continuous proportion column prop. The
data-generating parameters are attached as attr(, "truth").
d <- simulate_tls(family = "binomial", CTmax = 36, z = 4, seed = 1)
head(d)
attr(d, "truth")$CTmax
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.