knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4, dpi = 96 )
This vignette is the mathematical reference for freqTLS: its thermal-survival
mean curves, the direct CTmax/z parameterisation, the
disjoint-bounds asymptote transform, the relative-versus-absolute survival threshold, and the
algebraic bridge to bayesTLS. The
thermal-load-sensitivity framework was introduced by Daniel W. A. Noble, Pieter A.
Arnold, Shinichi Nakagawa, and Patrice Pottier in bayesTLS.
The package's implementation contract is tested against these equations; this vignette
mirrors it and checks the bridge identities numerically (no Stan required). If you
already understand the matched-configuration bridge to bayesTLS, you can skip
straight to the worked examples in vignette("freqTLS") and
vignette("comparing-to-bayesTLS").
library(freqTLS)
Let $d$ be exposure duration and $\log d = \log_{10} d$. By default, survival follows the descending four-parameter log-logistic curve
$$ p = \mathrm{low} + \frac{\mathrm{up} - \mathrm{low}}{1 + \exp!\big(k\,(\log_{10} d - \mathrm{mid})\big)}, \qquad k = \exp(\ln k). $$
Survival is high at short durations and falls toward $\mathrm{low}$ at long durations.
fit_tls() also fits a log-normal curve and two midpoint-centred Weibull
curves. They use the same midpoint and asymptotes, but their normalized shapes
and steepness scales differ. Let
$\eta = k(\log_{10} d - \mathrm{mid})$ and
$q = (p - \mathrm{low})/(\mathrm{up} - \mathrm{low})$. The curve-specific maps
are:
| Curve | Normalized survival $q(\eta)$ | Inverse $\eta(q)$ | |:--|:--|:--| | Log-logistic (default) | $\operatorname{logit}^{-1}(-\eta)$ | $-\operatorname{logit}(q)$ | | Log-normal | $\Phi(-\eta)$ | $-\Phi^{-1}(q)$ | | Weibull type 1 | $\exp{-\log(2)\exp(\eta)}$ | $\log{-\log(q)/\log(2)}$ | | Weibull type 2 | $1-\exp{-\log(2)\exp(-\eta)}$ | $-\log{-\log(1-q)/\log(2)}$ |
Every curve reaches halfway between low and up at $\eta = 0$.
Therefore CTmax still identifies the temperature where the relative
midpoint occurs at tref, and z still controls how that midpoint moves
with temperature. k depends on the selected curve, so compare its numerical
value across families only after converting to a common slope definition.
Use fit_lognormal(), fit_weibull(type = 1), or fit_weibull(type = 2) to
select an alternative. These wrappers set curve to "lognormal",
"weibull1", and "weibull2", respectively; fit_tls() accepts those same
values when all other fitting arguments are held constant. Only the log-logistic
default is matched to the bayesTLS benchmark. For example,
simulate from and fit the log-normal model with:
d_ln <- simulate_tls( family = "binomial", curve = "lognormal", temps = seq(32, 40, by = 2), times = c(15, 30, 60, 120, 240), reps = 4, n = 80, CTmax = 36, z = 4, tref = 60, seed = 2 ) fit_ln <- fit_lognormal( d_ln, y = survived, n = total, time = duration, temp = temp, family = "binomial", tref = 60 ) fit_ln$curve
CTmax/z parameterisationfreqTLS lets temperature enter the midpoint directly through the two headline
quantities. With $z_i = \exp(\eta_{\log z, i})$ and $\mathrm{CTmax}_i$ a function of the
design,
$$ \mathrm{mid}i = \log{10}(t_\mathrm{ref}) - \frac{T_i - \mathrm{CTmax}_i}{z_i}. $$
This parameterisation makes the two biological quantities direct model parameters, so profile likelihood can constrain them directly:
CTmax is the temperature at which the threshold crossing occurs at the reference
time $t_\mathrm{ref}$.z is the change in temperature per order of magnitude (a one-unit
change in $\log_{10}$ duration) — the thermal sensitivity in degrees Celsius
per 10-fold change in exposure duration.Because CTmax and z are model parameters (not derived afterwards), each can be
profiled directly. We can check the two properties on a fitted model:
set.seed(1) dat <- simulate_tls( family = "binomial", CTmax = 36, z = 4, times = c(30, 60, 120, 240, 480), tref = 60, seed = 1 ) fit <- fit_tls(dat, y = survived, n = total, time = duration, temp = temp, family = "binomial", tref = 60) ct <- get_ctmax(fit)$estimate zz <- get_z(fit)$estimate # (1) midpoint at temp = CTmax equals log10(tref) = log10(60) predict(fit, data.frame(temp = ct, duration = 60), type = "midpoint") # (2) midpoint slope in temperature is -1/z mids <- predict(fit, data.frame(temp = c(ct, ct + 1), duration = 60), type = "midpoint") c(slope = diff(mids), minus_one_over_z = -1 / zz)
The asymptotes use the bayesTLS compute_4pl_bounds() parameterisation: the
feasible band $[\ell, u]$ (default $[0, 1]$) is split at its midpoint, and low
and up each map an unconstrained coefficient onto one half, so
$\mathrm{up} > \mathrm{low}$ holds automatically:
$$ \mathrm{low} = \ell_{\min} + w_\mathrm{low}\,\mathrm{logit}^{-1}(\beta_\mathrm{low}), \qquad \mathrm{up} = u_{\min} + w_\mathrm{up}\,\mathrm{logit}^{-1}(\beta_\mathrm{up}). $$
low is confined to the lower half-band $[\ell_{\min}, \ell_{\max}]$ and up to the
upper half-band $[u_{\min}, u_{\max}]$ (the bands meet, with a tiny separating gap, at
the midpoint). Any $(\beta_\mathrm{low}, \beta_\mathrm{up})$ therefore gives a valid
ordered pair $\ell < \mathrm{low} < \mathrm{up} < u$. This is unconstrained and smooth,
which keeps the optimiser and the profiles well-behaved, and it matches bayesTLS exactly
so the two packages share the asymptote contract.
Under this parameterisation up is fitted through its own coordinate
$\beta_\mathrm{up}$, just as low is fitted through $\beta_\mathrm{low}$. The
limitation concerns interval computation, not fitting: freqTLS does not yet
profile $\beta_\mathrm{up}$, so it reports a delta-method Wald interval for up
(or a bootstrap interval when requested). The full table of parameters and links:
| Natural parameter | Internal coordinate | Link |
| --- | --- | --- |
| low | beta_low | logit (onto the lower half-band) |
| up | beta_up | logit (onto the upper half-band) |
| k | beta_logk | natural log (ln) |
| CTmax (per group) | beta_CT[g] | identity |
| z (per group) | beta_logz[g] | log |
| phi (beta-binomial) | log_phi | log |
A "lethal time" such as the LT$_{50}$ is the duration at which survival crosses a target probability. There are two conventions. A relative threshold is a position between the fitted asymptotes; an absolute threshold is a fixed survival probability on the response scale:
freqTLS default): the target is interpreted relative to the
fitted asymptotes, so relative fraction $0.5$ means halfway between low and up — which is exactly
the mean-curve midpoint $\mathrm{mid}$. This is the configuration that matches the bayesTLS
target_surv = "relative" setting and is what the benchmark uses (see
vignette("comparing-to-bayesTLS")).low and up.derive_lt() solves the selected mean curve for the duration at which survival reaches its numeric
absolute probability p, which must lie strictly between low and up. At the
relative midpoint, use p = (low + up) / 2; plot_tdt_curve() uses that midpoint
by default and can plot another valid absolute p. On the
$\log_{10} d$ axis the relative-threshold crossing is the line
$\log_{10} d = \mathrm{mid}(T) = \log_{10}(t_\mathrm{ref}) - (T - \mathrm{CTmax})/z$, whose
slope is $-1/z$ — the classic log-linear thermal death-time line.
# Absolute 50% survival at three temperatures, in minutes derive_lt(fit, p = 0.5, temp = c(35, 36, 37))
For the matched constant-shape log-logistic configuration
(temp_effects = "mid"), bayesTLS parameterises the midpoint as a line in
temperature,
$$ \mathrm{mid}(T) = b_{\mathrm{mid,Intercept}} + b_{\mathrm{mid},T_c}\,(T - \bar T), $$
and reads the thermal sensitivity and critical thermal maximum off that line:
$$ z = -\frac{1}{b_{\mathrm{mid},T_c}}, \qquad \mathrm{CTmax}(t_\mathrm{ref}) = \bar T + \frac{\log_{10}(t_\mathrm{ref}) - b_{\mathrm{mid,Intercept}}}{b_{\mathrm{mid},T_c}}. $$
Expanding the freqTLS midpoint as a line in $T$ gives the inverse map:
$$ \beta_1 = -\frac{1}{z}, \qquad \beta_0 = \log_{10}(t_\mathrm{ref}) + \frac{\mathrm{CTmax} - \bar T}{z}, $$
so
$$ z = -\frac{1}{\beta_1}, \qquad \mathrm{CTmax} = \bar T + \frac{\log_{10}(t_\mathrm{ref}) - \beta_0}{\beta_1}. $$
These are the midpoint-line identities used by bayesTLS. The
reparameterisation shares (low, up, k) and is smooth and invertible while z
is finite. Therefore a matched log-logistic, constant-shape, relative-threshold likelihood has
the same fitted curve under either coordinate system. Current bayesTLS also
offers direct CTmax/z parameterisation and an absolute-threshold option; numerical
comparisons must still match data, formulas, bounds, threshold, and random-effect
structure. freqTLS's distinct contribution is maximum-likelihood fitting with
direct profile-likelihood targets.
We can verify the bridge numerically without bayesTLS. Fit the midpoint line directly
from the model's own predicted midpoints (linear in $T$), then recover CTmax and z
from the slope and intercept:
Tbar <- mean(c(35, 37)) # any centring temperature works mids <- predict(fit, data.frame(temp = c(35, 37), duration = 60), type = "midpoint") beta1 <- diff(mids) / 2 # slope in T (= -1/z) beta0 <- mids[1] - beta1 * (35 - Tbar) # intercept at T = Tbar z_recovered <- -1 / beta1 ctmax_recovered <- Tbar + (log10(fit$tref) - beta0) / beta1 stopifnot( isTRUE(all.equal(unname(ctmax_recovered), unname(ct), tolerance = 1e-10)), isTRUE(all.equal(unname(z_recovered), unname(zz), tolerance = 1e-10)) ) rbind( fitted = c(CTmax = ct, z = zz), recovered = c(CTmax = ctmax_recovered, z = z_recovered) )
The recovered CTmax and z match the fitted values to numerical precision, confirming
that the direct parameterisation and the bayesTLS line are two coordinate systems for
the same curve. Equivariance of the profile likelihood under this monotone map is why the
z interval equals $\exp()$ of the internal log_z interval (see
vignette("profile-likelihood")).
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.