derive_z: Per-draw thermal sensitivity z directly from the joint...

View source: R/derive_tdt.R

derive_zR Documentation

Per-draw thermal sensitivity z directly from the joint posterior

Description

Derives z = -1 / (\mathrm{d}/\mathrm{d}T\,\log_{10}\mathrm{LT}(T)) per posterior draw, read straight from the fitted 4PL coefficients — no regression. There are two regimes:

Usage

derive_z(
  workflow,
  target_surv = "relative",
  temp_grid = NULL,
  ndraws = NULL,
  probs = c(0.025, 0.5, 0.975),
  h = 0.001,
  seed = NULL,
  by = NULL
)

Arguments

workflow

Fitted bayes_tls.

target_surv

Threshold mode: "relative" (default; = (low + up)/2), "absolute" (= 0.5), or a numeric in ⁠(0, 1)⁠.

temp_grid

Temperatures at which to evaluate local z and over which to pool. Default: the observed (unique) assay temperatures — pooling only where the data inform the curve.

ndraws

Posterior draws to subsample, or NULL (default) for all.

probs

Quantile probabilities for the summaries. Default c(0.025, 0.5, 0.975).

h

Temperature step (°C) for the central finite difference. Default 1e-3. (For a linear midpoint — the relative threshold — the central difference is exact regardless.)

seed

Optional integer seeding the draw subsample (relevant only when ndraws is set) for reproducibility. NULL (default) leaves the RNG untouched.

by

Optional moderator column(s) for per-group z. NULL (default) uses the fit's moderators (meta$group_vars); a single-condition fit then returns one ungrouped result.

Details

  • Relative threshold (default; the (\ell+u)/2 midpoint): \log_{10}\mathrm{LT}_{\text{rel}}(T) = \mathrm{mid}(T) = \beta_0 + \beta_1 (T-\bar T) is exactly linear, so z = -1/\beta_1 where \beta_1 is the temperature slope on mid (b_mid_temp_c). The asymptotes \ell, u and slope k do not enter (the midpoint cancels the curve asymmetry). z is constant in temperature.

  • Absolute threshold p: the LT curve gains the fitted model's offset from the midpoint, \log_{10}\mathrm{LT}_p(T) = \mathrm{mid}(T) + C_p(T). For the log-logistic (fit_4pl()) C_p = \tfrac{1}{k(T)}\log\tfrac{u(T)-p}{p-\ell(T)}; the log-normal and Weibull models (fit_lognormal(), fit_weibull()) use their own closed forms. When \ell, u or k carry temperature effects this bends the curve, so z varies with temperature. A local z(T) = -1/m(T) is computed at each assay temperature, where the local slope m(T) is obtained by a central finite difference of the closed-form LT curve (step h). When the shape parameters are constant in T the correction is flat and this reduces to -1/\beta_1.

The returned pooled z (the default single summary) is the per-draw mean of the local z(T) over temp_grid. The full per-temperature local z(T) is also returned. z is invariant to the time unit (a constant time-multiplier shifts the LT intercept, not its slope), so no time_multiplier is needed here.

Value

A list with:

  • draws: tibble ⁠(.draw, z)⁠ — pooled per-draw z.

  • summary: tibble ⁠(z_median, z_lower, z_upper)⁠.

  • local_draws: tibble ⁠(.draw, temp, z)⁠ — local z(T) per draw.

  • local_summary: tibble ⁠(temp, z_median, z_lower, z_upper)⁠.

  • target_surv, temp_grid. For a grouped fit each tibble gains the moderator column(s).

Examples

## Not run: 
wf <- fit_4pl(std)
z  <- derive_z(wf)             # relative: z = -1 / b_mid_temp_c per draw
z$summary
derive_z(wf, target_surv = "absolute")$local_summary  # local z(T)

## End(Not run)

bayesTLS documentation built on Nov. 29, 2026, 1:06 a.m.