| fit_tls | R Documentation |
fit_tls() fits a descending thermal-survival model to binomial or
beta-binomial counts, or to continuous proportions with the Beta family.
The default mean curve is the four-parameter log-logistic curve; log-normal
and two Weibull curves are opt-in alternatives. The model uses CTmax (the
critical thermal maximum at reference time tref) and z (thermal
sensitivity, degrees Celsius per decade of duration) as direct coordinates,
so both headline quantities can be profiled. Survival is a function of
log10(duration), with its midpoint moving through CTmax and z. The
default curve preserves the matched bayesTLS benchmark; optional curves use
curve-specific steepness scales k (see vignette("model-math")). The
thermal-load-sensitivity modelling framework was introduced by Daniel W. A.
Noble, Pieter A. Arnold, Shinichi Nakagawa, and Patrice Pottier in
bayesTLS.
fit_tls(
x,
y,
n,
time,
temp,
group = NULL,
family = c("beta_binomial", "binomial", "beta"),
tref = NULL,
start = NULL,
control = list(),
trace = FALSE,
quiet = FALSE,
data = NULL,
left_censored = NULL,
censor_limit = NULL,
bounds = c(0, 1),
fixed_low = NULL,
fixed_up = NULL,
curve = "loglogistic"
)
x |
Either a data frame (column interface) or a |
y |
< |
n |
< |
time |
< |
temp |
< |
group |
< |
family |
One of |
tref |
Reference time at which |
start |
Optional named list of starting values on the internal
(unconstrained) scale, overriding the defaults. Names must match the
parameters in |
control |
List of optimiser controls; |
trace |
Logical scalar; print optimiser progress. |
quiet |
Logical; if |
data |
Used only in the formula interface: the data frame the
|
left_censored |
Optional non-missing logical vector marking Beta
observations known only to lie below a detection limit. Supply it together
with |
censor_limit |
Numeric scalar or one value per observation giving the
explicit lower detection limit for |
bounds |
Finite ordered lower and upper limits for the asymptotes.
Defaults to |
fixed_low |
Optional exact natural-scale value for the constant lower asymptote. It must stay below the estimated upper band. |
fixed_up |
Optional exact natural-scale value for the constant upper asymptote. It must stay above the estimated lower band. Fix both for a 2PL. |
curve |
Mean-survival curve: |
There are two equivalent interfaces. In the column interface, columns are
referenced with tidy evaluation: pass the bare column names of data (as in
dplyr), not strings. In the formula interface, pass a tls_bf() object
as x and the data frame as data; the brms/drmTMB-style grammar names the
response, the two axes, and the CTmax / log_z predictors. Both interfaces
feed the same likelihood engine, so a grouped formula fit and the matching
group = column fit are numerically identical.
An object of class c("profile_tls", "tls_fit"): a list with the
call, the resolved family, tref, group_levels, a data_summary, the
internal-scale MLE par, an estimates data frame of natural-scale
parameters with standard errors, the vcov of the internal coordinates,
the logLik, residual df, AIC, a convergence list
(code/pdHess/message), the name_map, and the underlying TMB obj,
optimiser opt, and sdreport. $curve records the selected mean curve.
Use freqTLS at your own risk. Results and APIs may be incorrect or change. Users are responsible for checking their data, design, model specification, convergence, identifiability, diagnostics, and interpretation. Important analyses should be independently refitted and cross-checked with bayesTLS (source repository). Agreement is a cross-check, not proof of correctness; shared data or model errors can make both packages agree.
Run check_tls() on the fitted object. Its help page maps every
data-adequacy warning to a concrete design or analysis response.
vignette("profile-likelihood") explains open profiles and their method-
specific fallbacks: bootstrap for fixed-effects fits and Wald for random-
effects fits.
check_tls(), confint.profile_tls()
d <- simulate_tls(family = "binomial", times = c(30, 60, 120, 240, 480),
CTmax = 36, z = 4, tref = 60, seed = 1)
fit <- fit_tls(d, y = survived, n = total, time = duration, temp = temp,
family = "binomial", tref = 60)
fit$estimates
# The same fit through the formula interface:
fit2 <- fit_tls(
tls_bf(survived | trials(total) ~ time(duration) + temp(temp)),
data = d, family = "binomial", tref = 60
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.